Skip to content

Commit

Permalink
tweak(customs): add optional patron requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
Doster-d authored Oct 7, 2023
1 parent 3ef0e3b commit dd4ea7e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions code/__defines/donations_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down
4 changes: 4 additions & 0 deletions code/modules/client/preference_setup/loadout/lists/custom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions code/modules/customitems/item_spawning.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config/schema/custom_items.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit dd4ea7e

Please sign in to comment.