forked from tgstation/tgstation
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements Bitrunner Prefs Disks (Feat. Quirks & Evil Hacks) (without…
… the blowing up part) (#243) * redraw that horse as penance for rolling worst blunt imaginable * THERE we go
- Loading branch information
Showing
5 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
modular_doppler/bitrunning_prefs_disks/code/disks/prefs_disk.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/** | ||
* Bitrunning tech disks which let you load a custom character preference for your bit avatar. | ||
* This uses a preference selected from your character list. | ||
* Optionally, this may include the loadout as well. | ||
* | ||
* For the sake of domain restrictions: | ||
* - ability blocks block the application of character prefs. | ||
* - item blocks block the application of character loadout. | ||
*/ | ||
/obj/item/bitrunning_disk/preferences | ||
name = "bitrunning program: personalized avatar" | ||
desc = "A disk containing source code. It can be used to override your bit avatar's standard appearance. Further avatar disks will be ignored." | ||
|
||
// Allows it to be held in the pocket | ||
w_class = WEIGHT_CLASS_SMALL | ||
|
||
/// Our chosen preference. | ||
var/datum/preferences/chosen_preference | ||
/// Whether we include the loadout as well. | ||
var/include_loadout = FALSE | ||
/// Mock client we use for forwarding to quirk assignment (beware, evil hacks). | ||
var/datum/prefs_disk_client_interface/mock_client | ||
|
||
/obj/item/bitrunning_disk/preferences/Initialize(mapload) | ||
. = ..() | ||
register_context() | ||
|
||
/obj/item/bitrunning_disk/preferences/examine(mob/user) | ||
. = ..() | ||
if(isnull(chosen_preference)) | ||
return | ||
|
||
. += span_info("Loadout application is currently [include_loadout ? "enabled" : "disabled"].") | ||
. += span_notice("Ctrl-click to toggle loadout application.") | ||
|
||
/obj/item/bitrunning_disk/preferences/add_context(atom/source, list/context, obj/item/held_item, mob/living/user) | ||
var/result = NONE | ||
if(isnull(chosen_preference) && (held_item == src)) | ||
context[SCREENTIP_CONTEXT_LMB] = "Select avatar" | ||
result = CONTEXTUAL_SCREENTIP_SET | ||
if(!isturf(src.loc)) | ||
context[SCREENTIP_CONTEXT_CTRL_LMB] = "Toggle loadout" | ||
result = CONTEXTUAL_SCREENTIP_SET | ||
|
||
return result | ||
|
||
/obj/item/bitrunning_disk/preferences/Destroy() | ||
QDEL_NULL(chosen_preference) | ||
QDEL_NULL(mock_client) | ||
return ..() | ||
|
||
/obj/item/bitrunning_disk/preferences/attack_self(mob/user, modifiers) | ||
. = ..() | ||
|
||
if(isnull(user.client) || chosen_preference) | ||
return | ||
|
||
var/list/character_profiles = user.client.prefs?.create_character_profiles() | ||
if(isnull(character_profiles) || !length(character_profiles)) | ||
return | ||
|
||
var/choice = tgui_input_list(user, message = "Select a character", title = "Bitrunning Avatar", items = character_profiles) | ||
if(isnull(choice) || !user.is_holding(src)) | ||
return | ||
|
||
choice_made = choice | ||
chosen_preference = new(user.client) | ||
chosen_preference.load_character(character_profiles.Find(choice)) | ||
|
||
// Perform our evil hacks | ||
if(isnull(mock_client)) | ||
mock_client = new | ||
mock_client.prefs = chosen_preference | ||
// Done loading from the client, so replace reference to the real client | ||
chosen_preference.parent = mock_client | ||
|
||
balloon_alert(user, "avatar set!") | ||
playsound(user, 'sound/items/click.ogg', 50, TRUE) | ||
|
||
/obj/item/bitrunning_disk/preferences/item_ctrl_click(mob/user) | ||
if(isturf(src.loc)) // If on a turf, we skip to dragging | ||
return NONE | ||
if(isnull(chosen_preference)) | ||
balloon_alert(user, "set preference first!") | ||
return CLICK_ACTION_BLOCKING | ||
include_loadout = !include_loadout | ||
balloon_alert(user, include_loadout ? "loadout enabled!" : "loadout disabled!") | ||
|
||
// High frequency range when enabled, low when disabled. More tactile. | ||
var/toggle_frequency = include_loadout ? rand(45000, 55000) : rand(32000, 42000) | ||
playsound(user, 'sound/items/click.ogg', 50, TRUE, frequency = toggle_frequency) | ||
|
||
return CLICK_ACTION_SUCCESS | ||
|
||
/** | ||
* Allows for ordering of the prefs disk. | ||
*/ | ||
/datum/orderable_item/bitrunning_tech/prefs_disk | ||
cost_per_order = 1000 | ||
purchase_path = /obj/item/bitrunning_disk/preferences | ||
desc = "This disk contains a program that lets you load in custom bit avatars." | ||
|
||
/** | ||
* Evil hack that allows us to assign quirks without needing to forward a real client. | ||
* Using this instead of the normal mock client allows us to include only what we need without editing the base, | ||
* or interfering with things like `mock_client_uid`. | ||
* | ||
* Much the same, this should match the interface of /client wherever necessary. | ||
*/ | ||
/datum/prefs_disk_client_interface | ||
/// Player preferences datum for the client | ||
var/datum/preferences/prefs | ||
|
||
/// The mob the client controls | ||
var/mob/mob | ||
|
||
/// We don't actually care about award status, but we don't want it to runtime due to not existing. | ||
/datum/prefs_disk_client_interface/proc/get_award_status(achievement_type, mob/user, value = 1) | ||
return 0 |
4 changes: 4 additions & 0 deletions
4
modular_doppler/bitrunning_prefs_disks/code/outfit_overrides/bitrunner_outfit_override.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
// Spawns a single preferences disk to start with for all bitrunners. | ||
/datum/outfit/job/bitrunner | ||
r_pocket = /obj/item/bitrunning_disk/preferences |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!-- This should be copy-pasted into the root of your module folder as readme.md --> | ||
|
||
SOON<!--PR Number--> | ||
|
||
## Bitrunning Avatar Preference Disks <!--Title of your addition.--> | ||
|
||
Module ID: BITRUNNING_PREFS_DISKS <!-- Uppercase, UNDERSCORE_CONNECTED name of your module, that you use to mark files. This is so people can case-sensitive search for your edits, if any. --> | ||
|
||
### Description: | ||
|
||
Allows bitrunners to buy a personalized avatar disk, which lets them load in a given character preference, with all that entails. | ||
This includes even quirks through evil hacks, and optionally loadouts. | ||
Preference application and quirks are blocked if a domain blocks spells/abilities, loadouts are blocked if a domain blocks items. | ||
The evil hacks this performs are using a barebones mock client to allow for quirk assignment without forwarding or affecting the real client. | ||
|
||
<!-- Here, try to describe what your PR does, what features it provides and any other directly useful information. --> | ||
|
||
### TG Proc/File Changes: | ||
|
||
- `code/modules/bitrunning/server/obj_generation.dm`: `proc/stock_gear` | ||
<!-- If you edited any core procs, you should list them here. You should specify the files and procs you changed. | ||
E.g: | ||
- `code/modules/mob/living.dm`: `proc/overriden_proc`, `var/overriden_var` | ||
--> | ||
|
||
### Modular Overrides: | ||
|
||
- N/A | ||
<!-- If you added a new modular override (file or code-wise) for your module, you should list it here. Code files should specify what procs they changed, in case of multiple modules using the same file. | ||
E.g: | ||
- `modular_doppler/master_files/sound/my_cool_sound.ogg` | ||
- `modular_doppler/master_files/code/my_modular_override.dm`: `proc/overriden_proc`, `var/overriden_var` | ||
--> | ||
|
||
### Defines: | ||
|
||
- N/A | ||
<!-- If you needed to add any defines, mention the files you added those defines in, along with the name of the defines. --> | ||
|
||
### Included files that are not contained in this module: | ||
|
||
- N/A | ||
<!-- Likewise, be it a non-modular file or a modular one that's not contained within the folder belonging to this specific module, it should be mentioned here. Good examples are icons or sounds that are used between multiple modules, or other such edge-cases. --> | ||
|
||
### Credits: 00-Steven | ||
|
||
<!-- Here go the credits to you, dear coder, and in case of collaborative work or ports, credits to the original source of the code. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters