From 3a1b9b2489ca599b78f53bf57c2e8af1e9a7d65a Mon Sep 17 00:00:00 2001 From: Doster <63081538+Doster-d@users.noreply.github.com> Date: Fri, 6 Oct 2023 19:15:39 +0300 Subject: [PATCH] tweak(customs): add optional patron requirement --- code/__defines/donations_defines.dm | 1 + code/modules/client/preference_setup/loadout/lists/custom.dm | 4 ++++ code/modules/customitems/item_spawning.dm | 1 + config/schema/custom_items.schema.json | 4 ++++ 4 files changed, 10 insertions(+) diff --git a/code/__defines/donations_defines.dm b/code/__defines/donations_defines.dm index 5e56f25c60d..9771fe059cd 100644 --- a/code/__defines/donations_defines.dm +++ b/code/__defines/donations_defines.dm @@ -9,6 +9,7 @@ #define PATREON_CULTIST "cultist" #define PATREON_ASSISTANT "assistant" +// IMPORTANT (!!!) KEEP THE ASCENDING ORDER (more benefits -> place it on the right) OTHERWISE IT BREAKS CUSTOM ITEMS ASSIGNATION #define PATREON_ALL_TIERS list(\ PATREON_NONE, PATREON_CARGO, PATREON_ENGINEER, \ PATREON_SCIENTIST, PATREON_HOS, PATREON_CAPTAIN, \ diff --git a/code/modules/client/preference_setup/loadout/lists/custom.dm b/code/modules/client/preference_setup/loadout/lists/custom.dm index 8b361e3f3df..88039e5c4c1 100644 --- a/code/modules/client/preference_setup/loadout/lists/custom.dm +++ b/code/modules/client/preference_setup/loadout/lists/custom.dm @@ -3,6 +3,7 @@ var/ckey // assigned ckey of custom item owner var/required_access var/datum/custom_item/item_data + var/patreon_type /datum/gear/custom_item/New(key, item_path, datum/custom_item/data) var/obj/item/A = item_path @@ -32,6 +33,9 @@ gear_tweaks += new /datum/gear_tweak/custom(item_data) /datum/gear/custom_item/is_allowed_to_display(mob/user) + var/list/patreon_all_tiers = PATREON_ALL_TIERS + if(patreon_type && patreon_all_tiers.Find(user?.client?.donator_info.patron_type) < patreon_all_tiers.Find(patreon_type)) + return FALSE return user.ckey == ckey /datum/gear/custom_item/is_allowed_to_equip(mob/user) diff --git a/code/modules/customitems/item_spawning.dm b/code/modules/customitems/item_spawning.dm index b7c11d9ba73..bac0f8362ac 100644 --- a/code/modules/customitems/item_spawning.dm +++ b/code/modules/customitems/item_spawning.dm @@ -168,6 +168,7 @@ current_data.assoc_key = ckey current_data.item_path = item_path var/datum/gear/custom_item/G = new(ckey, item_path, current_data) + G.patreon_type = item_data["patreon_type"] var/use_name = G.display_name var/use_category = G.sort_category diff --git a/config/schema/custom_items.schema.json b/config/schema/custom_items.schema.json index f582c2bb8e9..3eb5c2459a0 100644 --- a/config/schema/custom_items.schema.json +++ b/config/schema/custom_items.schema.json @@ -70,6 +70,10 @@ }, "additional_data": { "type": "string" + }, + "patreon_type": { + "type": "string", + "description": "If there's no nil string, it will be required to have this patreon type or higher to posses item." } }, "required": ["item"],