From 4d46b59668a3ff36784444f4addac7c61a306d27 Mon Sep 17 00:00:00 2001 From: Nerevar <12636964+Nerev4r@users.noreply.github.com> Date: Thu, 23 Nov 2023 10:13:20 -0700 Subject: [PATCH] [PORT] Gives Synths Internal Computers (& One Other Thing) (#25168) * initial d * wew * amazing * you got it boss * thanks * blackpilled once again * Apply suggestions from code review Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> * Update brain.dm * Apply suggestions from code review * Update modular_skyrat/modules/synths/code/bodyparts/internal_computer/internal_computer.dm * swag * yee * Apply suggestions from code review * Update modular_skyrat/modules/synths/code/bodyparts/internal_computer/internal_computer.dm * Update modular_skyrat/modules/synths/code/bodyparts/internal_computer/internal_computer.dm --------- Co-authored-by: Snakebittenn <12636964+Snakebittenn@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> --- .../code/bodyparts/internal_computer/brain.dm | 11 ++ .../internal_computer/internal_computer.dm | 117 ++++++++++++++++++ tgstation.dme | 2 + 3 files changed, 130 insertions(+) create mode 100644 modular_skyrat/modules/synths/code/bodyparts/internal_computer/brain.dm create mode 100644 modular_skyrat/modules/synths/code/bodyparts/internal_computer/internal_computer.dm diff --git a/modular_skyrat/modules/synths/code/bodyparts/internal_computer/brain.dm b/modular_skyrat/modules/synths/code/bodyparts/internal_computer/brain.dm new file mode 100644 index 00000000000..9b65b3f6772 --- /dev/null +++ b/modular_skyrat/modules/synths/code/bodyparts/internal_computer/brain.dm @@ -0,0 +1,11 @@ +/obj/item/organ/internal/brain/synth + var/obj/item/modular_computer/pda/synth/internal_computer + actions_types = list(/datum/action/item_action/synth/open_internal_computer) + +/obj/item/organ/internal/brain/synth/Initialize(mapload) + . = ..() + internal_computer = new(src) + +/obj/item/organ/internal/brain/synth/Destroy() + QDEL_NULL(internal_computer) + return ..() diff --git a/modular_skyrat/modules/synths/code/bodyparts/internal_computer/internal_computer.dm b/modular_skyrat/modules/synths/code/bodyparts/internal_computer/internal_computer.dm new file mode 100644 index 00000000000..89f24cdcede --- /dev/null +++ b/modular_skyrat/modules/synths/code/bodyparts/internal_computer/internal_computer.dm @@ -0,0 +1,117 @@ +/// Custom computer for synth brains +/obj/item/modular_computer/pda/synth + name = "virtual persocom" + + base_active_power_usage = 0 + base_idle_power_usage = 0 + + long_ranged = TRUE //Synths have good antennae + + max_idle_programs = 3 + + max_capacity = 32 + +/obj/item/modular_computer/pda/synth/Initialize(mapload) + . = ..() + + // prevent these from being created outside of synth brains + if(!istype(loc, /obj/item/organ/internal/brain/synth)) + return INITIALIZE_HINT_QDEL + +/datum/action/item_action/synth/open_internal_computer + name = "Open persocom emulation" + desc = "Accesses your built-in virtual machine." + check_flags = AB_CHECK_CONSCIOUS + +/datum/action/item_action/synth/open_internal_computer/Trigger(trigger_flags) + . = ..() + var/obj/item/organ/internal/brain/synth/targetmachine = target + targetmachine.internal_computer.interact(owner) + +/obj/item/modular_computer/pda/synth/ui_state(mob/user) + return GLOB.default_state + +/obj/item/modular_computer/pda/synth/ui_status(mob/user) + var/obj/item/organ/internal/brain/synth/brain_loc = loc + if(!istype(brain_loc)) + return UI_CLOSE + + if(!QDELETED(brain_loc.owner)) + if(brain_loc.owner == user) + return min( + ui_status_user_is_abled(user, src), + ui_status_only_living(user), + ) + else return UI_CLOSE + return ..() + +/obj/item/modular_computer/pda/synth/RemoveID(mob/user) + var/obj/item/organ/internal/brain/synth/brain_loc = loc + if(!istype(brain_loc)) + return ..() + + if(!computer_id_slot) + return ..() + + if(crew_manifest_update) + GLOB.manifest.modify(computer_id_slot.registered_name, computer_id_slot.assignment, computer_id_slot.get_trim_assignment()) + + if(user && !issilicon(user) && in_range(brain_loc.owner || brain_loc, user)) + user.put_in_hands(computer_id_slot) + else + computer_id_slot.forceMove(brain_loc.owner ? brain_loc.owner.drop_location() : brain_loc.drop_location()) //We actually update the physical on brain removal/insert + + computer_id_slot = null + playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE) + balloon_alert(user, "removed ID") + +/obj/item/modular_computer/pda/synth/get_ntnet_status() + . = NTNET_NO_SIGNAL + // NTNet is down and we are not connected via wired connection. The synth is no more + var/obj/item/organ/internal/brain/synth/brain_loc = loc + if(!istype(brain_loc)) + return + if(!find_functional_ntnet_relay() || isnull(brain_loc.owner)) + return + var/turf/current_turf = get_turf(brain_loc.owner || brain_loc) + if(is_station_level(current_turf.z)) + return NTNET_GOOD_SIGNAL + else if(long_ranged && !is_centcom_level(current_turf.z)) // Centcom is excluded because cafe + return NTNET_LOW_SIGNAL + +/* +So, I am not snowflaking more code.. except this +Attacking a synth with an id loads it into its slot.. pain and probably shitcode +*/ + +/obj/item/card/id/attack(mob/living/target_mob, mob/living/user, params) + var/mob/living/carbon/human/targetmachine = target_mob + if(!istype(targetmachine)) + return ..() + + var/obj/item/organ/internal/brain/synth/robotbrain = targetmachine.get_organ_slot(ORGAN_SLOT_BRAIN) + if(istype(robotbrain)) + if(user.zone_selected == BODY_ZONE_PRECISE_EYES) + balloon_alert(user, "Inserting ID into persocom slot...") + if(do_after(user, 5 SECONDS)) + balloon_alert(user, "ID slot interface registered!") + to_chat(targetmachine, span_notice("[user] inserts [src] into your persocom's card slot.")) + robotbrain.internal_computer.InsertID(src, user) + return + return ..() + +/obj/item/modular_computer/pda/attack(mob/living/target_mob, mob/living/user, params) + var/mob/living/carbon/human/targetmachine = target_mob + if(!istype(targetmachine)) + return ..() + + var/obj/item/organ/internal/brain/synth/robotbrain = targetmachine.get_organ_slot(ORGAN_SLOT_BRAIN) + if(istype(robotbrain)) + if(user.zone_selected == BODY_ZONE_PRECISE_EYES) + balloon_alert(user, "Establishing SSH login with persocom...") + if(do_after(user, 5 SECONDS)) + balloon_alert(user, "Connection established!") + to_chat(targetmachine, span_notice("[user] establishes an SSH connection between [src] and your persocom emulation.")) + robotbrain.internal_computer.interact(user) + return + return ..() diff --git a/tgstation.dme b/tgstation.dme index f12d1d4b3dc..80df5fdadd3 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7862,6 +7862,8 @@ #include "modular_skyrat\modules\synths\code\bodyparts\silicon_alt_brains.dm" #include "modular_skyrat\modules\synths\code\bodyparts\stomach.dm" #include "modular_skyrat\modules\synths\code\bodyparts\tongue.dm" +#include "modular_skyrat\modules\synths\code\bodyparts\internal_computer\brain.dm" +#include "modular_skyrat\modules\synths\code\bodyparts\internal_computer\internal_computer.dm" #include "modular_skyrat\modules\synths\code\reagents\blood_pack.dm" #include "modular_skyrat\modules\synths\code\reagents\pill.dm" #include "modular_skyrat\modules\synths\code\reagents\pill_bottles.dm"