From d7adda1f1519ed5d23ae5451bb1c1dbaa084b960 Mon Sep 17 00:00:00 2001 From: Iajret Creature <122297233+Steals-The-PRs@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:14:04 +0300 Subject: [PATCH] [MIRROR] Bitrunning prefloading (#5196) * Bitrunning prefloading (#4555) * ebin * Apply suggestions from code review Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> * Update modular_nova/modules/bitrunning/code/disks.dm * Update code/modules/bitrunning/server/obj_generation.dm Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> --------- Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> * [MIRROR] Bitrunning prefloading --------- Co-authored-by: Stalkeros <42087567+Stalkeros2@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: StealsThePRs --- .../bitrunning/server/obj_generation.dm | 11 +++- code/modules/bitrunning/server/util.dm | 10 +++- modular_nova/modules/bitrunning/code/disks.dm | 52 +++++++++++++++++++ .../modules/bitrunning/code/outfit.dm | 2 + tgstation.dme | 1 + 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 modular_nova/modules/bitrunning/code/outfit.dm diff --git a/code/modules/bitrunning/server/obj_generation.dm b/code/modules/bitrunning/server/obj_generation.dm index baf427855a2..b747e8ca0dc 100644 --- a/code/modules/bitrunning/server/obj_generation.dm +++ b/code/modules/bitrunning/server/obj_generation.dm @@ -38,9 +38,14 @@ /// Generates a new avatar for the bitrunner. -/obj/machinery/quantum_server/proc/generate_avatar(turf/destination, datum/outfit/netsuit) +/obj/machinery/quantum_server/proc/generate_avatar(turf/destination, datum/outfit/netsuit, datum/preferences/prefs, include_loadout = FALSE) // NOVA EDIT CHANGE - Prefs argument - ORIGINAL: /obj/machinery/quantum_server/proc/generate_avatar(turf/destination, datum/outfit/netsuit) var/mob/living/carbon/human/avatar = new(destination) + // NOVA EDIT ADDITION START - PREFS! + if(!isnull(prefs)) + prefs.safe_transfer_prefs_to(avatar) + ADD_TRAIT(avatar, TRAIT_CANNOT_CRYSTALIZE, "Bitrunning") // Stops the funny ethereal bug + // NOVA EDIT ADDITION END var/outfit_path = generated_domain.forced_outfit || netsuit var/datum/outfit/to_wear = new outfit_path() @@ -77,6 +82,10 @@ new /obj/item/flashlight, ) + // NOVA EDIT ADDITION START + if(!isnull(prefs) && include_loadout) + avatar.equip_outfit_and_loadout(new /datum/outfit(), prefs) + // NOVA EDIT ADDITION END var/obj/item/card/id/outfit_id = avatar.wear_id if(outfit_id) outfit_id.registered_account = new() diff --git a/code/modules/bitrunning/server/util.dm b/code/modules/bitrunning/server/util.dm index 912f0c1f874..54673570f8a 100644 --- a/code/modules/bitrunning/server/util.dm +++ b/code/modules/bitrunning/server/util.dm @@ -148,7 +148,15 @@ if(isnull(entry_atom)) return - var/mob/living/carbon/new_avatar = generate_avatar(get_turf(entry_atom), netsuit) + // NOVA EDIT ADDITION BEGIN - PREFS! + var/datum/preferences/pref + var/load_loadout = FALSE + var/obj/item/bitrunning_disk/prefs/prefdisk = locate() in neo.get_contents() + if(prefdisk) + load_loadout = prefdisk.include_loadout + pref = prefdisk.loaded_preference + // NOVA EDIT ADDITION END + var/mob/living/carbon/new_avatar = generate_avatar(get_turf(entry_atom), netsuit, pref, include_loadout = load_loadout) // NOVA EDIT CHANGE - ORIGINAL: var/mob/living/carbon/new_avatar = generate_avatar(get_turf(entry_atom), netsuit) stock_gear(new_avatar, neo, generated_domain) // Cleanup for domains with one time use custom spawns diff --git a/modular_nova/modules/bitrunning/code/disks.dm b/modular_nova/modules/bitrunning/code/disks.dm index d62d05f31b0..3a0d202435a 100644 --- a/modular_nova/modules/bitrunning/code/disks.dm +++ b/modular_nova/modules/bitrunning/code/disks.dm @@ -17,6 +17,53 @@ /obj/item/storage/pouch/cin_medkit, ) +/obj/item/bitrunning_disk/prefs + name = "\improper DeForest biological simulation disk" + desc = "A disk containing the biological simulation data necessary to load custom characters into bitrunning domains." + icon = 'icons/obj/devices/circuitry_n_data.dmi' + base_icon_state = "datadisk" + icon_state = "datadisk0" + + w_class = WEIGHT_CLASS_SMALL + + var/datum/preferences/loaded_preference + + var/include_loadout = FALSE + +/obj/item/bitrunning_disk/prefs/examine(mob/user) + . = ..() + if(!isnull(loaded_preference)) + var/name = loaded_preference.read_preference(/datum/preference/name/real_name) + . += "It currently has the character [name] loaded, with loadouts [(include_loadout ? "enabled" : "disabled")]" + . += span_notice("Alt-Click to change loadout loading") + +/obj/item/bitrunning_disk/prefs/click_alt(mob/user) + if(isnull(loaded_preference)) + return CLICK_ACTION_BLOCKING + include_loadout = !include_loadout // We just switch this around. Elegant! + balloon_alert(user, include_loadout ? "Loadout enabled" : "Loadout disabled") + return CLICK_ACTION_SUCCESS + +/obj/item/bitrunning_disk/prefs/attack_self(mob/user, modifiers) + . = ..() + + var/list/prefdata_names = user.client.prefs?.create_character_profiles() + if(isnull(prefdata_names)) + return + + var/response = tgui_alert(user, message = "Change selected prefs?", title = "Prefchange", buttons = list("Yes", "No")) + if(isnull(response) || response == "No") + return + var/choice = tgui_input_list(user, message = "Select a character", title = "Character selection", items = prefdata_names) + if(isnull(choice) || !user.is_holding(src)) + return + + loaded_preference = new(user.client) + loaded_preference.load_character(prefdata_names.Find(choice)) + + balloon_alert(user, "character set!") + to_chat(user, span_notice("Character set to [choice] sucessfully!")) + /datum/orderable_item/bitrunning_tech/ability_tier0 cost_per_order = 350 item_path = /obj/item/bitrunning_disk/ability/tier0 @@ -99,3 +146,8 @@ /datum/orderable_item/bitrunning_tech/ability_tier3 desc = "This disk contains a program that lets you shapeshift into a lesser ashdrake, a polar bear, a holy juggernaut, or a holy wraith; or cast Death Loop." + +/datum/orderable_item/bitrunning_tech/pref_item + cost_per_order = 500 + item_path = /obj/item/bitrunning_disk/prefs + desc = "This disk contains a program that lets you load in custom characters." diff --git a/modular_nova/modules/bitrunning/code/outfit.dm b/modular_nova/modules/bitrunning/code/outfit.dm new file mode 100644 index 00000000000..eea880e45f7 --- /dev/null +++ b/modular_nova/modules/bitrunning/code/outfit.dm @@ -0,0 +1,2 @@ +/datum/outfit/job/bitrunner + r_pocket = /obj/item/bitrunning_disk/prefs diff --git a/tgstation.dme b/tgstation.dme index 61cab8f8cee..1694d0c06fc 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7149,6 +7149,7 @@ #include "modular_nova\modules\bitrunning\code\disks.dm" #include "modular_nova\modules\bitrunning\code\flair.dm" #include "modular_nova\modules\bitrunning\code\mobs.dm" +#include "modular_nova\modules\bitrunning\code\outfit.dm" #include "modular_nova\modules\bitrunning\code\spells.dm" #include "modular_nova\modules\bitrunning\code\virtual_domains\ancient_milsim\area.dm" #include "modular_nova\modules\bitrunning\code\virtual_domains\ancient_milsim\choice_beacon.dm"