i think it works

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)
This commit is contained in:
LetterN
2021-10-30 11:45:50 +08:00
parent f7b898a2a9
commit 99019166e4
117 changed files with 3049 additions and 1868 deletions
+90 -69
View File
@@ -1,54 +1,76 @@
/proc/get_uplink_items(datum/game_mode/gamemode, allow_sales = TRUE, allow_restricted = TRUE, other_filter = list())
var/list/filtered_uplink_items = GLOB.uplink_categories.Copy() // list of uplink categories without associated values.
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.include_modes.len)
if(!gamemode && SSticker.mode && !(SSticker.mode.type in I.include_modes))
continue
if(gamemode && !(gamemode in I.include_modes))
continue
if(I.exclude_modes.len)
if(!gamemode && SSticker.mode && (SSticker.mode.type in I.exclude_modes))
continue
if(gamemode && (gamemode in I.exclude_modes))
continue
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 (I.type in other_filter)
continue
LAZYSET(filtered_uplink_items[I.category], I.name, I)
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)
for(var/i in 1 to 3)
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 = 1
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.cost = max(round(A.cost * discount),1)
A.category = "Discounted Gear"
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
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
LAZYSET(filtered_uplink_items[A.category], A.name, A)
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"]
for(var/category in filtered_uplink_items)
if(!filtered_uplink_items[category]) //empty categories with no associated uplink item. Remove.
filtered_uplink_items -= category
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
@@ -67,12 +89,14 @@
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
var/list/include_modes = list() // Game modes to allow this item in.
var/list/exclude_modes = list() // Game modes to disallow this item from.
/// 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()
@@ -80,6 +104,7 @@
/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)
@@ -94,70 +119,66 @@
if(ishuman(user) && istype(A, /obj/item))
var/mob/living/carbon/human/H = user
if(H.put_in_hands(A))
to_chat(H, "[A] materializes into your hands!")
to_chat(H, span_boldnotice("[A] materializes into your hands!"))
return A
to_chat(user, "[A] materializes onto the floor.")
to_chat(user, span_boldnotice("[A] materializes onto the floor!"))
return A
/*
Uplink Categories:
Due to how the typesof() in-built byond proc works, it should be kept in mind
the order categories are displayed in the uplink UI is same to the order they are loaded in the code.
I trust no extra filter is needed as long as they are all contained within the following lines.
When adding new uplink categories, please keep them separate from their sub paths here and without set item.
Failure to comply may result in the new categories being listed at the bottom of the UI.
*/
//Discounts (dynamically filled above)
/datum/uplink_item/discounts
category = "Discounts"
// cit specific. idk
/datum/uplink_item/holiday
category = "Holiday"
/datum/uplink_item/bundles_TC
category = "Telecrystals and Bundles"
//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"
/datum/uplink_item/stealthy_weapons
category = "Stealthy Weapons"
/datum/uplink_item/ammo
category = "Ammunition"
surplus = 40
/datum/uplink_item/explosives
category = "Explosives"
//Support and Mechs
/datum/uplink_item/support
category = "Support and Exosuits"
surplus = 0
include_modes = list(/datum/game_mode/nuclear)
/datum/uplink_item/suits
category = "Clothing"
surplus = 40
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"
exclude_modes = list(/datum/game_mode/nuclear, /datum/game_mode/nuclear/clown_ops)
purchasable_from = ~(UPLINK_NUKE_OPS | UPLINK_CLOWN_OPS)
surplus = 0
cant_discount = TRUE
// Pointless
/datum/uplink_item/badass
category = "(Pointless) Badassery"
surplus = 0
//Discounts (dynamically filled above)
/datum/uplink_item/discounts
category = "Discounted Gear"