From 22d5aebaa59c51f873ef07ba6207383ed46197d5 Mon Sep 17 00:00:00 2001 From: Letter N <24603524+LetterN@users.noreply.github.com> Date: Fri, 24 Jul 2020 14:38:04 +0800 Subject: [PATCH] second batch - MAJOR: mech_fab, turrets --- code/game/machinery/computer/Operating.dm | 84 +- code/game/machinery/computer/camera.dm | 13 +- code/game/machinery/computer/crew.dm | 7 +- code/game/machinery/computer/dna_console.dm | 9 +- .../machinery/computer/launchpad_control.dm | 8 +- .../computer/prisoner/gulag_teleporter.dm | 9 +- code/game/machinery/computer/robot.dm | 9 +- code/game/machinery/computer/station_alert.dm | 8 +- code/game/machinery/computer/teleporter.dm | 26 +- code/game/machinery/doors/airlock.dm | 24 +- .../machinery/doors/airlock_electronics.dm | 10 +- code/game/machinery/doors/brigdoors.dm | 9 +- .../machinery/porta_turret/portable_turret.dm | 637 ++++++------- code/game/mecha/mech_bay.dm | 7 +- code/game/mecha/mech_fabricator.dm | 874 +++++++++++------- code/game/mecha/mecha_control_console.dm | 9 +- code/game/objects/items/RPD.dm | 29 +- code/game/objects/items/airlock_painter.dm | 6 +- code/game/objects/items/crayons.dm | 14 +- code/game/objects/items/eightball.dm | 10 +- 20 files changed, 988 insertions(+), 814 deletions(-) diff --git a/code/game/machinery/computer/Operating.dm b/code/game/machinery/computer/Operating.dm index c8efe319db..122e89dd93 100644 --- a/code/game/machinery/computer/Operating.dm +++ b/code/game/machinery/computer/Operating.dm @@ -43,69 +43,39 @@ table.computer = src break -/obj/machinery/computer/operating/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.not_incapacitated_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/computer/operating/ui_state(mob/user) + return GLOB.not_incapacitated_state + +/obj/machinery/computer/operating/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "OperatingComputer", name, 350, 470, master_ui, state) + ui = new(user, src, "OperatingComputer", name) ui.open() /obj/machinery/computer/operating/ui_data(mob/user) var/list/data = list() - data["table"] = table + var/list/surgeries = list() + for(var/X in advanced_surgeries) + var/datum/surgery/S = X + var/list/surgery = list() + surgery["name"] = initial(S.name) + surgery["desc"] = initial(S.desc) + surgeries += list(surgery) + data["surgeries"] = surgeries + data["patient"] = null if(table) - var/list/surgeries = list() - for(var/X in advanced_surgeries) - var/datum/surgery/S = X - var/list/surgery = list() - surgery["name"] = initial(S.name) - surgery["desc"] = initial(S.desc) - surgeries += list(surgery) - data["surgeries"] = surgeries - if(table.check_patient()) + data["table"] = table + if(!table.check_eligible_patient()) + return data + data["patient"] = list() + patient = table.patient + else + if(sbed) + data["table"] = sbed + if(!ishuman(sbed.occupant) && !ismonkey(sbed.occupant)) + return data data["patient"] = list() - patient = table.patient - switch(patient.stat) - if(CONSCIOUS) - data["patient"]["stat"] = "Conscious" - data["patient"]["statstate"] = "good" - if(SOFT_CRIT) - data["patient"]["stat"] = "Conscious" - data["patient"]["statstate"] = "average" - if(UNCONSCIOUS) - data["patient"]["stat"] = "Unconscious" - data["patient"]["statstate"] = "average" - if(DEAD) - data["patient"]["stat"] = "Dead" - data["patient"]["statstate"] = "bad" - data["patient"]["health"] = patient.health - data["patient"]["blood_type"] = patient.dna.blood_type - data["patient"]["maxHealth"] = patient.maxHealth - data["patient"]["minHealth"] = HEALTH_THRESHOLD_DEAD - data["patient"]["bruteLoss"] = patient.getBruteLoss() - data["patient"]["fireLoss"] = patient.getFireLoss() - data["patient"]["toxLoss"] = patient.getToxLoss() - data["patient"]["oxyLoss"] = patient.getOxyLoss() - if(patient.surgeries.len) - data["procedures"] = list() - for(var/datum/surgery/procedure in patient.surgeries) - var/datum/surgery_step/surgery_step = procedure.get_surgery_step() - var/chems_needed = surgery_step.get_chem_list() - var/alternative_step - var/alt_chems_needed = "" - if(surgery_step.repeatable) - var/datum/surgery_step/next_step = procedure.get_surgery_next_step() - if(next_step) - alternative_step = capitalize(next_step.name) - alt_chems_needed = next_step.get_chem_list() - else - alternative_step = "Finish operation" - data["procedures"] += list(list( - "name" = capitalize(procedure.name), - "next_step" = capitalize(surgery_step.name), - "chems_needed" = chems_needed, - "alternative_step" = alternative_step, - "alt_chems_needed" = alt_chems_needed - )) + patient = sbed.occupant else data["patient"] = null return data @@ -153,6 +123,8 @@ )) return data + + /obj/machinery/computer/operating/ui_act(action, params) if(..()) return diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index 2b3416e1c8..5c8173adae 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -5,8 +5,6 @@ icon_keyboard = "security_key" circuit = /obj/item/circuitboard/computer/security light_color = LIGHT_COLOR_RED - ui_x = 870 - ui_y = 708 var/list/network = list("ss13") var/obj/machinery/camera/active_camera @@ -55,11 +53,9 @@ network -= i network += "[idnum][i]" -/obj/machinery/computer/security/ui_interact(\ - mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) +/obj/machinery/computer/security/ui_interact(mob/user, datum/tgui/ui) // Update UI - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) + ui = SStgui.try_update_ui(user, src, ui) // Show static if can't use the camera if(!active_camera?.can_use()) show_camera_static() @@ -76,10 +72,11 @@ use_power(active_power_usage) // Register map objects user.client.register_map_obj(cam_screen) - user.client.register_map_obj(cam_plane_master) + for(var/plane in cam_plane_masters) + user.client.register_map_obj(plane) user.client.register_map_obj(cam_background) // Open UI - ui = new(user, src, ui_key, "CameraConsole", name, ui_x, ui_y, master_ui, state) + ui = new(user, src, "CameraConsole", name) ui.open() /obj/machinery/computer/security/ui_data() diff --git a/code/game/machinery/computer/crew.dm b/code/game/machinery/computer/crew.dm index cd8b5c1c59..19da4f75d8 100644 --- a/code/game/machinery/computer/crew.dm +++ b/code/game/machinery/computer/crew.dm @@ -76,11 +76,10 @@ GLOBAL_DATUM_INIT(crewmonitor, /datum/crewmonitor, new) /datum/crewmonitor/Destroy() return ..() -/datum/crewmonitor/ui_interact(mob/user, ui_key = "crew", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/datum/crewmonitor/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if (!ui) - ui = new(user, src, ui_key, "CrewConsole", "crew monitor", 800, 600 , master_ui, state) + ui = new(user, src, "CrewConsole") ui.open() /datum/crewmonitor/proc/show(mob/M, source) diff --git a/code/game/machinery/computer/dna_console.dm b/code/game/machinery/computer/dna_console.dm index 2dce50aa88..286c106788 100644 --- a/code/game/machinery/computer/dna_console.dm +++ b/code/game/machinery/computer/dna_console.dm @@ -220,9 +220,7 @@ /obj/machinery/computer/scan_consolenew/examine(mob/user) . = ..() -/obj/machinery/computer/scan_consolenew/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - . = ..() - +/obj/machinery/computer/scan_consolenew/ui_interact(mob/user, datum/tgui/ui) // Most of ui_interact is spent setting variables for passing to the tgui // interface. // We can also do some general state processing here too as it's a good @@ -264,10 +262,9 @@ time_to_pulse = round((rad_pulse_timer - world.time)/10) // Attempt to update tgui ui, open and update if needed. - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) - + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "DnaConsole", name, 539, 710, master_ui, state) + ui = new(user, src, "DnaConsole") ui.open() /obj/machinery/computer/scan_consolenew/ui_data(mob/user) diff --git a/code/game/machinery/computer/launchpad_control.dm b/code/game/machinery/computer/launchpad_control.dm index fdbe2f1060..b2f7ae73a1 100644 --- a/code/game/machinery/computer/launchpad_control.dm +++ b/code/game/machinery/computer/launchpad_control.dm @@ -53,10 +53,10 @@ var/obj/machinery/launchpad/pad = launchpads[number] return pad -/obj/machinery/computer/launchpad/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/computer/launchpad/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "LaunchpadConsole", name, ui_x, ui_y, master_ui, state) + ui = new(user, src, "LaunchpadConsole", name) ui.open() /obj/machinery/computer/launchpad/ui_data(mob/user) @@ -128,4 +128,4 @@ if("pull") teleport(usr, current_pad, FALSE) . = TRUE - . = TRUE \ No newline at end of file + . = TRUE diff --git a/code/game/machinery/computer/prisoner/gulag_teleporter.dm b/code/game/machinery/computer/prisoner/gulag_teleporter.dm index dd925fbe3b..13727b585b 100644 --- a/code/game/machinery/computer/prisoner/gulag_teleporter.dm +++ b/code/game/machinery/computer/prisoner/gulag_teleporter.dm @@ -6,8 +6,6 @@ icon_keyboard = "security_key" req_access = list(ACCESS_ARMORY) circuit = /obj/item/circuitboard/computer/gulag_teleporter_console - ui_x = 350 - ui_y = 295 var/default_goal = 200 var/obj/machinery/gulag_teleporter/teleporter = null @@ -21,11 +19,10 @@ . = ..() scan_machinery() -/obj/machinery/computer/prisoner/gulag_teleporter_computer/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/computer/prisoner/gulag_teleporter_computer/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "GulagTeleporterConsole", name, ui_x, ui_y, master_ui, state) + ui = new(user, src, "GulagTeleporterConsole", name) ui.open() /obj/machinery/computer/prisoner/gulag_teleporter_computer/ui_data(mob/user) diff --git a/code/game/machinery/computer/robot.dm b/code/game/machinery/computer/robot.dm index 4fd9665b1d..401d05da12 100644 --- a/code/game/machinery/computer/robot.dm +++ b/code/game/machinery/computer/robot.dm @@ -23,11 +23,10 @@ return return TRUE -/obj/machinery/computer/robotics/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/computer/robotics/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "RoboticsControlConsole", name, ui_x, ui_y, master_ui, state) + ui = new(user, src, "RoboticsControlConsole", name) ui.open() /obj/machinery/computer/robotics/ui_data(mob/user) @@ -123,5 +122,5 @@ var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread s.set_up(3, TRUE, D) s.start() - D.visible_message("\the [D] self destructs!") + D.visible_message("\the [D] self-destructs!") D.gib() diff --git a/code/game/machinery/computer/station_alert.dm b/code/game/machinery/computer/station_alert.dm index b4340b9350..7b2e6ab455 100644 --- a/code/game/machinery/computer/station_alert.dm +++ b/code/game/machinery/computer/station_alert.dm @@ -16,11 +16,10 @@ GLOB.alert_consoles -= src return ..() -/obj/machinery/computer/station_alert/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/computer/station_alert/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "StationAlertConsole", name, 325, 500, master_ui, state) + ui = new(user, src, "StationAlertConsole", name) ui.open() /obj/machinery/computer/station_alert/ui_data(mob/user) @@ -31,6 +30,7 @@ data["alarms"][class] = list() for(var/area in alarms[class]) data["alarms"][class] += area + return data /obj/machinery/computer/station_alert/proc/triggerAlarm(class, area/A, O, obj/source) diff --git a/code/game/machinery/computer/teleporter.dm b/code/game/machinery/computer/teleporter.dm index e7957a5b75..3a8ff7bf19 100644 --- a/code/game/machinery/computer/teleporter.dm +++ b/code/game/machinery/computer/teleporter.dm @@ -34,11 +34,10 @@ break return power_station -obj/machinery/computer/teleporter/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/computer/teleporter/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "Teleporter", name, ui_x, ui_y, master_ui, state) + ui = new(user, src, "Teleporter", name) ui.open() /obj/machinery/computer/teleporter/ui_data(mob/user) @@ -56,7 +55,6 @@ obj/machinery/computer/teleporter/ui_interact(mob/user, ui_key = "main", datum/t return data - /obj/machinery/computer/teleporter/ui_act(action, params) if(..()) return @@ -92,16 +90,18 @@ obj/machinery/computer/teleporter/ui_interact(mob/user, ui_key = "main", datum/t say("Processing hub calibration to target...") calibrating = TRUE power_station.update_icon() - spawn(50 * (3 - power_station.teleporter_hub.accuracy)) //Better parts mean faster calibration - calibrating = FALSE - if(check_hub_connection()) - power_station.teleporter_hub.calibrated = TRUE - say("Calibration complete.") - else - say("Error: Unable to detect hub.") - power_station.update_icon() + addtimer(CALLBACK(src, .proc/finish_calibration), 50 * (3 - power_station.teleporter_hub.accuracy)) //Better parts mean faster calibration . = TRUE +/obj/machinery/computer/teleporter/proc/finish_calibration() + calibrating = FALSE + if(check_hub_connection()) + power_station.teleporter_hub.calibrated = TRUE + say("Calibration complete.") + else + say("Error: Unable to detect hub.") + power_station.update_icon() + /obj/machinery/computer/teleporter/proc/check_hub_connection() if(!power_station) return FALSE diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index a950cb7e7d..d403b32896 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -298,10 +298,10 @@ /obj/machinery/door/airlock/Destroy() QDEL_NULL(wires) + QDEL_NULL(electronics) if(charge) qdel(charge) charge = null - QDEL_NULL(electronics) if (cyclelinkedairlock) if (cyclelinkedairlock.cyclelinkedairlock == src) cyclelinkedairlock.cyclelinkedairlock = null @@ -309,7 +309,7 @@ if(id_tag) for(var/obj/machinery/doorButtons/D in GLOB.machines) D.removeMe(src) - qdel(note) + QDEL_NULL(note) for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds) diag_hud.remove_from_hud(src) return ..() @@ -1440,11 +1440,10 @@ else if(istype(note, /obj/item/photo)) return "photo" -/obj/machinery/door/airlock/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/door/airlock/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "AiAirlock", name, 500, 390, master_ui, state) + ui = new(user, src, "AiAirlock", name) ui.open() return TRUE @@ -1452,10 +1451,10 @@ var/list/data = list() var/list/power = list() - power["main"] = src.secondsMainPowerLost ? 0 : 2 // boolean - power["main_timeleft"] = src.secondsMainPowerLost - power["backup"] = src.secondsBackupPowerLost ? 0 : 2 // boolean - power["backup_timeleft"] = src.secondsBackupPowerLost + power["main"] = secondsMainPowerLost ? 0 : 2 // boolean + power["main_timeleft"] = secondsMainPowerLost + power["backup"] = secondsBackupPowerLost ? 0 : 2 // boolean + power["backup_timeleft"] = secondsBackupPowerLost data["power"] = power data["shock"] = secondsElectrified == 0 ? 2 : 0 @@ -1495,14 +1494,14 @@ loseMainPower() update_icon() else - to_chat(usr, "Main power is already offline.") + to_chat(usr, "Main power is already offline.") . = TRUE if("disrupt-backup") if(!secondsBackupPowerLost) loseBackupPower() update_icon() else - to_chat(usr, "Backup power is already offline.") + to_chat(usr, "Backup power is already offline.") . = TRUE if("shock-restore") shock_restore(usr) @@ -1531,7 +1530,6 @@ . = TRUE if("speed-toggle") normalspeed = !normalspeed - . = TRUE if("open-close") user_toggle_open(usr) diff --git a/code/game/machinery/doors/airlock_electronics.dm b/code/game/machinery/doors/airlock_electronics.dm index a0ce3954c3..ef2be8d744 100644 --- a/code/game/machinery/doors/airlock_electronics.dm +++ b/code/game/machinery/doors/airlock_electronics.dm @@ -15,11 +15,13 @@ . = ..() . += "Has a neat selection menu for modifying airlock access levels." -/obj/item/electronics/airlock/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.hands_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/item/electronics/airlock/ui_state(mob/user) + return GLOB.hands_state + +/obj/item/electronics/airlock/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "AirlockElectronics", name, 420, 485, master_ui, state) + ui = new(user, src, "AirlockElectronics", name) ui.open() /obj/item/electronics/airlock/ui_static_data(mob/user) diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm index 5a1ed7dd19..b2e0050819 100644 --- a/code/game/machinery/doors/brigdoors.dm +++ b/code/game/machinery/doors/brigdoors.dm @@ -140,11 +140,10 @@ . = new_time == timer_duration //return 1 on no change timer_duration = new_time -/obj/machinery/door_timer/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/door_timer/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "BrigTimer", name, 300, 138, master_ui, state) + ui = new(user, src, "BrigTimer", name) ui.open() //icon update function @@ -235,7 +234,7 @@ preset_time = PRESET_LONG . = set_timer(preset_time) if(timing) - activation_time = REALTIMEOFDAY + activation_time = world.time else . = FALSE diff --git a/code/game/machinery/porta_turret/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm index 1887ee46c0..38597ea158 100644 --- a/code/game/machinery/porta_turret/portable_turret.dm +++ b/code/game/machinery/porta_turret/portable_turret.dm @@ -4,6 +4,15 @@ #define POPUP_ANIM_TIME 5 #define POPDOWN_ANIM_TIME 5 //Be sure to change the icon animation at the same time or it'll look bad +#define TURRET_FLAG_SHOOT_ALL_REACT (1<<0) // The turret gets pissed off and shoots at people nearby (unless they have sec access!) +#define TURRET_FLAG_AUTH_WEAPONS (1<<1) // Checks if it can shoot people that have a weapon they aren't authorized to have +#define TURRET_FLAG_SHOOT_CRIMINALS (1<<2) // Checks if it can shoot people that are wanted +#define TURRET_FLAG_SHOOT_ALL (1<<3) // The turret gets pissed off and shoots at people nearby (unless they have sec access!) +#define TURRET_FLAG_SHOOT_ANOMALOUS (1<<4) // Checks if it can shoot at unidentified lifeforms (ie xenos) +#define TURRET_FLAG_SHOOT_UNSHIELDED (1<<5) // Checks if it can shoot people that aren't mindshielded and who arent heads +#define TURRET_FLAG_SHOOT_BORGS (1<<6) // checks if it can shoot cyborgs +#define TURRET_FLAG_SHOOT_HEADS (1<<7) // checks if it can shoot at heads of staff + /obj/machinery/porta_turret name = "turret" icon = 'icons/obj/turrets.dmi' @@ -15,68 +24,72 @@ use_power = IDLE_POWER_USE //this turret uses and requires power idle_power_usage = 50 //when inactive, this turret takes up constant 50 Equipment power active_power_usage = 300 //when active, this turret takes up constant 300 Equipment power - req_access = list(ACCESS_SEC_DOORS) - power_channel = EQUIP //drains power from the EQUIPMENT channel - - var/base_icon_state = "standard" - var/scan_range = 7 - var/atom/base = null //for turrets inside other objects - - var/raised = 0 //if the turret cover is "open" and the turret is raised - var/raising= 0 //if the turret is currently opening or closing its cover - + req_access = list(ACCESS_SECURITY) /// Only people with Security access + power_channel = AREA_USAGE_EQUIP //drains power from the EQUIPMENT channel max_integrity = 160 //the turret's health integrity_failure = 0.5 armor = list("melee" = 50, "bullet" = 30, "laser" = 30, "energy" = 30, "bomb" = 30, "bio" = 0, "rad" = 0, "fire" = 90, "acid" = 90) - - var/locked = TRUE //if the turret's behaviour control access is locked - var/controllock = FALSE //if the turret responds to control panels - - var/installation = /obj/item/gun/energy/e_gun/turret //the type of weapon installed by default + /// Base turret icon state + var/base_icon_state = "standard" + /// Scan range of the turret for locating targets + var/scan_range = 7 + /// For turrets inside other objects + var/atom/base = null + /// If the turret cover is "open" and the turret is raised + var/raised = FALSE + /// If the turret is currently opening or closing its cover + var/raising = FALSE + /// If the turret's behaviour control access is locked + var/locked = TRUE + /// If the turret responds to control panels + var/controllock = FALSE + /// The type of weapon installed by default + var/installation = /obj/item/gun/energy/e_gun/turret + /// What stored gun is in the turret var/obj/item/gun/stored_gun = null - var/gun_charge = 0 //the charge of the gun when retrieved from wreckage - + /// The charge of the gun when retrieved from wreckage + var/gun_charge = 0 + /// In which mode is turret in, stun or lethal var/mode = TURRET_STUN - - var/stun_projectile = null //stun mode projectile type + /// Stun mode projectile type + var/stun_projectile = null + /// Sound of stun projectile var/stun_projectile_sound - var/nonlethal_projectile //projectile to use in stun mode when the target is resting, if any - var/nonlethal_projectile_sound - var/lethal_projectile = null //lethal mode projectile type + /// Lethal mode projectile type + var/lethal_projectile = null + /// Sound of lethal projectile var/lethal_projectile_sound - - var/reqpower = 500 //power needed per shot - var/always_up = 0 //Will stay active - var/has_cover = 1 //Hides the cover - - var/obj/machinery/porta_turret_cover/cover = null //the cover that is covering this turret - - var/last_fired = 0 //world.time the turret last fired - var/shot_delay = 15 //ticks until next shot (1.5 ?) - - - var/check_records = 1 //checks if it can use the security records - var/criminals = 1 //checks if it can shoot people on arrest - var/auth_weapons = 0 //checks if it can shoot people that have a weapon they aren't authorized to have - var/stun_all = 0 //if this is active, the turret shoots everything that isn't security or head of staff - var/check_anomalies = 1 //checks if it can shoot at unidentified lifeforms (ie xenos) - var/shoot_unloyal = 0 //checks if it can shoot people that aren't loyalty implantd - - var/attacked = 0 //if set to 1, the turret gets pissed off and shoots at people nearby (unless they have sec access!) - - var/on = TRUE //determines if the turret is on - - var/list/faction = list("turret") // Same faction mobs will never be shot at, no matter the other settings - - var/datum/effect_system/spark_spread/spark_system //the spark system, used for generating... sparks? - + /// Power needed per shot + var/reqpower = 500 + /// Will stay active + var/always_up = FALSE + /// Hides the cover + var/has_cover = TRUE + /// The cover that is covering this turret + var/obj/machinery/porta_turret_cover/cover = null + /// World.time the turret last fired + var/last_fired = 0 + /// Ticks until next shot (1.5 ?) + var/shot_delay = 15 + /// Turret flags about who is turret allowed to shoot + var/turret_flags = TURRET_FLAG_SHOOT_CRIMINALS | TURRET_FLAG_SHOOT_ANOMALOUS + /// Determines if the turret is on + var/on = TRUE + /// Same faction mobs will never be shot at, no matter the other settings + var/list/faction = list("turret") + /// The spark system, used for generating... sparks? + var/datum/effect_system/spark_spread/spark_system + /// Linked turret control panel of the turret var/obj/machinery/turretid/cp = null - - var/wall_turret_direction //The turret will try to shoot from a turf in that direction when in a wall - - var/manual_control = FALSE // + /// The turret will try to shoot from a turf in that direction when in a wall + var/wall_turret_direction + /// If the turret is manually controlled + var/manual_control = FALSE + /// Action button holder for quitting manual control var/datum/action/turret_quit/quit_action + /// Action button holder for switching between turret modes when manually controlling var/datum/action/turret_toggle/toggle_action + /// Mob that is remotely controlling the turret var/mob/remote_controller /obj/machinery/porta_turret/Initialize() @@ -99,6 +112,25 @@ if(!has_cover) INVOKE_ASYNC(src, .proc/popUp) +/obj/machinery/porta_turret/proc/toggle_on(var/set_to) + var/current = on + if (!isnull(set_to)) + on = set_to + else + on = !on + if (current != on) + check_should_process() + if (!on) + popDown() + +/obj/machinery/porta_turret/proc/check_should_process() + if (datum_flags & DF_ISPROCESSING) + if (!on || !anchored || (stat & BROKEN) || !powered()) + end_processing() + else + if (on && anchored && !(stat & BROKEN) && powered()) + begin_processing() + /obj/machinery/porta_turret/update_icon_state() if(!anchored) icon_state = "turretCover" @@ -118,7 +150,6 @@ else icon_state = "[base_icon_state]_unpowered" - /obj/machinery/porta_turret/proc/setup(obj/item/gun/turret_gun) if(stored_gun) qdel(stored_gun) @@ -159,83 +190,88 @@ remove_control() return ..() -/obj/machinery/porta_turret/ui_interact(mob/user) - . = ..() - var/dat - dat += "Status: [on ? "On" : "Off"]
" - dat += "Behaviour controls are [locked ? "locked" : "unlocked"]
" +/obj/machinery/porta_turret/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "PortableTurret", name) + ui.open() - if(!locked) - dat += "Check for Weapon Authorization: [auth_weapons ? "Yes" : "No"]
" - dat += "Check Security Records: [check_records ? "Yes" : "No"]
" - dat += "Neutralize Identified Criminals: [criminals ? "Yes" : "No"]
" - dat += "Neutralize All Non-Security and Non-Command Personnel: [stun_all ? "Yes" : "No"]
" - dat += "Neutralize All Unidentified Life Signs: [check_anomalies ? "Yes" : "No"]
" - dat += "Neutralize All Non-Loyalty Implanted Personnel: [shoot_unloyal ? "Yes" : "No"]
" +/obj/machinery/porta_turret/ui_data(mob/user) + var/list/data = list( + "locked" = locked, + "on" = on, + "check_weapons" = turret_flags & TURRET_FLAG_AUTH_WEAPONS, + "neutralize_criminals" = turret_flags & TURRET_FLAG_SHOOT_CRIMINALS, + "neutralize_all" = turret_flags & TURRET_FLAG_SHOOT_ALL, + "neutralize_unidentified" = turret_flags & TURRET_FLAG_SHOOT_ANOMALOUS, + "neutralize_nonmindshielded" = turret_flags & TURRET_FLAG_SHOOT_UNSHIELDED, + "neutralize_cyborgs" = turret_flags & TURRET_FLAG_SHOOT_BORGS, + "ignore_heads" = turret_flags & TURRET_FLAG_SHOOT_HEADS, + "manual_control" = manual_control, + "silicon_user" = FALSE, + "allow_manual_control" = FALSE, + "lasertag_turret" = istype(src, /obj/machinery/porta_turret/lasertag), + ) if(issilicon(user)) + data["silicon_user"] = TRUE if(!manual_control) var/mob/living/silicon/S = user if(S.hack_software) - dat += "Assume direct control : Manual Control
" - else - dat += "Warning! Remote control protocol enabled.
" + data["allow_manual_control"] = TRUE + return data - - var/datum/browser/popup = new(user, "autosec", "Automatic Portable Turret Installation", 300, 300) - popup.set_content(dat) - popup.open() - -/obj/machinery/porta_turret/Topic(href, href_list) - if(..()) - return - usr.set_machine(src) - add_fingerprint(usr) - - if(href_list["power"] && !locked) - if(anchored) //you can't turn a turret on/off if it's not anchored/secured - on = !on //toggle on/off - else - to_chat(usr, "It has to be secured first!") - interact(usr) +/obj/machinery/porta_turret/ui_act(action, list/params) + . = ..() + if(.) return - if(href_list["operation"]) - switch(href_list["operation"]) //toggles customizable behavioural protocols - if("authweapon") - auth_weapons = !auth_weapons - if("checkrecords") - check_records = !check_records - if("shootcrooks") - criminals = !criminals - if("shootall") - stun_all = !stun_all - if("checkxenos") - check_anomalies = !check_anomalies - if("checkloyal") - shoot_unloyal = !shoot_unloyal - if("manual") - if(issilicon(usr) && !manual_control) - give_control(usr) - interact(usr) + switch(action) + if("power") + if(anchored) + toggle_on() + return TRUE + else + to_chat(usr, "It has to be secured first!") + if("authweapon") + turret_flags ^= TURRET_FLAG_AUTH_WEAPONS + return TRUE + if("shootcriminals") + turret_flags ^= TURRET_FLAG_SHOOT_CRIMINALS + return TRUE + if("shootall") + turret_flags ^= TURRET_FLAG_SHOOT_ALL + return TRUE + if("checkxenos") + turret_flags ^= TURRET_FLAG_SHOOT_ANOMALOUS + return TRUE + if("checkloyal") + turret_flags ^= TURRET_FLAG_SHOOT_UNSHIELDED + return TRUE + if("shootborgs") + turret_flags ^= TURRET_FLAG_SHOOT_BORGS + return TRUE + if("shootheads") + turret_flags ^= TURRET_FLAG_SHOOT_HEADS + return TRUE + if("manual") + if(!issilicon(usr)) + return + give_control(usr) + return TRUE + +/obj/machinery/porta_turret/ui_host(mob/user) + if(has_cover && cover) + return cover + if(base) + return base + return src /obj/machinery/porta_turret/power_change() - if(!anchored) + . = ..() + if(!anchored || (stat & BROKEN) || !powered()) update_icon() remove_control() - return - if(stat & BROKEN) - update_icon() - remove_control() - else - if( powered() ) - stat &= ~NOPOWER - update_icon() - else - spawn(rand(0, 15)) - stat |= NOPOWER - remove_control() - update_icon() - + check_should_process() /obj/machinery/porta_turret/attackby(obj/item/I, mob/user, params) if(stat & BROKEN) @@ -283,8 +319,10 @@ locked = !locked to_chat(user, "Controls are now [locked ? "locked" : "unlocked"].") else - to_chat(user, "Access denied.") + to_chat(user, "Access denied.") else if(istype(I, /obj/item/multitool) && !locked) + if(!multitool_check_buffer(user, I)) + return var/obj/item/multitool/M = I M.buffer = src to_chat(user, "You add [src] to multitool buffer.") @@ -292,19 +330,17 @@ return ..() /obj/machinery/porta_turret/emag_act(mob/user) - . = ..() if(obj_flags & EMAGGED) return to_chat(user, "You short out [src]'s threat assessment circuits.") - visible_message("[src] hums oddly...") + audible_message("[src] hums oddly...") obj_flags |= EMAGGED controllock = TRUE - on = FALSE //turns off the turret temporarily + toggle_on(FALSE) //turns off the turret temporarily update_icon() - sleep(60) //6 seconds for the traitor to gtfo of the area before the turret decides to ruin his shit - on = TRUE //turns it back on. The cover popUp() popDown() are automatically called in process(), no need to define it here - return TRUE - + //6 seconds for the traitor to gtfo of the area before the turret decides to ruin his shit + addtimer(CALLBACK(src, .proc/toggle_on, TRUE), 6 SECONDS) + //turns it back on. The cover popUp() popDown() are automatically called in process(), no need to define it here /obj/machinery/porta_turret/emp_act(severity) . = ..() @@ -313,63 +349,41 @@ if(on) //if the turret is on, the EMP no matter how severe disables the turret for a while //and scrambles its settings, with a slight chance of having an emag effect - check_records = pick(0, 1) - criminals = pick(0, 1) - auth_weapons = pick(0, 1) - stun_all = pick(0, 0, 0, 0, 1) //stun_all is a pretty big deal, so it's least likely to get turned on + if(prob(50)) + turret_flags |= TURRET_FLAG_SHOOT_CRIMINALS + if(prob(50)) + turret_flags |= TURRET_FLAG_AUTH_WEAPONS + if(prob(20)) + turret_flags |= TURRET_FLAG_SHOOT_ALL // Shooting everyone is a pretty big deal, so it's least likely to get turned on - on = FALSE + toggle_on(FALSE) remove_control() - spawn(rand(60,600)) - if(!on) - on = TRUE + addtimer(CALLBACK(src, .proc/toggle_on, TRUE), rand(60,600)) /obj/machinery/porta_turret/take_damage(damage, damage_type = BRUTE, damage_flag = 0, sound_effect = 1) . = ..() - if(.) //damage received + if(. && obj_integrity > 0) //damage received if(prob(30)) spark_system.start() - if(on && !attacked && !(obj_flags & EMAGGED)) - attacked = TRUE + if(on && !(turret_flags & TURRET_FLAG_SHOOT_ALL_REACT) && !(obj_flags & EMAGGED)) + turret_flags |= TURRET_FLAG_SHOOT_ALL_REACT addtimer(CALLBACK(src, .proc/reset_attacked), 60) /obj/machinery/porta_turret/proc/reset_attacked() - attacked = FALSE + turret_flags &= ~TURRET_FLAG_SHOOT_ALL_REACT /obj/machinery/porta_turret/deconstruct(disassembled = TRUE) qdel(src) /obj/machinery/porta_turret/obj_break(damage_flag) - if(!(flags_1 & NODECONSTRUCT_1) && !(stat & BROKEN)) - stat |= BROKEN //enables the BROKEN bit + . = ..() + if(.) power_change() invisibility = 0 spark_system.start() //creates some sparks because they look cool qdel(cover) //deletes the cover - no need on keeping it there! -//turret healing -/obj/machinery/porta_turret/examine(mob/user) - . = ..() - if(obj_integrity < max_integrity) - . += "Use a welder to fix it." - -/obj/machinery/porta_turret/welder_act(mob/living/user, obj/item/I) - . = TRUE - if(obj_integrity < max_integrity) - if(!I.tool_start_check(user, amount=0)) - return - user.visible_message("[user] is welding the turret.", \ - "You begin repairing the turret...", \ - "You hear welding.") - if(I.use_tool(src, user, 40, volume=50)) - obj_integrity = max_integrity - user.visible_message("[user.name] has repaired [src].", \ - "You finish repairing the turret.") - else - to_chat(user, "The turret doesn't need repairing.") - - /obj/machinery/porta_turret/process() //the main machinery process if(cover == null && anchored) //if it has no cover and is anchored @@ -381,35 +395,43 @@ cover.parent_turret = src //assign the cover its parent_turret, which would be this (src) if(!on || (stat & (NOPOWER|BROKEN)) || manual_control) - return + return PROCESS_KILL var/list/targets = list() for(var/mob/A in view(scan_range, base)) if(A.invisibility > SEE_INVISIBLE_LIVING) continue - if(check_anomalies)//if it's set to check for simple animals + if(turret_flags & TURRET_FLAG_SHOOT_ANOMALOUS)//if it's set to check for simple animals if(isanimal(A)) var/mob/living/simple_animal/SA = A if(SA.stat || in_faction(SA)) //don't target if dead or in faction continue targets += SA - if(issilicon(A)) - var/mob/living/silicon/sillycone = A - if(sillycone.stat || in_faction(sillycone)) + continue + + if(issilicon(A)) + var/mob/living/silicon/sillycone = A + + if(ispAI(A)) + continue + + if((turret_flags & TURRET_FLAG_SHOOT_BORGS) && sillycone.stat != DEAD && iscyborg(sillycone)) + targets += sillycone + continue + + if(sillycone.stat || in_faction(sillycone)) + continue + + if(iscyborg(sillycone)) + var/mob/living/silicon/robot/sillyconerobot = A + if(LAZYLEN(faction) && (ROLE_SYNDICATE in faction) && sillyconerobot.emagged == TRUE) continue - if(iscyborg(sillycone)) - var/mob/living/silicon/robot/sillyconerobot = A - if(LAZYLEN(faction) && (ROLE_SYNDICATE in faction) && sillyconerobot.emagged == TRUE) - continue - - targets += sillycone - - if(iscarbon(A)) + else if(iscarbon(A)) var/mob/living/carbon/C = A - //If not emagged, only target non downed carbons - if(mode != TURRET_LETHAL && (C.stat || C.handcuffed || (C.combat_flags & COMBAT_FLAG_HARD_STAMCRIT)))//CIT CHANGE - replaces check for lying with check for recoveringstam + //If not emagged, only target carbons that can use items + if(mode != TURRET_LETHAL && (C.stat || C.handcuffed || !(C.mobility_flags & MOBILITY_USE))) continue //If emagged, target all but dead carbons @@ -418,12 +440,13 @@ //if the target is a human and not in our faction, analyze threat level if(ishuman(C) && !in_faction(C)) + if(assess_perp(C) >= 4) targets += C - - else if(check_anomalies) //non humans who are not simple animals (xenos etc) + else if(turret_flags & TURRET_FLAG_SHOOT_ANOMALOUS) //non humans who are not simple animals (xenos etc) if(!in_faction(C)) targets += C + for(var/A in GLOB.mechas_list) if((get_dist(A, base) < scan_range) && can_see(base, A, scan_range)) var/obj/mecha/Mech = A @@ -431,6 +454,10 @@ if(assess_perp(Mech.occupant) >= 4) targets += Mech + if((turret_flags & TURRET_FLAG_SHOOT_ANOMALOUS) && GLOB.blobs.len && (mode == TURRET_LETHAL)) + for(var/obj/structure/blob/B in view(scan_range, base)) + targets += B + if(targets.len) tryToShootAt(targets) else if(!always_up) @@ -443,7 +470,6 @@ if(target(M)) return 1 - /obj/machinery/porta_turret/proc/popUp() //pops the turret up if(!anchored) return @@ -485,36 +511,37 @@ if(obj_flags & EMAGGED) return 10 //if emagged, always return 10. - if((stun_all || attacked) && !allowed(perp)) + if((turret_flags & (TURRET_FLAG_SHOOT_ALL | TURRET_FLAG_SHOOT_ALL_REACT)) && !allowed(perp)) //if the turret has been attacked or is angry, target all non-sec people if(!allowed(perp)) return 10 - if(auth_weapons) //check for weapon authorization + if(turret_flags & TURRET_FLAG_AUTH_WEAPONS) //check for weapon authorization if(isnull(perp.wear_id) || istype(perp.wear_id.GetID(), /obj/item/card/id/syndicate)) if(allowed(perp)) //if the perp has security access, return 0 return 0 - if(perp.is_holding_item_of_type(/obj/item/gun) || perp.is_holding_item_of_type(/obj/item/melee/baton)) threatcount += 4 if(istype(perp.belt, /obj/item/gun) || istype(perp.belt, /obj/item/melee/baton)) threatcount += 2 - if(check_records) //if the turret can check the records, check if they are set to *Arrest* on records + if(turret_flags & TURRET_FLAG_SHOOT_CRIMINALS) //if the turret can check the records, check if they are set to *Arrest* on records var/perpname = perp.get_face_name(perp.get_id_name()) var/datum/data/record/R = find_record("name", perpname, GLOB.data_core.security) if(!R || (R.fields["criminal"] == "*Arrest*")) threatcount += 4 - if(shoot_unloyal) - if (!HAS_TRAIT(perp, TRAIT_MINDSHIELD)) - threatcount += 4 + if((turret_flags & TURRET_FLAG_SHOOT_UNSHIELDED) && (!HAS_TRAIT(perp, TRAIT_MINDSHIELD))) + threatcount += 4 + + // If we aren't shooting heads then return a threatcount of 0 + if (!(turret_flags & TURRET_FLAG_SHOOT_HEADS) && (perp.get_assignment() in GLOB.command_positions)) + return 0 return threatcount - /obj/machinery/porta_turret/proc/in_faction(mob/target) for(var/faction1 in faction) if(faction1 in target.faction) @@ -557,26 +584,17 @@ T = closer break - var/mob/living/carbon/C - if(iscarbon(target)) - C = target - update_icon() var/obj/item/projectile/A //any emagged turrets drains 2x power and uses a different projectile? if(mode == TURRET_STUN) - if(nonlethal_projectile && C && C.resting) - use_power(reqpower*0.5) - A = new nonlethal_projectile(T) - playsound(loc, nonlethal_projectile_sound, 75, 1) - else - use_power(reqpower) - A = new stun_projectile(T) - playsound(loc, stun_projectile_sound, 75, 1) + use_power(reqpower) + A = new stun_projectile(T) + playsound(loc, stun_projectile_sound, 75, TRUE) else use_power(reqpower * 2) A = new lethal_projectile(T) - playsound(loc, lethal_projectile_sound, 75, 1) + playsound(loc, lethal_projectile_sound, 75, TRUE) //Shooting Code: @@ -586,16 +604,15 @@ A.fire() return A -/obj/machinery/porta_turret/proc/setState(on, mode) +/obj/machinery/porta_turret/proc/setState(on, mode, shoot_cyborgs) if(controllock) return - src.on = on - if(!on) - popDown() + + shoot_cyborgs ? (turret_flags |= TURRET_FLAG_SHOOT_BORGS) : (turret_flags &= ~TURRET_FLAG_SHOOT_BORGS) + toggle_on(on) src.mode = mode power_change() - /datum/action/turret_toggle name = "Toggle Mode" icon_icon = 'icons/mob/actions/actions_mecha.dmi' @@ -679,27 +696,30 @@ /obj/machinery/porta_turret/syndicate/ComponentInitialize() . = ..() - AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) + // AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) + AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) //this one or ^ one? + + +/obj/machinery/porta_turret/syndicate/setup() + return + +/obj/machinery/porta_turret/syndicate/assess_perp(mob/living/carbon/human/perp) + return 10 //Syndicate turrets shoot everything not in their faction /obj/machinery/porta_turret/syndicate/energy icon_state = "standard_stun" base_icon_state = "standard" stun_projectile = /obj/item/projectile/energy/electrode stun_projectile_sound = 'sound/weapons/taser.ogg' - nonlethal_projectile = /obj/item/projectile/beam/disabler - nonlethal_projectile_sound = 'sound/weapons/taser2.ogg' lethal_projectile = /obj/item/projectile/beam/laser lethal_projectile_sound = 'sound/weapons/laser.ogg' desc = "An energy blaster auto-turret." - /obj/machinery/porta_turret/syndicate/energy/heavy icon_state = "standard_stun" base_icon_state = "standard" stun_projectile = /obj/item/projectile/energy/electrode stun_projectile_sound = 'sound/weapons/taser.ogg' - nonlethal_projectile = /obj/item/projectile/beam/disabler - nonlethal_projectile_sound = 'sound/weapons/taser2.ogg' lethal_projectile = /obj/item/projectile/beam/laser/heavylaser lethal_projectile_sound = 'sound/weapons/lasercannonfire.ogg' desc = "An energy blaster auto-turret." @@ -709,14 +729,13 @@ integrity_failure = 0.08 armor = list("melee" = 50, "bullet" = 30, "laser" = 30, "energy" = 30, "bomb" = 50, "bio" = 0, "rad" = 0, "fire" = 90, "acid" = 90) - -/obj/machinery/porta_turret/syndicate/setup() - return - -/obj/machinery/porta_turret/syndicate/assess_perp(mob/living/carbon/human/perp) - return 10 //Syndicate turrets shoot everything not in their faction +/obj/machinery/porta_turret/syndicate/energy/raven + stun_projectile = /obj/item/projectile/beam/laser + stun_projectile_sound = 'sound/weapons/laser.ogg' + faction = list("neutral","silicon","turret") /obj/machinery/porta_turret/syndicate/pod + integrity_failure = 0.5 max_integrity = 40 stun_projectile = /obj/item/projectile/bullet/syndicate_turret lethal_projectile = /obj/item/projectile/bullet/syndicate_turret @@ -741,8 +760,7 @@ /obj/machinery/porta_turret/ai faction = list("silicon") - nonlethal_projectile = /obj/item/projectile/beam/disabler - nonlethal_projectile_sound = 'sound/weapons/taser2.ogg' + turret_flags = TURRET_FLAG_SHOOT_CRIMINALS | TURRET_FLAG_SHOOT_ANOMALOUS | TURRET_FLAG_SHOOT_HEADS /obj/machinery/porta_turret/ai/assess_perp(mob/living/carbon/human/perp) return 10 //AI turrets shoot at everything not in their faction @@ -798,6 +816,7 @@ /obj/machinery/porta_turret/centcom_shuttle/weak max_integrity = 120 + integrity_failure = 0.5 name = "Old Laser Turret" desc = "A turret built with substandard parts and run down further with age. Still capable of delivering lethal lasers to the odd space carp, but not much else." stun_projectile = /obj/item/projectile/beam/weak/penetrator @@ -811,7 +830,6 @@ stun_projectile_sound = 'sound/weapons/gunshot.ogg' desc = "A ballistic machine gun auto-turret." - //////////////////////// //Turret Control Panel// //////////////////////// @@ -822,14 +840,22 @@ icon = 'icons/obj/machines/turret_control.dmi' icon_state = "control_standby" density = FALSE - var/enabled = 1 - var/lethal = 0 - var/locked = TRUE - var/control_area = null //can be area name, path or nothing. - var/ailock = 0 // AI cannot use this req_access = list(ACCESS_AI_UPLOAD) - var/list/obj/machinery/porta_turret/turrets = list() resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF + /// Variable dictating if linked turrets are active and will shoot targets + var/enabled = TRUE + /// Variable dictating if linked turrets will shoot lethal projectiles + var/lethal = FALSE + /// Variable dictating if the panel is locked, preventing changes to turret settings + var/locked = TRUE + /// An area in which linked turrets are located, it can be an area name, path or nothing + var/control_area = null + /// AI is unable to use this machine if set to TRUE + var/ailock = FALSE + /// Variable dictating if linked turrets will shoot cyborgs + var/shoot_cyborgs = FALSE + /// List of all linked turrets + var/list/turrets = list() /obj/machinery/turretid/Initialize(mapload, ndir = 0, built = 0) . = ..() @@ -862,112 +888,111 @@ T.cp = src /obj/machinery/turretid/examine(mob/user) - . = ..() - if(hasSiliconAccessInArea(user) && (!stat & BROKEN)) - . += "Ctrl-click [src] to [ enabled ? "disable" : "enable"] turrets." - . += "Alt-click [src] to set turrets to [ lethal ? "stun" : "kill"]." + . += ..() + if(issilicon(user) && !(stat & BROKEN)) + . += {"Ctrl-click [src] to [ enabled ? "disable" : "enable"] turrets. + Alt-click [src] to set turrets to [ lethal ? "stun" : "kill"]."} /obj/machinery/turretid/attackby(obj/item/I, mob/user, params) if(stat & BROKEN) return if (istype(I, /obj/item/multitool)) + if(!multitool_check_buffer(user, I)) + return var/obj/item/multitool/M = I if(M.buffer && istype(M.buffer, /obj/machinery/porta_turret)) turrets |= M.buffer - to_chat(user, "You link \the [M.buffer] with \the [src]") + to_chat(user, "You link \the [M.buffer] with \the [src].") return - if (hasSiliconAccessInArea(user)) + if (issilicon(user)) return attack_hand(user) if ( get_dist(src, user) == 0 ) // trying to unlock the interface if (allowed(usr)) if(obj_flags & EMAGGED) - to_chat(user, "The turret control is unresponsive.") + to_chat(user, "The turret control is unresponsive!") return locked = !locked to_chat(user, "You [ locked ? "lock" : "unlock"] the panel.") - if (locked) - if (user.machine==src) - user.unset_machine() - user << browse(null, "window=turretid") - else - if (user.machine==src) - attack_hand(user) else - to_chat(user, "Access denied.") + to_chat(user, "Access denied.") /obj/machinery/turretid/emag_act(mob/user) - . = ..() if(obj_flags & EMAGGED) return - to_chat(user, "You short out the turret controls' access analysis module.") + to_chat(user, "You short out the turret controls' access analysis module.") obj_flags |= EMAGGED locked = FALSE - if(user && user.machine == src) - attack_hand(user) - return TRUE /obj/machinery/turretid/attack_ai(mob/user) - if(!ailock || IsAdminGhost(user)) + if(!ailock || isAdminGhostAI(user)) return attack_hand(user) else - to_chat(user, "There seems to be a firewall preventing you from accessing this device.") + to_chat(user, "There seems to be a firewall preventing you from accessing this device!") -/obj/machinery/turretid/ui_interact(mob/user) +/obj/machinery/turretid/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "TurretControl", name) + ui.open() + +/obj/machinery/turretid/ui_data(mob/user) + var/list/data = list() + data["locked"] = locked + data["siliconUser"] = user.has_unlimited_silicon_privilege + data["enabled"] = enabled + data["lethal"] = lethal + data["shootCyborgs"] = shoot_cyborgs + return data + +/obj/machinery/turretid/ui_act(action, list/params) . = ..() - if ( get_dist(src, user) > 0 ) - if ( !(hasSiliconAccessInArea(user) || IsAdminGhost(user)) ) - to_chat(user, "You are too far away.") - user.unset_machine() - user << browse(null, "window=turretid") - return - - var/t = "" - - if(locked && !(hasSiliconAccessInArea(user) || IsAdminGhost(user))) - t += "
Swipe ID card to unlock interface
" - else - if(!hasSiliconAccessInArea(user) && !IsAdminGhost(user)) - t += "
Swipe ID card to lock interface
" - t += "Turrets [enabled?"activated":"deactivated"] - [enabled?"Disable":"Enable"]?
" - t += "Currently set for [lethal?"lethal":"stun repeatedly"] - Change to [lethal?"Stun repeatedly":"Lethal"]?
" - - var/datum/browser/popup = new(user, "turretid", "Turret Control Panel ([get_area_name(src, TRUE)])") - popup.set_content(t) - popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state)) - popup.open() - -/obj/machinery/turretid/Topic(href, href_list) - if(..()) + if(.) return - if (locked) - if(!(hasSiliconAccessInArea(usr) || IsAdminGhost(usr))) - to_chat(usr, "Control panel is locked!") - return - if (href_list["toggleOn"]) - toggle_on() - else if (href_list["toggleLethal"]) - toggle_lethal() - attack_hand(usr) -/obj/machinery/turretid/proc/toggle_lethal() + switch(action) + if("lock") + if(!usr.has_unlimited_silicon_privilege) + return + if((obj_flags & EMAGGED) || (stat & BROKEN)) + to_chat(usr, "The turret control is unresponsive!") + return + locked = !locked + return TRUE + if("power") + toggle_on(usr) + return TRUE + if("mode") + toggle_lethal(usr) + return TRUE + if("shoot_silicons") + shoot_silicons(usr) + return TRUE + +/obj/machinery/turretid/proc/toggle_lethal(mob/user) lethal = !lethal + add_hiddenprint(user) + log_combat(user, src, "[lethal ? "enabled" : "disabled"] lethals on") updateTurrets() -/obj/machinery/turretid/proc/toggle_on() +/obj/machinery/turretid/proc/toggle_on(mob/user) enabled = !enabled + add_hiddenprint(user) + log_combat(user, src, "[enabled ? "enabled" : "disabled"]") + updateTurrets() + +/obj/machinery/turretid/proc/shoot_silicons(mob/user) + shoot_cyborgs = !shoot_cyborgs + add_hiddenprint(user) + log_combat(user, src, "[shoot_cyborgs ? "Shooting Borgs" : "Not Shooting Borgs"]") updateTurrets() /obj/machinery/turretid/proc/updateTurrets() for (var/obj/machinery/porta_turret/aTurret in turrets) - aTurret.setState(enabled, lethal) - update_icon() - -/obj/machinery/turretid/power_change() - ..() + aTurret.setState(enabled, lethal, shoot_cyborgs) update_icon() /obj/machinery/turretid/update_icon_state() @@ -1045,11 +1070,7 @@ /obj/machinery/porta_turret/lasertag req_access = list(ACCESS_MAINT_TUNNELS, ACCESS_THEATRE) - check_records = 0 - criminals = 0 - auth_weapons = 1 - stun_all = 0 - check_anomalies = 0 + turret_flags = TURRET_FLAG_AUTH_WEAPONS var/team_color /obj/machinery/porta_turret/lasertag/assess_perp(mob/living/carbon/human/perp) @@ -1077,20 +1098,14 @@ if(properties["team_color"]) team_color = properties["team_color"] -/obj/machinery/porta_turret/lasertag/ui_interact(mob/user) - . = ..() +/obj/machinery/porta_turret/lasertag/ui_status(mob/user) if(ishuman(user)) var/mob/living/carbon/human/H = user if(team_color == "blue" && istype(H.wear_suit, /obj/item/clothing/suit/redtag)) - return + return UI_CLOSE if(team_color == "red" && istype(H.wear_suit, /obj/item/clothing/suit/bluetag)) - return - - var/dat = "Status: [on ? "On" : "Off"]" - - var/datum/browser/popup = new(user, "autosec", "Automatic Portable Turret Installation", 300, 300) - popup.set_content(dat) - popup.open() + return UI_CLOSE + return ..() //lasertag presets /obj/machinery/porta_turret/lasertag/red @@ -1101,16 +1116,14 @@ installation = /obj/item/gun/energy/laser/bluetag team_color = "blue" -/obj/machinery/porta_turret/lasertag/bullet_act(obj/item/projectile/P) +/obj/machinery/porta_turret/lasertag/bullet_act(obj/projectile/P) . = ..() if(on) if(team_color == "blue") if(istype(P, /obj/item/projectile/beam/lasertag/redtag)) - on = FALSE - spawn(100) - on = TRUE + toggle_on(FALSE) + addtimer(CALLBACK(src, .proc/toggle_on, TRUE), 10 SECONDS) else if(team_color == "red") if(istype(P, /obj/item/projectile/beam/lasertag/bluetag)) - on = FALSE - spawn(100) - on = TRUE + toggle_on(FALSE) + addtimer(CALLBACK(src, .proc/toggle_on, TRUE), 10 SECONDS) diff --git a/code/game/mecha/mech_bay.dm b/code/game/mecha/mech_bay.dm index dcd8a12b38..e9f682e929 100644 --- a/code/game/mecha/mech_bay.dm +++ b/code/game/mecha/mech_bay.dm @@ -81,10 +81,10 @@ var/obj/machinery/mech_bay_recharge_port/recharge_port light_color = LIGHT_COLOR_PINK -/obj/machinery/computer/mech_bay_power_console/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/computer/mech_bay_power_console/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "MechBayPowerConsole", "Mech Bay Power Control Console", 400, 200, master_ui, state) + ui = new(user, src, "MechBayPowerConsole", name) ui.open() /obj/machinery/computer/mech_bay_power_console/ui_act(action, params) @@ -104,7 +104,6 @@ data["recharge_port"]["mech"] = list("health" = recharge_port.recharging_mech.obj_integrity, "maxhealth" = recharge_port.recharging_mech.max_integrity, "cell" = null, "name" = recharge_port.recharging_mech.name,) if(recharge_port.recharging_mech.cell && !QDELETED(recharge_port.recharging_mech.cell)) data["recharge_port"]["mech"]["cell"] = list( - "critfail" = recharge_port.recharging_mech.cell.crit_fail, "charge" = recharge_port.recharging_mech.cell.charge, "maxcharge" = recharge_port.recharging_mech.cell.maxcharge ) diff --git a/code/game/mecha/mech_fabricator.dm b/code/game/mecha/mech_fabricator.dm index ca481f0d80..714878cf56 100644 --- a/code/game/mecha/mech_fabricator.dm +++ b/code/game/mecha/mech_fabricator.dm @@ -9,17 +9,41 @@ active_power_usage = 5000 req_access = list(ACCESS_ROBOTICS) circuit = /obj/item/circuitboard/machine/mechfab - var/time_coeff = 1 - var/component_coeff = 1 - var/datum/techweb/specialized/autounlocking/exofab/stored_research - var/sync = 0 - var/part_set - var/datum/design/being_built + processing_flags = START_PROCESSING_MANUALLY + + subsystem_type = /datum/controller/subsystem/processing/fastprocess + + /// Current items in the build queue. var/list/queue = list() - var/processing_queue = 0 - var/screen = "main" - var/temp - var/offstation_security_levels = TRUE + /// Whether or not the machine is building the entire queue automagically. + var/process_queue = FALSE + + /// The current design datum that the machine is building. + var/datum/design/being_built + /// World time when the build will finish. + var/build_finish = 0 + /// World time when the build started. + var/build_start = 0 + /// Reference to all materials used in the creation of the item being_built. + var/list/build_materials + /// Part currently stored in the Exofab. + var/obj/item/stored_part + + /// Coefficient for the speed of item building. Based on the installed parts. + var/time_coeff = 1 + /// Coefficient for the efficiency of material usage in item building. Based on the installed parts. + var/component_coeff = 1 + + /// Copy of the currently synced techweb. + var/datum/techweb/specialized/autounlocking/exofab/stored_research + + /// Whether the Exofab links to the ore silo on init. Special derelict or maintanance variants should set this to FALSE. + var/link_on_init = TRUE + + /// Reference to a remote material inventory, such as an ore silo. + var/datum/component/remote_materials/rmat + + /// A list of categories that valid MECHFAB design datums will broadly categorise themselves under. var/list/part_sets = list( "Cyborg", "Ripley", @@ -33,25 +57,17 @@ "Exosuit Equipment", "Exosuit Ammunition", "Cyborg Upgrade Modules", + "Cybernetics", + "Implants", + "Control Interfaces", "Misc" ) -/obj/machinery/mecha_part_fabricator/Initialize() - var/static/list/allowed_types = list( - /datum/material/iron, - /datum/material/glass, - /datum/material/silver, - /datum/material/gold, - /datum/material/diamond, - /datum/material/plasma, - /datum/material/uranium, - /datum/material/bananium, - /datum/material/titanium, - /datum/material/bluespace - ) - var/datum/component/material_container/materials = AddComponent(/datum/component/material_container, allowed_types, 0, TRUE, /obj/item/stack, CALLBACK(src, .proc/is_insertion_ready), CALLBACK(src, .proc/AfterMaterialInsert)) - materials.precise_insertion = TRUE +/obj/machinery/mecha_part_fabricator/Initialize(mapload) stored_research = new + rmat = AddComponent(/datum/component/remote_materials, "mechfab", mapload && link_on_init) + + RefreshParts() //Recalculating local material sizes if the fab isn't linked return ..() /obj/machinery/mecha_part_fabricator/RefreshParts() @@ -60,8 +76,7 @@ //maximum stocking amount (default 300000, 600000 at T4) for(var/obj/item/stock_parts/matter_bin/M in component_parts) T += M.rating - var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) - materials.max_amount = (200000 + (T*50000)) + rmat.set_local_size((200000 + (T*50000))) //resources adjustment coefficient (1 -> 0.85 -> 0.7 -> 0.55) T = 1.15 @@ -74,89 +89,153 @@ for(var/obj/item/stock_parts/manipulator/Ml in component_parts) T += Ml.rating time_coeff = round(initial(time_coeff) - (initial(time_coeff)*(T))/5,0.01) - var/obj/item/circuitboard/machine/mechfab/C = circuit - offstation_security_levels = C.offstation_security_levels + + // Adjust the build time of any item currently being built. + if(being_built) + var/last_const_time = build_finish - build_start + var/new_const_time = get_construction_time_w_coeff(initial(being_built.construction_time)) + var/const_time_left = build_finish - world.time + var/new_build_time = (new_const_time / last_const_time) * const_time_left + build_finish = world.time + new_build_time + + update_static_data(usr) /obj/machinery/mecha_part_fabricator/examine(mob/user) . = ..() - var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) if(in_range(user, src) || isobserver(user)) - . += "The status display reads: Storing up to [materials.max_amount] material units.
Material consumption at [component_coeff*100]%.
Build time reduced by [100-time_coeff*100]%.
" + . += "The status display reads: Storing up to [rmat.local_size] material units.
Material consumption at [component_coeff*100]%.
Build time reduced by [100-time_coeff*100]%.
" -/obj/machinery/mecha_part_fabricator/emag_act() - . = ..() - if(obj_flags & EMAGGED) - return - obj_flags |= EMAGGED - req_access = list() - INVOKE_ASYNC(src, .proc/error_action_sucessful) - return TRUE - -/obj/machinery/mecha_part_fabricator/proc/error_action_sucessful() - say("DB error \[Code 0x00F1\]") - sleep(10) - say("Attempting auto-repair...") - sleep(15) - say("User DB corrupted \[Code 0x00FA\]. Truncating data structure...") - sleep(30) - say("User DB truncated. Please contact your Nanotrasen system operator for future assistance.") - - -/obj/machinery/mecha_part_fabricator/proc/output_parts_list(set_name) - var/output = "" - for(var/v in stored_research.researched_designs) - var/datum/design/D = SSresearch.techweb_design_by_id(v) - if(D.build_type & MECHFAB) - if(!(set_name in D.category)) - continue - output += "
[output_part_info(D)]
\[" - if(check_clearance(D) && check_resources(D)) - output += "Build | " - output += "Add to queue\]\[?\]
" - return output - -/obj/machinery/mecha_part_fabricator/proc/check_clearance(datum/design/D) - if(!(obj_flags & EMAGGED) && (offstation_security_levels || is_station_level(z)) && !ISINRANGE(GLOB.security_level, D.min_security_level, D.max_security_level)) - return FALSE - return TRUE - -/obj/machinery/mecha_part_fabricator/proc/output_part_info(datum/design/D) - var/clearance = !(obj_flags & EMAGGED) && (offstation_security_levels || is_station_level(z)) - var/sec_text = "" - if(clearance && (D.min_security_level > SEC_LEVEL_GREEN || D.max_security_level < SEC_LEVEL_DELTA)) - sec_text = " (Allowed security levels: " - for(var/n in D.min_security_level to D.max_security_level) - sec_text += NUM2SECLEVEL(n) - if(n + 1 <= D.max_security_level) - sec_text += ", " - sec_text += ") " - var/output = "[initial(D.name)] (Cost: [output_part_cost(D)]) [sec_text][get_construction_time_w_coeff(D)/10]sec" - return output - -/obj/machinery/mecha_part_fabricator/proc/output_part_cost(datum/design/D) - var/i = 0 - var/output +/** + * Generates an info list for a given part. + * + * Returns a list of part information. + * * D - Design datum to get information on. + * * categories - Boolean, whether or not to parse snowflake categories into the part information list. + */ +/obj/machinery/mecha_part_fabricator/proc/output_part_info(datum/design/D, categories = FALSE) + var/cost = list() for(var/c in D.materials) var/datum/material/M = c - output += "[i?" | ":null][get_resource_cost_w_coeff(D, M)] [M.name]" - i++ - return output + cost[M.name] = get_resource_cost_w_coeff(D, M) + var/obj/built_item = D.build_path + + var/list/category_override = null + var/list/sub_category = null + + if(categories) + // Handle some special cases to build up sub-categories for the fab interface. + // Start with checking if this design builds a cyborg module. + if(built_item in typesof(/obj/item/borg/upgrade)) + var/obj/item/borg/upgrade/U = built_item + var/module_types = initial(U.module_flags) + sub_category = list() + if(module_types) + if(module_types & BORG_MODULE_SECURITY) + sub_category += "Security" + if(module_types & BORG_MODULE_MINER) + sub_category += "Mining" + if(module_types & BORG_MODULE_JANITOR) + sub_category += "Janitor" + if(module_types & BORG_MODULE_MEDICAL) + sub_category += "Medical" + if(module_types & BORG_MODULE_ENGINEERING) + sub_category += "Engineering" + else + sub_category += "All Cyborgs" + // Else check if this design builds a piece of exosuit equipment. + else if(built_item in typesof(/obj/item/mecha_parts/mecha_equipment)) + var/obj/item/mecha_parts/mecha_equipment/E = built_item + var/mech_types = initial(E.mech_flags) + sub_category = "Equipment" + if(mech_types) + category_override = list() + if(mech_types & EXOSUIT_MODULE_RIPLEY) + category_override += "Ripley" + if(mech_types & EXOSUIT_MODULE_ODYSSEUS) + category_override += "Odysseus" + // if(mech_types & EXOSUIT_MODULE_CLARKE) + // category_override += "Clarke" + if(mech_types & EXOSUIT_MODULE_GYGAX) + category_override += "Gygax" + if(mech_types & EXOSUIT_MODULE_DURAND) + category_override += "Durand" + if(mech_types & EXOSUIT_MODULE_HONK) + category_override += "H.O.N.K" + if(mech_types & EXOSUIT_MODULE_PHAZON) + category_override += "Phazon" + + + var/list/part = list( + "name" = D.name, + "desc" = initial(built_item.desc), + "printTime" = get_construction_time_w_coeff(initial(D.construction_time))/10, + "cost" = cost, + "id" = D.id, + "subCategory" = sub_category, + "categoryOverride" = category_override, + "searchMeta" = D.search_metadata + ) + + return part + +/** + * Generates a list of resources / materials available to this Exosuit Fab + * + * Returns null if there is no material container available. + * List format is list(material_name = list(amount = ..., ref = ..., etc.)) + */ /obj/machinery/mecha_part_fabricator/proc/output_available_resources() - var/output - var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) - for(var/mat_id in materials.materials) - var/datum/material/M = mat_id - var/amount = materials.materials[mat_id] - output += "[M.name]: [amount] cm³" - if(amount >= MINERAL_MATERIAL_AMOUNT) - output += "- Remove \[1\]" - if(amount >= (MINERAL_MATERIAL_AMOUNT * 10)) - output += " | \[10\]" - output += " | \[All\]" - output += "
" - return output + var/datum/component/material_container/materials = rmat.mat_container + var/list/material_data = list() + + if(materials) + for(var/mat_id in materials.materials) + var/datum/material/M = mat_id + var/list/material_info = list() + var/amount = materials.materials[mat_id] + + material_info = list( + "name" = M.name, + "ref" = REF(M), + "amount" = amount, + "sheets" = round(amount / MINERAL_MATERIAL_AMOUNT), + "removable" = amount >= MINERAL_MATERIAL_AMOUNT + ) + + material_data += list(material_info) + + return material_data + + return null + +/** + * Intended to be called when an item starts printing. + * + * Adds the overlay to show the fab working and sets active power usage settings. + */ +/obj/machinery/mecha_part_fabricator/proc/on_start_printing() + add_overlay("fab-active") + use_power = ACTIVE_POWER_USE + +/** + * Intended to be called when the exofab has stopped working and is no longer printing items. + * + * Removes the overlay to show the fab working and sets idle power usage settings. Additionally resets the description and turns off queue processing. + */ +/obj/machinery/mecha_part_fabricator/proc/on_finish_printing() + cut_overlay("fab-active") + use_power = IDLE_POWER_USE + desc = initial(desc) + process_queue = FALSE + +/** + * Calculates resource/material costs for printing an item based on the machine's resource coefficient. + * + * Returns a list of k,v resources with their amounts. + * * D - Design datum to calculate the modified resource cost of. + */ /obj/machinery/mecha_part_fabricator/proc/get_resources_w_coeff(datum/design/D) var/list/resources = list() for(var/R in D.materials) @@ -164,294 +243,416 @@ resources[M] = get_resource_cost_w_coeff(D, M) return resources +/** + * Checks if the Exofab has enough resources to print a given item. + * + * Returns FALSE if the design has no reagents used in its construction (?) or if there are insufficient resources. + * Returns TRUE if there are sufficient resources to print the item. + * * D - Design datum to calculate the modified resource cost of. + */ /obj/machinery/mecha_part_fabricator/proc/check_resources(datum/design/D) - if(D.reagents_list.len) // No reagents storage - no reagent designs. + if(length(D.reagents_list)) // No reagents storage - no reagent designs. return FALSE - var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) + var/datum/component/material_container/materials = rmat.mat_container if(materials.has_materials(get_resources_w_coeff(D))) return TRUE return FALSE -/obj/machinery/mecha_part_fabricator/proc/build_part(datum/design/D) +/** + * Attempts to build the next item in the build queue. + * + * Returns FALSE if either there are no more parts to build or the next part is not buildable. + * Returns TRUE if the next part has started building. + * * verbose - Whether the machine should use say() procs. Set to FALSE to disable the machine saying reasons for failure to build. + */ +/obj/machinery/mecha_part_fabricator/proc/build_next_in_queue(verbose = TRUE) + if(!length(queue)) + return FALSE + + var/datum/design/D = queue[1] + if(build_part(D, verbose)) + remove_from_queue(1) + return TRUE + + return FALSE + +/** + * Starts the build process for a given design datum. + * + * Returns FALSE if the procedure fails. Returns TRUE when being_built is set. + * Uses materials. + * * D - Design datum to attempt to print. + * * verbose - Whether the machine should use say() procs. Set to FALSE to disable the machine saying reasons for failure to build. + */ +/obj/machinery/mecha_part_fabricator/proc/build_part(datum/design/D, verbose = TRUE) + if(!D) + return FALSE + + var/datum/component/material_container/materials = rmat.mat_container + if (!materials) + if(verbose) + say("No access to material storage, please contact the quartermaster.") + return FALSE + if (rmat.on_hold()) + if(verbose) + say("Mineral access is on hold, please contact the quartermaster.") + return FALSE + if(!check_resources(D)) + if(verbose) + say("Not enough resources. Processing stopped.") + return FALSE + + build_materials = get_resources_w_coeff(D) + + materials.use_materials(build_materials) being_built = D - desc = "It's building \a [initial(D.name)]." - var/list/res_coef = get_resources_w_coeff(D) + build_finish = world.time + get_construction_time_w_coeff(initial(D.construction_time)) + build_start = world.time + desc = "It's building \a [D.name]." - var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) - materials.use_materials(res_coef) - add_overlay("fab-active") - use_power = ACTIVE_POWER_USE - updateUsrDialog() - sleep(get_construction_time_w_coeff(D)) - use_power = IDLE_POWER_USE - cut_overlay("fab-active") - desc = initial(desc) + rmat.silo_log(src, "built", -1, "[D.name]", build_materials) - var/location = get_step(src,(dir)) - var/obj/item/I = new D.build_path(location) - I.set_custom_materials(res_coef) - say("\The [I] is complete.") - being_built = null - - updateUsrDialog() return TRUE -/obj/machinery/mecha_part_fabricator/proc/update_queue_on_page() - send_byjax(usr,"mecha_fabricator.browser","queue",list_queue()) - return +/obj/machinery/mecha_part_fabricator/process() + // If there's a stored part to dispense due to an obstruction, try to dispense it. + if(stored_part) + var/turf/exit = get_step(src,(dir)) + if(exit.density) + return TRUE -/obj/machinery/mecha_part_fabricator/proc/add_part_set_to_queue(set_name) - if(set_name in part_sets) - for(var/v in stored_research.researched_designs) - var/datum/design/D = SSresearch.techweb_design_by_id(v) - if(D.build_type & MECHFAB) - if(set_name in D.category) - add_to_queue(D) + say("Obstruction cleared. \The [stored_part] is complete.") + stored_part.forceMove(exit) + stored_part = null -/obj/machinery/mecha_part_fabricator/proc/add_to_queue(D) + // If there's nothing being built, try to build something + if(!being_built) + // If we're not processing the queue anymore or there's nothing to build, end processing. + if(!process_queue || !build_next_in_queue()) + on_finish_printing() + end_processing() + return TRUE + on_start_printing() + + // If there's an item being built, check if it is complete. + if(being_built && (build_finish < world.time)) + // Then attempt to dispense it and if appropriate build the next item. + dispense_built_part(being_built) + if(process_queue) + build_next_in_queue(FALSE) + return TRUE + +/** + * Dispenses a part to the tile infront of the Exosuit Fab. + * + * Returns FALSE is the machine cannot dispense the part on the appropriate turf. + * Return TRUE if the part was successfully dispensed. + * * D - Design datum to attempt to dispense. + */ +/obj/machinery/mecha_part_fabricator/proc/dispense_built_part(datum/design/D) + var/obj/item/I = new D.build_path(src) + I.material_flags |= MATERIAL_NO_EFFECTS //Find a better way to do this. + I.set_custom_materials(build_materials) + + being_built = null + + var/turf/exit = get_step(src,(dir)) + if(exit.density) + say("Error! Part outlet is obstructed.") + desc = "It's trying to dispense \a [D.name], but the part outlet is obstructed." + stored_part = I + return FALSE + + say("\The [I] is complete.") + I.forceMove(exit) + return TRUE + +/** + * Adds a list of datum designs to the build queue. + * + * Will only add designs that are in this machine's stored techweb. + * Does final checks for datum IDs and makes sure this machine can build the designs. + * * part_list - List of datum design ids for designs to add to the queue. + */ +/obj/machinery/mecha_part_fabricator/proc/add_part_set_to_queue(list/part_list) + for(var/v in stored_research.researched_designs) + var/datum/design/D = SSresearch.techweb_design_by_id(v) + if((D.build_type & MECHFAB) && (D.id in part_list)) + add_to_queue(D) + +/** + * Adds a datum design to the build queue. + * + * Returns TRUE if successful and FALSE if the design was not added to the queue. + * * D - Datum design to add to the queue. + */ +/obj/machinery/mecha_part_fabricator/proc/add_to_queue(datum/design/D) if(!istype(queue)) queue = list() if(D) queue[++queue.len] = D - return queue.len + return TRUE + return FALSE +/** + * Removes datum design from the build queue based on index. + * + * Returns TRUE if successful and FALSE if a design was not removed from the queue. + * * index - Index in the build queue of the element to remove. + */ /obj/machinery/mecha_part_fabricator/proc/remove_from_queue(index) - if(!isnum(index) || !ISINTEGER(index) || !istype(queue) || (index<1 || index>queue.len)) + if(!isnum(index) || !ISINTEGER(index) || !istype(queue) || (index<1 || index>length(queue))) return FALSE queue.Cut(index,++index) return TRUE -/obj/machinery/mecha_part_fabricator/proc/process_queue() - var/datum/design/D = queue[1] - if(!D) - remove_from_queue(1) - if(queue.len) - return process_queue() - else - return - temp = null - while(D) - if(stat&(NOPOWER|BROKEN)) - return FALSE - if(!check_clearance(D)) - say("Security level not met. Queue processing stopped.") - temp = {"Security level not met to build next part.
- Try again | Return"} - return FALSE - if(!check_resources(D)) - say("Not enough resources. Queue processing stopped.") - temp = {"Not enough resources to build next part.
-
Try again | Return"} - return FALSE - remove_from_queue(1) - build_part(D) - D = listgetindex(queue, 1) - say("Queue processing finished successfully.") - +/** + * Generates a list of parts formatted for tgui based on the current build queue. + * + * Returns a formatted list of lists containing formatted part information for every part in the build queue. + */ /obj/machinery/mecha_part_fabricator/proc/list_queue() - var/output = "Queue contains:" - if(!istype(queue) || !queue.len) - output += "
Nothing" - else - output += "
    " - var/i = 0 - for(var/datum/design/D in queue) - i++ - var/obj/part = D.build_path - output += "" - output += initial(part.name) + " - " - output += "[i>1?"":null] " - output += "[i↓":null] " - output += "Remove" + if(!istype(queue) || !length(queue)) + return null - output += "
" - output += "\[Process queue | Clear queue\]" - return output + var/list/queued_parts = list() + for(var/datum/design/D in queue) + var/list/part = output_part_info(D) + queued_parts += list(part) + return queued_parts +/** + * Syncs machine with R&D servers. + * + * Requires an R&D Console visible within 7 tiles. Copies techweb research. Updates tgui's state data. + */ /obj/machinery/mecha_part_fabricator/proc/sync() - temp = "Updating local R&D database..." - updateUsrDialog() - sleep(30) //only sleep if called by user - - for(var/obj/machinery/computer/rdconsole/RDC in oview(7,src)) + for(var/obj/machinery/computer/rdconsole/RDC in orange(7,src)) RDC.stored_research.copy_research_to(stored_research) - temp = "Processed equipment designs.
" - //check if the tech coefficients have changed - temp += "Return" - - updateUsrDialog() + update_static_data(usr) say("Successfully synchronized with R&D server.") return - temp = "Unable to connect to local R&D Database.
Please check your connections and try again.
Return" - updateUsrDialog() + say("Unable to connect to local R&D server.") return +/** + * Calculates the coefficient-modified resource cost of a single material component of a design's recipe. + * + * Returns coefficient-modified resource cost for the given material component. + * * D - Design datum to pull the resource cost from. + * * resource - Material datum reference to the resource to calculate the cost of. + * * roundto - Rounding value for round() proc + */ /obj/machinery/mecha_part_fabricator/proc/get_resource_cost_w_coeff(datum/design/D, var/datum/material/resource, roundto = 1) return round(D.materials[resource]*component_coeff, roundto) -/obj/machinery/mecha_part_fabricator/proc/get_construction_time_w_coeff(datum/design/D, roundto = 1) //aran - return round(initial(D.construction_time)*time_coeff, roundto) +/** + * Calculates the coefficient-modified build time of a design. + * + * Returns coefficient-modified build time of a given design. + * * D - Design datum to calculate the modified build time of. + * * roundto - Rounding value for round() proc + */ +/obj/machinery/mecha_part_fabricator/proc/get_construction_time_w_coeff(construction_time, roundto = 1) //aran + return round(construction_time*time_coeff, roundto) -/obj/machinery/mecha_part_fabricator/ui_interact(mob/user as mob) - . = ..() - var/dat, left_part - user.set_machine(src) - var/turf/exit = get_step(src,(dir)) - if(exit.density) - say("Error! Part outlet is obstructed.") - return - if(temp) - left_part = temp - else if(being_built) - var/obj/I = being_built.build_path - left_part = {"Building [initial(I.name)].
- Please wait until completion...
"} +/obj/machinery/mecha_part_fabricator/ui_assets(mob/user) + return list( + get_asset_datum(/datum/asset/spritesheet/sheetmaterials) + ) + +/obj/machinery/mecha_part_fabricator/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "ExosuitFabricator") + ui.open() + +/obj/machinery/mecha_part_fabricator/ui_static_data(mob/user) + var/list/data = list() + + var/list/final_sets = list() + var/list/buildable_parts = list() + + for(var/part_set in part_sets) + final_sets += part_set + + for(var/v in stored_research.researched_designs) + var/datum/design/D = SSresearch.techweb_design_by_id(v) + if(D.build_type & MECHFAB) + // This is for us. + var/list/part = output_part_info(D, TRUE) + + if(part["category_override"]) + for(var/cat in part["category_override"]) + buildable_parts[cat] += list(part) + if(!(cat in part_sets)) + final_sets += cat + continue + + for(var/cat in part_sets) + // Find all matching categories. + if(!(cat in D.category)) + continue + + buildable_parts[cat] += list(part) + + data["partSets"] = final_sets + data["buildableParts"] = buildable_parts + + return data + +/obj/machinery/mecha_part_fabricator/ui_data(mob/user) + var/list/data = list() + + data["materials"] = output_available_resources() + + if(being_built) + var/list/part = list( + "name" = being_built.name, + "duration" = build_finish - world.time, + "printTime" = get_construction_time_w_coeff(initial(being_built.construction_time)) + ) + data["buildingPart"] = part else - switch(screen) - if("main") - left_part = output_available_resources()+"
" - left_part += "Sync with R&D servers
" - for(var/part_set in part_sets) - left_part += "[part_set] - \[Add all parts to queue\]
" - if("parts") - left_part += output_parts_list(part_set) - left_part += "
Return" - dat = {" - - - [name] data - - - - - - - - - -
- [left_part] - - [list_queue()] -
- - "} - user << browse(dat, "window=mecha_fabricator;size=1000x430") - onclose(user, "mecha_fabricator") - return + data["buildingPart"] = null -/obj/machinery/mecha_part_fabricator/Topic(href, href_list) + data["queue"] = list_queue() + + if(stored_part) + data["storedPart"] = stored_part.name + else + data["storedPart"] = null + + data["isProcessingQueue"] = process_queue + + return data + +/obj/machinery/mecha_part_fabricator/ui_act(action, var/list/params) if(..()) - return - if(href_list["part_set"]) - var/tpart_set = href_list["part_set"] - if(tpart_set) - if(tpart_set=="clear") - part_set = null - else - part_set = tpart_set - screen = "parts" - if(href_list["part"]) - var/T = href_list["part"] - for(var/v in stored_research.researched_designs) - var/datum/design/D = SSresearch.techweb_design_by_id(v) - if(D.build_type & MECHFAB) - if(D.id == T) - if(!processing_queue) - build_part(D) - else - add_to_queue(D) - break - if(href_list["add_to_queue"]) - var/T = href_list["add_to_queue"] - for(var/v in stored_research.researched_designs) - var/datum/design/D = SSresearch.techweb_design_by_id(v) - if(D.build_type & MECHFAB) - if(D.id == T) + return TRUE + + . = TRUE + + add_fingerprint(usr) + usr.set_machine(src) + + switch(action) + if("sync_rnd") + // Sync with R&D Servers + sync() + return + if("add_queue_set") + // Add all parts of a set to queue + var/part_list = params["part_list"] + add_part_set_to_queue(part_list) + return + if("add_queue_part") + // Add a specific part to queue + var/T = params["id"] + for(var/v in stored_research.researched_designs) + var/datum/design/D = SSresearch.techweb_design_by_id(v) + if((D.build_type & MECHFAB) && (D.id == T)) add_to_queue(D) break - return update_queue_on_page() - if(href_list["remove_from_queue"]) - remove_from_queue(text2num(href_list["remove_from_queue"])) - return update_queue_on_page() - if(href_list["partset_to_queue"]) - add_part_set_to_queue(href_list["partset_to_queue"]) - return update_queue_on_page() - if(href_list["process_queue"]) - spawn(0) - if(processing_queue || being_built) - return FALSE - processing_queue = 1 - process_queue() - processing_queue = 0 - if(href_list["clear_temp"]) - temp = null - if(href_list["screen"]) - screen = href_list["screen"] - if(href_list["queue_move"] && href_list["index"]) - var/index = text2num(href_list["index"]) - var/new_index = index + text2num(href_list["queue_move"]) - if(isnum(index) && isnum(new_index) && ISINTEGER(index) && ISINTEGER(new_index)) - if(ISINRANGE(new_index,1,queue.len)) - queue.Swap(index,new_index) - return update_queue_on_page() - if(href_list["clear_queue"]) - queue = list() - return update_queue_on_page() - if(href_list["sync"]) - sync() - if(href_list["part_desc"]) - var/T = href_list["part_desc"] - for(var/v in stored_research.researched_designs) - var/datum/design/D = SSresearch.techweb_design_by_id(v) - if(D.build_type & MECHFAB) - if(D.id == T) - var/obj/part = D.build_path - temp = {"

[initial(part.name)] description:

- [initial(part.desc)]
- Return - "} - break + return + if("del_queue_part") + // Delete a specific from from the queue + var/index = text2num(params["index"]) + remove_from_queue(index) + return + if("clear_queue") + // Delete everything from queue + queue.Cut() + return + if("build_queue") + // Build everything in queue + if(process_queue) + return + process_queue = TRUE - if(href_list["remove_mat"] && href_list["material"]) - var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) - var/datum/material/Mat = locate(href_list["material"]) - materials.retrieve_sheets(text2num(href_list["remove_mat"]), Mat) + if(!being_built) + begin_processing() + return + if("stop_queue") + // Pause queue building. Also known as stop. + process_queue = FALSE + return + if("build_part") + // Build a single part + if(being_built || process_queue) + return - updateUsrDialog() - return + var/id = params["id"] + var/datum/design/D = SSresearch.techweb_design_by_id(id) -/obj/machinery/mecha_part_fabricator/on_deconstruction() - var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) - materials.retrieve_all() - ..() + if(!(D.build_type & MECHFAB) || !(D.id == id)) + return + + if(build_part(D)) + on_start_printing() + begin_processing() + + return + if("move_queue_part") + // Moves a part up or down in the queue. + var/index = text2num(params["index"]) + var/new_index = index + text2num(params["newindex"]) + if(isnum(index) && isnum(new_index) && ISINTEGER(index) && ISINTEGER(new_index)) + if(ISINRANGE(new_index,1,length(queue))) + queue.Swap(index,new_index) + return + if("remove_mat") + // Remove a material from the fab + var/mat_ref = params["ref"] + var/amount = text2num(params["amount"]) + var/datum/material/mat = locate(mat_ref) + eject_sheets(mat, amount) + return + + return FALSE + +/** + * Eject material sheets. + * + * Returns the number of sheets successfully ejected. + * eject_sheet - Byond REF of the material to eject. + * eject_amt - Number of sheets to attempt to eject. + */ +/obj/machinery/mecha_part_fabricator/proc/eject_sheets(eject_sheet, eject_amt) + var/datum/component/material_container/mat_container = rmat.mat_container + if (!mat_container) + say("No access to material storage, please contact the quartermaster.") + return 0 + if (rmat.on_hold()) + say("Mineral access is on hold, please contact the quartermaster.") + return 0 + var/count = mat_container.retrieve_sheets(text2num(eject_amt), eject_sheet, drop_location()) + var/list/matlist = list() + matlist[eject_sheet] = text2num(eject_amt) + rmat.silo_log(src, "ejected", -count, "sheets", matlist) + return count /obj/machinery/mecha_part_fabricator/proc/AfterMaterialInsert(item_inserted, id_inserted, amount_inserted) var/datum/material/M = id_inserted add_overlay("fab-load-[M.name]") addtimer(CALLBACK(src, /atom/proc/cut_overlay, "fab-load-[M.name]"), 10) - updateUsrDialog() -/obj/machinery/mecha_part_fabricator/attackby(obj/item/W, mob/user, params) - if(default_deconstruction_screwdriver(user, "fab-o", "fab-idle", W)) +/obj/machinery/mecha_part_fabricator/screwdriver_act(mob/living/user, obj/item/I) + if(..()) return TRUE + if(being_built) + to_chat(user, "\The [src] is currently processing! Please wait until completion.") + return FALSE + return default_deconstruction_screwdriver(user, "fab-o", "fab-idle", I) - if(default_deconstruction_crowbar(W)) +/obj/machinery/mecha_part_fabricator/crowbar_act(mob/living/user, obj/item/I) + if(..()) return TRUE - - return ..() + if(being_built) + to_chat(user, "\The [src] is currently processing! Please wait until completion.") + return FALSE + return default_deconstruction_crowbar(I) /obj/machinery/mecha_part_fabricator/proc/is_insertion_ready(mob/user) if(panel_open) @@ -463,6 +664,9 @@ return TRUE +/obj/machinery/mecha_part_fabricator/maint + link_on_init = FALSE + /obj/machinery/mecha_part_fabricator/offstation - offstation_security_levels = FALSE + link_on_init = FALSE circuit = /obj/item/circuitboard/machine/mechfab/offstation diff --git a/code/game/mecha/mecha_control_console.dm b/code/game/mecha/mecha_control_console.dm index c7db051331..50d18c6fda 100644 --- a/code/game/mecha/mecha_control_console.dm +++ b/code/game/mecha/mecha_control_console.dm @@ -5,14 +5,11 @@ icon_keyboard = "tech_key" req_access = list(ACCESS_ROBOTICS) circuit = /obj/item/circuitboard/computer/mecha_control - ui_x = 500 - ui_y = 500 -/obj/machinery/computer/mecha/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/computer/mecha/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "ExosuitControlConsole", name, ui_x, ui_y, master_ui, state) + ui = new(user, src, "ExosuitControlConsole", name) ui.open() /obj/machinery/computer/mecha/ui_data(mob/user) diff --git a/code/game/objects/items/RPD.dm b/code/game/objects/items/RPD.dm index 93d73b2b5f..b3d5ed431a 100644 --- a/code/game/objects/items/RPD.dm +++ b/code/game/objects/items/RPD.dm @@ -238,24 +238,22 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list( playsound(get_turf(user), 'sound/items/deconstruct.ogg', 50, 1) return(BRUTELOSS) -/obj/item/pipe_dispenser/ui_base_html(html) - var/datum/asset/spritesheet/assets = get_asset_datum(/datum/asset/spritesheet/pipes) - . = replacetext(html, "", assets.css_tag()) +/obj/item/pipe_dispenser/ui_assets(mob/user) + return list( + get_asset_datum(/datum/asset/spritesheet/pipes), + ) -/obj/item/pipe_dispenser/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \ - datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/item/pipe_dispenser/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - var/datum/asset/assets = get_asset_datum(/datum/asset/spritesheet/pipes) - assets.send(user) - - ui = new(user, src, ui_key, "RapidPipeDispenser", name, 425, 515, master_ui, state) + ui = new(user, src, "RapidPipeDispenser", name) ui.open() /obj/item/pipe_dispenser/ui_data(mob/user) var/list/data = list( "category" = category, "piping_layer" = piping_layer, + // "ducting_layer" = ducting_layer, //uhh is this for chem thing? "preview_rows" = recipe.get_preview(p_dir), "categories" = list(), "selected_color" = paint_color, @@ -284,7 +282,7 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list( /obj/item/pipe_dispenser/ui_act(action, params) if(..()) return - if(!usr.canUseTopic(src)) + if(!usr.canUseTopic(src, BE_CLOSE)) return var/playeffect = TRUE switch(action) @@ -304,6 +302,9 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list( if("piping_layer") piping_layer = text2num(params["piping_layer"]) playeffect = FALSE + // if("ducting_layer") + // ducting_layer = text2num(params["ducting_layer"]) + // playeffect = FALSE if("pipe_type") var/static/list/recipes if(!recipes) @@ -320,11 +321,9 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list( mode &= ~n else mode |= n - - if(playeffect && world.time >= effectcooldown) + if(playeffect) spark_system.start() - effectcooldown = world.time + 100 - playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0) + playsound(get_turf(src), 'sound/effects/pop.ogg', 50, FALSE) return TRUE /obj/item/pipe_dispenser/pre_attack(atom/A, mob/user) diff --git a/code/game/objects/items/airlock_painter.dm b/code/game/objects/items/airlock_painter.dm index 4f3761f899..b28de437ed 100644 --- a/code/game/objects/items/airlock_painter.dm +++ b/code/game/objects/items/airlock_painter.dm @@ -180,10 +180,10 @@ stored_decal_total = "[stored_decal][yellow_fix][stored_color]" return -/obj/item/airlock_painter/decal/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/item/airlock_painter/decal/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "DecalPainter", name, 500, 400, master_ui, state) + ui = new(user, src, "DecalPainter", name) ui.open() /obj/item/airlock_painter/decal/ui_data(mob/user) diff --git a/code/game/objects/items/crayons.dm b/code/game/objects/items/crayons.dm index 620fbbf100..c5b08a2801 100644 --- a/code/game/objects/items/crayons.dm +++ b/code/game/objects/items/crayons.dm @@ -147,23 +147,23 @@ to_chat(user, "There is not enough of [src] left!") . = TRUE -/obj/item/toy/crayon/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.hands_state) - // tgui is a plague upon this codebase +/obj/item/toy/crayon/ui_state(mob/user) + return GLOB.hands_state - SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/item/toy/crayon/ui_interact(mob/user, datum/tgui/ui) + // tgui is a plague upon this codebase + // no u + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "Crayon", name, 600, 600, - master_ui, state) + ui = new(user, src, "Crayon", name) ui.open() /obj/item/toy/crayon/spraycan/AltClick(mob/user) - . = ..() if(user.canUseTopic(src, BE_CLOSE, ismonkey(user))) if(has_cap) is_capped = !is_capped to_chat(user, "The cap on [src] is now [is_capped ? "on" : "off"].") update_icon() - return TRUE /obj/item/toy/crayon/CtrlClick(mob/user) if(can_change_colour && !isturf(loc) && user.canUseTopic(src, BE_CLOSE, ismonkey(user))) diff --git a/code/game/objects/items/eightball.dm b/code/game/objects/items/eightball.dm index 837f57ceb5..0d5c9a22aa 100644 --- a/code/game/objects/items/eightball.dm +++ b/code/game/objects/items/eightball.dm @@ -192,11 +192,13 @@ return top_vote -/obj/item/toy/eightball/haunted/ui_interact(mob/user, ui_key="main", datum/tgui/ui=null, force_open=0, datum/tgui/master_ui=null, datum/ui_state/state = GLOB.always_state) +/obj/item/toy/eightball/haunted/ui_state(mob/user) + return GLOB.observer_state - ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/item/toy/eightball/haunted/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, src, ui_key, "EightBallVote", name, 400, 600, master_ui, state) + ui = new(user, src, "EightBallVote", name) ui.open() /obj/item/toy/eightball/haunted/ui_data(mob/user) @@ -229,4 +231,4 @@ else votes[selected_answer] += 1 voted[user.ckey] = selected_answer - . = TRUE \ No newline at end of file + . = TRUE