Skip to content

Commit

Permalink
[MIRROR] Bitrunning prefloading (#5196)
Browse files Browse the repository at this point in the history
* Bitrunning prefloading (#4555)

* ebin

* Apply suggestions from code review

Co-authored-by: Bloop <[email protected]>

* Update modular_nova/modules/bitrunning/code/disks.dm

* Update code/modules/bitrunning/server/obj_generation.dm

Co-authored-by: Bloop <[email protected]>

---------

Co-authored-by: Bloop <[email protected]>

* [MIRROR] Bitrunning prefloading

---------

Co-authored-by: Stalkeros <[email protected]>
Co-authored-by: Bloop <[email protected]>
Co-authored-by: StealsThePRs <[email protected]>
  • Loading branch information
4 people authored Nov 26, 2024
1 parent 6d7570b commit d7adda1
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 2 deletions.
11 changes: 10 additions & 1 deletion code/modules/bitrunning/server/obj_generation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand Down
10 changes: 9 additions & 1 deletion code/modules/bitrunning/server/util.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions modular_nova/modules/bitrunning/code/disks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
2 changes: 2 additions & 0 deletions modular_nova/modules/bitrunning/code/outfit.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/datum/outfit/job/bitrunner
r_pocket = /obj/item/bitrunning_disk/prefs
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d7adda1

Please sign in to comment.