From 5052f836e71006d3eb634a92dda8fadc2e898db2 Mon Sep 17 00:00:00 2001 From: SandPoot Date: Mon, 6 Feb 2023 19:54:54 -0300 Subject: [PATCH] the stuff --- code/__DEFINES/inventory.dm | 4 +- code/__DEFINES/loadout.dm | 4 +- code/__HELPERS/custom_holoforms.dm | 1 + code/_globalvars/bitfields.dm | 1 + code/_globalvars/lists/loadout_categories.dm | 3 +- code/controllers/subsystem/job.dm | 67 +++++++++++++++++-- .../objects/structures/ghost_role_spawners.dm | 5 +- code/modules/clothing/under/accessories.dm | 3 +- .../mob/dead/new_player/preferences_setup.dm | 3 +- .../mob/living/carbon/human/inventory.dm | 4 ++ .../mob/living/carbon/human/species.dm | 16 +++++ .../code/modules/client/loadout/_loadout.dm | 1 + .../code/modules/client/loadout/accessory.dm | 20 ++++++ .../code/modules/client/loadout/backpack.dm | 20 +----- tgstation.dme | 1 + 15 files changed, 123 insertions(+), 30 deletions(-) create mode 100644 modular_citadel/code/modules/client/loadout/accessory.dm diff --git a/code/__DEFINES/inventory.dm b/code/__DEFINES/inventory.dm index 6c83a46514..d087c82093 100644 --- a/code/__DEFINES/inventory.dm +++ b/code/__DEFINES/inventory.dm @@ -46,9 +46,11 @@ #define ITEM_SLOT_HANDCUFFED (1<<18) /// Legcuff slot (bolas, beartraps) #define ITEM_SLOT_LEGCUFFED (1<<19) +/// To attach to a jumpsuit +#define ITEM_SLOT_ACCESSORY (1<<20) /// Total amount of slots -#define SLOTS_AMT 20 // Keep this up to date! +#define SLOTS_AMT 21 // Keep this up to date! //SLOT GROUP HELPERS #define ITEM_SLOT_POCKETS (ITEM_SLOT_LPOCKET|ITEM_SLOT_RPOCKET) diff --git a/code/__DEFINES/loadout.dm b/code/__DEFINES/loadout.dm index 182e58c1f7..4a52d25fb3 100644 --- a/code/__DEFINES/loadout.dm +++ b/code/__DEFINES/loadout.dm @@ -4,10 +4,12 @@ #define LOADOUT_SUBCATEGORY_NONE "Miscellaneous" #define LOADOUT_SUBCATEGORIES_NONE list("Miscellaneous") +//accessory +#define LOADOUT_CATEGORY_ACCESSORY "Accessory" + //backpack #define LOADOUT_CATEGORY_BACKPACK "In backpack" #define LOADOUT_SUBCATEGORY_BACKPACK_GENERAL "General" //basically anything that there's not enough of to have its own subcategory -#define LOADOUT_SUBCATEGORY_BACKPACK_ACCESSORIES "Accessories" //maybe one day someone will make loadouts have accessory compatibility #define LOADOUT_SUBCATEGORY_BACKPACK_TOYS "Toys" //neck #define LOADOUT_CATEGORY_NECK "Neck" diff --git a/code/__HELPERS/custom_holoforms.dm b/code/__HELPERS/custom_holoforms.dm index 8aa8d279ec..87f3bfbe8b 100644 --- a/code/__HELPERS/custom_holoforms.dm +++ b/code/__HELPERS/custom_holoforms.dm @@ -6,6 +6,7 @@ prefs.copy_to(mannequin) if(apply_loadout && prefs.parent) SSjob.equip_loadout(prefs.parent.mob, mannequin, bypass_prereqs = TRUE) + SSjob.post_equip_loadout(prefs.parent.mob, mannequin, bypass_prereqs = TRUE) if(copy_job) var/datum/job/highest = prefs.get_highest_job() if(highest && !istype(highest, /datum/job/ai) && !istype(highest, /datum/job/cyborg)) diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index f412f31e9c..1f261903d2 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -412,6 +412,7 @@ DEFINE_BITFIELD(sight, list( )) DEFINE_BITFIELD(slot_flags, list( + "ITEM_SLOT_ACCESSORY" = ITEM_SLOT_ACCESSORY, "ITEM_SLOT_BACK" = ITEM_SLOT_BACK, "ITEM_SLOT_BACKPACK" = ITEM_SLOT_BACKPACK, "ITEM_SLOT_BELT" = ITEM_SLOT_BELT, diff --git a/code/_globalvars/lists/loadout_categories.dm b/code/_globalvars/lists/loadout_categories.dm index 5dd7220676..4ddb451f19 100644 --- a/code/_globalvars/lists/loadout_categories.dm +++ b/code/_globalvars/lists/loadout_categories.dm @@ -1,5 +1,6 @@ GLOBAL_LIST_INIT(loadout_categories, list( - LOADOUT_CATEGORY_BACKPACK = list(LOADOUT_SUBCATEGORY_BACKPACK_GENERAL, LOADOUT_SUBCATEGORY_BACKPACK_ACCESSORIES, LOADOUT_SUBCATEGORY_BACKPACK_TOYS), + LOADOUT_CATEGORY_ACCESSORY = LOADOUT_SUBCATEGORIES_NONE, + LOADOUT_CATEGORY_BACKPACK = list(LOADOUT_SUBCATEGORY_BACKPACK_GENERAL, LOADOUT_SUBCATEGORY_BACKPACK_TOYS), LOADOUT_CATEGORY_NECK = list(LOADOUT_SUBCATEGORY_NECK_GENERAL, LOADOUT_SUBCATEGORY_NECK_TIE, LOADOUT_SUBCATEGORY_NECK_SCARVES), LOADOUT_CATEGORY_MASK = LOADOUT_SUBCATEGORIES_NONE, LOADOUT_CATEGORY_HANDS = LOADOUT_SUBCATEGORIES_NONE, diff --git a/code/controllers/subsystem/job.dm b/code/controllers/subsystem/job.dm index 643811368c..ac681642c7 100644 --- a/code/controllers/subsystem/job.dm +++ b/code/controllers/subsystem/job.dm @@ -482,7 +482,7 @@ SUBSYSTEM_DEF(job) if(job.dresscodecompliant)// CIT CHANGE - dress code compliance equip_loadout(N, H) // CIT CHANGE - allows players to spawn with loadout items job.after_spawn(H, M.client, joined_late) // note: this happens before the mob has a key! M will always have a client, H might not. - equip_loadout(N, H, TRUE)//CIT CHANGE - makes players spawn with in-backpack loadout items properly. A little hacky but it works + post_equip_loadout(N, H)//CIT CHANGE - makes players spawn with in-backpack loadout items properly. A little hacky but it works var/list/tcg_cards if(ishuman(H)) @@ -684,7 +684,7 @@ SUBSYSTEM_DEF(job) message_admins(msg) CRASH(msg) -/datum/controller/subsystem/job/proc/equip_loadout(mob/dead/new_player/N, mob/living/M, equipbackpackstuff, bypass_prereqs = FALSE, can_drop = TRUE) +/datum/controller/subsystem/job/proc/equip_loadout(mob/dead/new_player/N, mob/living/M, bypass_prereqs = FALSE, can_drop = TRUE) var/mob/the_mob = N if(!the_mob) the_mob = M // cause this doesn't get assigned if player is a latejoiner @@ -702,9 +702,68 @@ SUBSYSTEM_DEF(job) permitted = FALSE if(G.donoritem && !G.donator_ckey_check(the_mob.client.ckey)) permitted = FALSE - if(!equipbackpackstuff && G.slot == ITEM_SLOT_BACKPACK)//snowflake check since plopping stuff in the backpack doesnt work for pre-job equip loadout stuffs + if(G.handle_post_equip) permitted = FALSE - if(equipbackpackstuff && G.slot != ITEM_SLOT_BACKPACK)//ditto + if(!permitted) + continue + var/obj/item/I = new G.path + if(I) + if(length(i[LOADOUT_COLOR])) //handle loadout colors + //handle polychromic items + if((G.loadout_flags & LOADOUT_CAN_COLOR_POLYCHROMIC) && length(G.loadout_initial_colors)) + var/datum/element/polychromic/polychromic = LAZYACCESS(I.comp_lookup, "item_worn_overlays") //stupid way to do it but GetElement does not work for this + if(polychromic && istype(polychromic)) + var/list/polychromic_entry = polychromic.colors_by_atom[I] + if(polychromic_entry) + if(polychromic.suits_with_helmet_typecache[I.type]) //is this one of those toggleable hood/helmet things? + polychromic.connect_helmet(I,i[LOADOUT_COLOR]) + polychromic.colors_by_atom[I] = i[LOADOUT_COLOR] + I.update_icon() + else + //handle non-polychromic items (they only have one color) + I.add_atom_colour(i[LOADOUT_COLOR][1], FIXED_COLOUR_PRIORITY) + I.update_icon() + //when inputting the data it's already sanitized + if(i[LOADOUT_CUSTOM_NAME]) + var/custom_name = i[LOADOUT_CUSTOM_NAME] + I.name = custom_name + if(i[LOADOUT_CUSTOM_DESCRIPTION]) + var/custom_description = i[LOADOUT_CUSTOM_DESCRIPTION] + I.desc = custom_description + if(!M.equip_to_slot_if_possible(I, G.slot, disable_warning = TRUE, bypass_equip_delay_self = TRUE)) // If the job's dresscode compliant, try to put it in its slot, first + if(iscarbon(M)) + var/mob/living/carbon/C = M + var/obj/item/storage/backpack/B = C.back + if(!B || !SEND_SIGNAL(B, COMSIG_TRY_STORAGE_INSERT, I, null, TRUE, TRUE)) // Otherwise, try to put it in the backpack, for carbons. + if(can_drop) + I.forceMove(get_turf(C)) + else + qdel(I) + else if(!M.equip_to_slot_if_possible(I, ITEM_SLOT_BACKPACK, disable_warning = TRUE, bypass_equip_delay_self = TRUE)) // Otherwise, try to put it in the backpack + if(can_drop) + I.forceMove(get_turf(M)) // If everything fails, just put it on the floor under the mob. + else + qdel(I) + +/datum/controller/subsystem/job/proc/post_equip_loadout(mob/dead/new_player/N, mob/living/M, bypass_prereqs = FALSE, can_drop = TRUE) + var/mob/the_mob = N + if(!the_mob) + the_mob = M // cause this doesn't get assigned if player is a latejoiner + var/list/chosen_gear = the_mob.client.prefs.loadout_data["SAVE_[the_mob.client.prefs.loadout_slot]"] + if(the_mob.client && the_mob.client.prefs && (chosen_gear && chosen_gear.len)) + if(!ishuman(M))//no silicons allowed + return + for(var/i in chosen_gear) + var/datum/gear/G = istext(i[LOADOUT_ITEM]) ? text2path(i[LOADOUT_ITEM]) : i[LOADOUT_ITEM] + G = GLOB.loadout_items[initial(G.category)][initial(G.subcategory)][initial(G.name)] + if(!G) + continue + var/permitted = TRUE + if(!bypass_prereqs && G.restricted_roles && G.restricted_roles.len && !(M.mind.assigned_role in G.restricted_roles)) + permitted = FALSE + if(G.donoritem && !G.donator_ckey_check(the_mob.client.ckey)) + permitted = FALSE + if(!G.handle_post_equip) permitted = FALSE if(!permitted) continue diff --git a/code/game/objects/structures/ghost_role_spawners.dm b/code/game/objects/structures/ghost_role_spawners.dm index 0077ad82da..90224af8cc 100644 --- a/code/game/objects/structures/ghost_role_spawners.dm +++ b/code/game/objects/structures/ghost_role_spawners.dm @@ -73,7 +73,7 @@ yolk.gib() QDEL_NULL(egg) return ..() - + /obj/effect/mob_spawn/human/ash_walker name = "ash walker egg" desc = "A man-sized yellow egg, spawned from some unfathomable creature. A humanoid silhouette lurks within." @@ -835,7 +835,8 @@ var/area/A = get_area(src) var/datum/outfit/O = new /datum/outfit/ghostcafe() O.equip(new_spawn, FALSE, new_spawn.client) - SSjob.equip_loadout(null, new_spawn, FALSE) + SSjob.equip_loadout(null, new_spawn) + SSjob.post_equip_loadout(null, new_spawn) SSquirks.AssignQuirks(new_spawn, new_spawn.client, TRUE, TRUE, null, FALSE, new_spawn) new_spawn.AddElement(/datum/element/ghost_role_eligibility, free_ghosting = TRUE) new_spawn.AddElement(/datum/element/dusts_on_catatonia) diff --git a/code/modules/clothing/under/accessories.dm b/code/modules/clothing/under/accessories.dm index f481d83009..51a1868483 100644 --- a/code/modules/clothing/under/accessories.dm +++ b/code/modules/clothing/under/accessories.dm @@ -4,7 +4,8 @@ icon = 'icons/obj/clothing/accessories.dmi' icon_state = "plasma" item_state = "" //no inhands - slot_flags = 0 + slot_flags = ITEM_SLOT_ACCESSORY + slot_equipment_priority = list(ITEM_SLOT_ACCESSORY) w_class = WEIGHT_CLASS_SMALL var/above_suit = FALSE var/minimize_when_attached = TRUE // TRUE if shown as a small icon in corner, FALSE if overlayed diff --git a/code/modules/mob/dead/new_player/preferences_setup.dm b/code/modules/mob/dead/new_player/preferences_setup.dm index 378313311e..dd3d5186de 100644 --- a/code/modules/mob/dead/new_player/preferences_setup.dm +++ b/code/modules/mob/dead/new_player/preferences_setup.dm @@ -51,7 +51,8 @@ if(current_tab == LOADOUT_TAB) //give it its loadout if not on the appearance tab - SSjob.equip_loadout(parent.mob, mannequin, FALSE, bypass_prereqs = TRUE, can_drop = FALSE) + SSjob.equip_loadout(parent.mob, mannequin, bypass_prereqs = TRUE, can_drop = FALSE) + SSjob.post_equip_loadout(parent.mob, mannequin, bypass_prereqs = TRUE, can_drop = FALSE) else if(previewJob && equip_job) mannequin.job = previewJob.title diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index 4c30a1d742..d8f87cf273 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -148,6 +148,10 @@ if(ITEM_SLOT_SUITSTORE) s_store = I update_inv_s_store() + if(ITEM_SLOT_ACCESSORY) + var/obj/item/clothing/under/attach_target = w_uniform + attach_target.attach_accessory(I, src, TRUE) + // updates handled by attach_accessory else to_chat(src, "You are trying to equip this item to an unsupported inventory slot. Report this to a coder!") not_handled = TRUE diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 10f064423c..bed766519f 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -1454,6 +1454,22 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) if(SEND_SIGNAL(H.back, COMSIG_TRY_STORAGE_CAN_INSERT, I, H, TRUE)) return TRUE return FALSE + if(ITEM_SLOT_ACCESSORY) + if(istype(H.w_uniform, /obj/item/clothing/under)) + var/obj/item/clothing/under/attaching_target = H.w_uniform + if(attaching_target.attached_accessory) + if(return_warning) + return_warning[1] = "\The [attaching_target] already has an accessory." + return FALSE + if(attaching_target.dummy_thick) + if(return_warning) + return_warning[1] = "\The [attaching_target] is too bulky and cannot have accessories attached to it!" + return FALSE + else + return TRUE + else if(return_warning) + return_warning[1] = "\The [H.w_uniform] cannot have any attachments." + return FALSE return FALSE //Unsupported slot /datum/species/proc/equip_delay_self_check(obj/item/I, mob/living/carbon/human/H, bypass_equip_delay_self) diff --git a/modular_citadel/code/modules/client/loadout/_loadout.dm b/modular_citadel/code/modules/client/loadout/_loadout.dm index 5f895c4805..f33beecb32 100644 --- a/modular_citadel/code/modules/client/loadout/_loadout.dm +++ b/modular_citadel/code/modules/client/loadout/_loadout.dm @@ -55,6 +55,7 @@ GLOBAL_LIST_EMPTY(loadout_whitelist_ids) var/geargroupID //defines the ID that the gear inherits from the config var/loadout_flags = LOADOUT_CAN_NAME | LOADOUT_CAN_DESCRIPTION var/list/loadout_initial_colors = list() + var/handle_post_equip = FALSE //NEW DONATOR SYTSEM STUFF var/donoritem //autoset on new if null diff --git a/modular_citadel/code/modules/client/loadout/accessory.dm b/modular_citadel/code/modules/client/loadout/accessory.dm new file mode 100644 index 0000000000..55cce181a5 --- /dev/null +++ b/modular_citadel/code/modules/client/loadout/accessory.dm @@ -0,0 +1,20 @@ +/datum/gear/accessory + category = LOADOUT_CATEGORY_ACCESSORY + slot = ITEM_SLOT_ACCESSORY + handle_post_equip = TRUE + +/datum/gear/accessory/necklace + name = "A renameable necklace" + path = /obj/item/clothing/accessory/necklace + +/datum/gear/accessory/polymaidapron + name = "Polychromic maid apron" + path = /obj/item/clothing/accessory/maidapron/polychromic + loadout_flags = LOADOUT_CAN_NAME | LOADOUT_CAN_DESCRIPTION | LOADOUT_CAN_COLOR_POLYCHROMIC + loadout_initial_colors = list("#333333", "#FFFFFF") + +/datum/gear/accessory/pridepin + name = "Pride pin" + path = /obj/item/clothing/accessory/pride + loadout_flags = LOADOUT_CAN_NAME | LOADOUT_CAN_DESCRIPTION + cost = 0 diff --git a/modular_citadel/code/modules/client/loadout/backpack.dm b/modular_citadel/code/modules/client/loadout/backpack.dm index a0be000b31..24545e7b4c 100644 --- a/modular_citadel/code/modules/client/loadout/backpack.dm +++ b/modular_citadel/code/modules/client/loadout/backpack.dm @@ -2,6 +2,7 @@ category = LOADOUT_CATEGORY_BACKPACK subcategory = LOADOUT_SUBCATEGORY_BACKPACK_GENERAL slot = ITEM_SLOT_BACKPACK + handle_post_equip = TRUE /datum/gear/backpack/plushbox name = "Plushie Choice Box" @@ -172,25 +173,6 @@ path = /obj/item/storage/fancy/ringbox/diamond cost = 5 -/datum/gear/backpack/necklace //this is here because loadout doesn't support proper accessories - name = "A renameable necklace" - path = /obj/item/clothing/accessory/necklace - subcategory = LOADOUT_SUBCATEGORY_BACKPACK_ACCESSORIES - -/datum/gear/backpack/polymaidapron //this is ALSO here because loadout doesn't support proper accessories - name = "Polychromic maid apron" - path = /obj/item/clothing/accessory/maidapron/polychromic - loadout_flags = LOADOUT_CAN_NAME | LOADOUT_CAN_DESCRIPTION | LOADOUT_CAN_COLOR_POLYCHROMIC - loadout_initial_colors = list("#333333", "#FFFFFF") - subcategory = LOADOUT_SUBCATEGORY_BACKPACK_ACCESSORIES - -/datum/gear/backpack/pridepin //what the two comments above said - name = "Pride pin" - path = /obj/item/clothing/accessory/pride - loadout_flags = LOADOUT_CAN_NAME | LOADOUT_CAN_DESCRIPTION - subcategory = LOADOUT_SUBCATEGORY_BACKPACK_ACCESSORIES - cost = 0 - // Moved here from quirks /datum/gear/backpack/dyespray name = "Hair dye spray" diff --git a/tgstation.dme b/tgstation.dme index e0b11fb3ad..07e2f9ec6f 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3814,6 +3814,7 @@ #include "modular_citadel\code\modules\client\loadout\_medical.dm" #include "modular_citadel\code\modules\client\loadout\_security.dm" #include "modular_citadel\code\modules\client\loadout\_service.dm" +#include "modular_citadel\code\modules\client\loadout\accessory.dm" #include "modular_citadel\code\modules\client\loadout\backpack.dm" #include "modular_citadel\code\modules\client\loadout\glasses.dm" #include "modular_citadel\code\modules\client\loadout\gloves.dm"