Allows Job and Species specific items to roll discounts (#25915)

* Job and Species Discounts

* Condensed procs

* No His Grace discounts

* Better crates, no discounts for 10 TC or lower

* Removes extraneous bits

* Removed excess null, fixed out-of-scope discount floor change

* Documentation, null check, and a lot of snakes

* Reworked logic of where it does job/species checks

* Curly brackets begone

Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>

* Curly brackets begone pt2

Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>

* Removed for loops in job-species checks

* No freebies

* Early continues

---------

Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>
Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
This commit is contained in:
PollardTheDragon
2024-08-04 04:01:35 -04:00
committed by GitHub
parent a21b962ee6
commit 88fbe41208
3 changed files with 25 additions and 14 deletions
+19 -9
View File
@@ -2,14 +2,12 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
// This define is used when we have to spawn in an uplink item in a weird way, like a Surplus crate spawning an actual crate.
// Use this define by setting `uses_special_spawn` to TRUE on the item, and then checking if the parent proc of `spawn_item` returns this define. If it does, implement your special spawn after that.
/proc/get_uplink_items(obj/item/uplink/U)
/proc/get_uplink_items(obj/item/uplink/U, mob/user)
var/list/uplink_items = list()
var/list/sales_items = list()
var/newreference = 1
if(!length(uplink_items))
for(var/path in GLOB.uplink_items)
var/datum/uplink_item/I = new path
if(!I.item)
continue
@@ -17,30 +15,42 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
continue
if(length(I.excludefrom) && (U.uplink_type in I.excludefrom))
continue
//Add items to discount pool, checking job, species, and hijacker status
if(I.job && !(user.mind.assigned_role in I.job)) //If your job does not match, no discount
continue
if(I.species && !(user.dna?.species.name in I.species)) //If your species does not match, no discount
continue
if(I.hijack_only && !(locate(/datum/objective/hijack) in user.mind.get_all_objectives())) //If you aren't a hijacker, no hijack only items
continue
if(!uplink_items[I.category])
uplink_items[I.category] = list()
uplink_items[I.category] += I
if(I.limited_stock < 0 && I.can_discount && I.item && I.cost > 5)
sales_items += I
if(isnull(user)) //Handles surplus
return uplink_items
for(var/i in 1 to 3)
var/datum/uplink_item/I = pick_n_take(sales_items)
var/datum/uplink_item/A = new I.type
var/datum/uplink_item/sale_item = pick_n_take(sales_items)
var/datum/uplink_item/A = new sale_item.type
var/discount = 0.5
A.limited_stock = 1
sale_item.refundable = FALSE
A.refundable = FALSE
if(A.cost >= 100)
discount *= 0.5 // If the item costs 100TC or more, it's only 25% off.
A.cost = max(round(A.cost * (1 - discount)), 1)
A.category = "Discounted Gear"
A.name += " ([round(((initial(A.cost) - A.cost) / initial(A.cost)) * 100)]% off!)"
A.job = null // If you get a job specific item selected, actually lets you buy it in the discount section
A.species = null //same as above for species speific items
A.reference = "DIS[newreference]"
A.desc += " Limit of [A.limited_stock] per uplink. Normally costs [initial(A.cost)] TC."
A.surplus = 0 // stops the surplus crate potentially giving out a bit too much
A.item = I.item
A.surplus = 0 //No freebies
A.item = sale_item.item
newreference++
if(!uplink_items[A.category])
uplink_items[A.category] = list()
+1 -2
View File
@@ -4,7 +4,6 @@
/datum/uplink_item/jobspecific
category = "Job Specific Tools"
can_discount = FALSE
excludefrom = list(UPLINK_TYPE_NUCLEAR, UPLINK_TYPE_SST) // Stops the job specific category appearing for nukies
//Clown
@@ -145,6 +144,7 @@
job = list("Chaplain")
surplus = 0 //No lucky chances from the crate; if you get this, this is ALL you're getting
hijack_only = TRUE //This is a murderbone weapon, as such, it should only be available in those scenarios.
can_discount = FALSE
//Janitor
@@ -333,7 +333,6 @@
/datum/uplink_item/species_restricted
category = "Species Specific Gear"
can_discount = FALSE
excludefrom = list(UPLINK_TYPE_NUCLEAR, UPLINK_TYPE_SST) // Stops the job specific category appearing for nukies
//skrell