mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-10 18:02:57 +00:00
MAJOR antag backend update - you cannot bruteforce the pen anymore - uplink now uses bitflag to lock purchases - poplock is handled entirely by the buyable uplink items - tgui antag intro (for selected ones)
185 lines
7.0 KiB
Plaintext
185 lines
7.0 KiB
Plaintext
GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
|
|
|
|
/proc/get_uplink_items(uplink_flag, allow_sales = TRUE, allow_restricted = TRUE)
|
|
var/list/filtered_uplink_items = list()
|
|
var/list/sale_items = list()
|
|
|
|
for(var/path in GLOB.uplink_items)
|
|
var/datum/uplink_item/I = new path
|
|
if(!I.item)
|
|
continue
|
|
if (!(I.purchasable_from & uplink_flag))
|
|
continue
|
|
if(I.player_minimum && I.player_minimum > GLOB.joined_player_list.len)
|
|
continue
|
|
if (I.restricted && !allow_restricted)
|
|
continue
|
|
|
|
if(!filtered_uplink_items[I.category])
|
|
filtered_uplink_items[I.category] = list()
|
|
filtered_uplink_items[I.category][I.name] = I
|
|
if(I.limited_stock < 0 && !I.cant_discount && I.item && I.cost > 1)
|
|
sale_items += I
|
|
if(allow_sales)
|
|
var/datum/team/nuclear/nuclear_team
|
|
// if (uplink_flag & UPLINK_NUKE_OPS) // uplink code kind of needs a redesign
|
|
// nuclear_team = locate() in GLOB.antagonist_teams // the team discounts could be in a GLOB with this design but it would make sense for them to be team specific...
|
|
if (!nuclear_team)
|
|
create_uplink_sales(3, "Discounted Gear", 1, sale_items, filtered_uplink_items)
|
|
else
|
|
if (!nuclear_team.team_discounts)
|
|
// create 5 unlimited stock discounts
|
|
create_uplink_sales(5, "Discounted Team Gear", -1, sale_items, filtered_uplink_items)
|
|
// Create 10 limited stock discounts
|
|
create_uplink_sales(10, "Limited Stock Team Gear", 1, sale_items, filtered_uplink_items)
|
|
nuclear_team.team_discounts = list("Discounted Team Gear" = filtered_uplink_items["Discounted Team Gear"], "Limited Stock Team Gear" = filtered_uplink_items["Limited Stock Team Gear"])
|
|
else
|
|
for(var/cat in nuclear_team.team_discounts)
|
|
for(var/item in nuclear_team.team_discounts[cat])
|
|
var/datum/uplink_item/D = nuclear_team.team_discounts[cat][item]
|
|
var/datum/uplink_item/O = filtered_uplink_items[initial(D.category)][initial(D.name)]
|
|
O.refundable = FALSE
|
|
|
|
filtered_uplink_items["Discounted Team Gear"] = nuclear_team.team_discounts["Discounted Team Gear"]
|
|
filtered_uplink_items["Limited Stock Team Gear"] = nuclear_team.team_discounts["Limited Stock Team Gear"]
|
|
|
|
|
|
return filtered_uplink_items
|
|
|
|
/proc/create_uplink_sales(num, category_name, limited_stock, sale_items, uplink_items)
|
|
if (num <= 0)
|
|
return
|
|
|
|
if(!uplink_items[category_name])
|
|
uplink_items[category_name] = list()
|
|
|
|
for (var/i in 1 to num)
|
|
var/datum/uplink_item/I = pick_n_take(sale_items)
|
|
var/datum/uplink_item/A = new I.type
|
|
var/discount = A.get_discount()
|
|
var/list/disclaimer = list("Void where prohibited.", "Not recommended for children.", "Contains small parts.", "Check local laws for legality in region.", "Do not taunt.", "Not responsible for direct, indirect, incidental or consequential damages resulting from any defect, error or failure to perform.", "Keep away from fire or flames.", "Product is provided \"as is\" without any implied or expressed warranties.", "As seen on TV.", "For recreational use only.", "Use only as directed.", "16% sales tax will be charged for orders originating within Space Nebraska.")
|
|
A.limited_stock = limited_stock
|
|
I.refundable = FALSE //THIS MAN USES ONE WEIRD TRICK TO GAIN FREE TC, CODERS HATES HIM!
|
|
A.refundable = FALSE
|
|
if(A.cost >= 20) //Tough love for nuke ops
|
|
discount *= 0.5
|
|
A.category = category_name
|
|
A.cost = max(round(A.cost * discount),1)
|
|
A.name += " ([round(((initial(A.cost)-A.cost)/initial(A.cost))*100)]% off!)"
|
|
A.desc += " Normally costs [initial(A.cost)] TC. All sales final. [pick(disclaimer)]"
|
|
A.item = I.item
|
|
|
|
uplink_items[category_name][A.name] = A
|
|
|
|
|
|
/**
|
|
* Uplink Items
|
|
*
|
|
* Items that can be spawned from an uplink. Can be limited by gamemode.
|
|
**/
|
|
/datum/uplink_item
|
|
var/name = "item name"
|
|
var/category = "item category"
|
|
var/desc = "item description"
|
|
var/item = null // Path to the item to spawn.
|
|
var/refund_path = null // Alternative path for refunds, in case the item purchased isn't what is actually refunded (ie: holoparasites).
|
|
var/cost = 0
|
|
var/refund_amount = 0 // specified refund amount in case there needs to be a TC penalty for refunds.
|
|
var/refundable = FALSE
|
|
var/surplus = 100 // Chance of being included in the surplus crate.
|
|
var/cant_discount = FALSE
|
|
var/limited_stock = -1 //Setting this above zero limits how many times this item can be bought by the same traitor in a round, -1 is unlimited
|
|
/// A bitfield to represent what uplinks can purchase this item.
|
|
/// See [`code/__DEFINES/uplink.dm`].
|
|
var/purchasable_from = ALL
|
|
var/list/restricted_roles = list() //If this uplink item is only available to certain roles. Roles are dependent on the frequency chip or stored ID.
|
|
var/player_minimum //The minimum crew size needed for this item to be added to uplinks.
|
|
var/purchase_log_vis = TRUE // Visible in the purchase log?
|
|
var/restricted = FALSE // Adds restrictions for VR/Events
|
|
var/list/restricted_species //Limits items to a specific species. Hopefully.
|
|
var/illegal_tech = TRUE // Can this item be deconstructed to unlock certain techweb research nodes?
|
|
|
|
/datum/uplink_item/proc/get_discount()
|
|
return pick(4;0.75,2;0.5,1;0.25)
|
|
|
|
/datum/uplink_item/proc/purchase(mob/user, datum/component/uplink/U)
|
|
var/atom/A = spawn_item(item, user, U)
|
|
// log_uplink("[key_name(user)] purchased [src] for [cost] telecrystals from [U.parent]'s uplink")
|
|
if(purchase_log_vis && U.purchase_log)
|
|
U.purchase_log.LogPurchase(A, src, cost)
|
|
|
|
/datum/uplink_item/proc/spawn_item(spawn_path, mob/user, datum/component/uplink/U)
|
|
if(!spawn_path)
|
|
return
|
|
var/atom/A
|
|
if(ispath(spawn_path))
|
|
A = new spawn_path(get_turf(user))
|
|
else
|
|
A = spawn_path
|
|
if(ishuman(user) && istype(A, /obj/item))
|
|
var/mob/living/carbon/human/H = user
|
|
if(H.put_in_hands(A))
|
|
to_chat(H, span_boldnotice("[A] materializes into your hands!"))
|
|
return A
|
|
to_chat(user, span_boldnotice("[A] materializes onto the floor!"))
|
|
return A
|
|
|
|
//Discounts (dynamically filled above)
|
|
/datum/uplink_item/discounts
|
|
category = "Discounts"
|
|
|
|
// cit specific. idk
|
|
/datum/uplink_item/holiday
|
|
category = "Holiday"
|
|
|
|
//All bundles and telecrystals
|
|
/datum/uplink_item/bundles_tc
|
|
category = "Bundles"
|
|
surplus = 0
|
|
cant_discount = TRUE
|
|
|
|
// Dangerous Items
|
|
/datum/uplink_item/dangerous
|
|
category = "Conspicuous Weapons"
|
|
|
|
//Support and Mechs
|
|
/datum/uplink_item/support
|
|
category = "Support and Exosuits"
|
|
surplus = 0
|
|
purchasable_from = UPLINK_NUKE_OPS
|
|
|
|
// Stealth Items
|
|
/datum/uplink_item/stealthy_tools
|
|
category = "Stealth Gadgets"
|
|
|
|
//Space Suits and Hardsuits
|
|
/datum/uplink_item/suits
|
|
category = "Space Suits"
|
|
surplus = 40
|
|
|
|
// Devices and Tools
|
|
/datum/uplink_item/device_tools
|
|
category = "Misc. Gadgets"
|
|
|
|
// Implants
|
|
/datum/uplink_item/implants
|
|
category = "Implants"
|
|
surplus = 50
|
|
|
|
//Race-specific items
|
|
/datum/uplink_item/race_restricted
|
|
category = "Species-Restricted"
|
|
purchasable_from = ~(UPLINK_NUKE_OPS | UPLINK_CLOWN_OPS)
|
|
surplus = 0
|
|
|
|
// Role-specific items
|
|
/datum/uplink_item/role_restricted
|
|
category = "Role-Restricted"
|
|
purchasable_from = ~(UPLINK_NUKE_OPS | UPLINK_CLOWN_OPS)
|
|
surplus = 0
|
|
|
|
// Pointless
|
|
/datum/uplink_item/badass
|
|
category = "(Pointless) Badassery"
|
|
surplus = 0
|