From 2d6bb70729275144159091a65d81274d011fb74f Mon Sep 17 00:00:00 2001
From: AzuleUtama <44248086+AzuleUtama@users.noreply.github.com>
Date: Mon, 19 Nov 2018 19:01:46 +0000
Subject: [PATCH 1/5] Discounts!
LET'S GO SHOPPING!
---
code/datums/uplink_item.dm | 38 ++++++++++++++++++++++
code/game/objects/items/devices/uplinks.dm | 4 +++
2 files changed, 42 insertions(+)
diff --git a/code/datums/uplink_item.dm b/code/datums/uplink_item.dm
index ed3536f8183..fee33786131 100644
--- a/code/datums/uplink_item.dm
+++ b/code/datums/uplink_item.dm
@@ -2,6 +2,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
/proc/get_uplink_items(var/job = null)
var/list/uplink_items = list()
+ var/list/sales_items = list()
if(!uplink_items.len)
var/list/last = list()
@@ -22,6 +23,8 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
uplink_items[I.category] = list()
uplink_items[I.category] += I
+ if(I.limited_stock < 0 && !I.cant_discount && I.item && I.cost > 1)
+ sales_items += I
for(var/datum/uplink_item/I in last)
if(!uplink_items[I.category])
@@ -29,6 +32,26 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
uplink_items[I.category] += I
+ 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/discount = 0.5
+ A.limited_stock = 1
+ I.refundable = FALSE
+ A.refundable = FALSE
+ if(A.cost >= 20)
+ 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 += " Only [A.limited_stock] in stock. Normally costs [initial(A.cost)] TC. All sales final"
+ A.item = I.item
+
+ if(!uplink_items[A.category])
+ uplink_items[A.category] = list()
+
+ uplink_items[A.category] += A
+
return uplink_items
/datum/nano_item_lists
@@ -51,22 +74,28 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
var/list/excludefrom = list() //Empty list does nothing. Place the name of gamemode you don't want this item to be available in here. This is so you dont have to list EVERY mode to exclude something.
var/list/job = null
var/surplus = 100 //Chance of being included in the surplus crate (when pick() selects it)
+ var/cant_discount = FALSE
+ var/limited_stock = -1 // Can you only buy so many? -1 allows for infinite purchases
var/hijack_only = FALSE //can this item be purchased only during hijackings?
var/refundable = FALSE
var/refund_path = null // Alternative path for refunds, in case the item purchased isn't what is actually refunded (ie: holoparasites).
var/refund_amount // specified refund amount in case there needs to be a TC penalty for refunds.
/datum/uplink_item/proc/spawn_item(var/turf/loc, var/obj/item/uplink/U)
+
if(hijack_only)
if(!(locate(/datum/objective/hijack) in usr.mind.objectives))
to_chat(usr, "The Syndicate lacks resources to provide you with this item.")
return
+
if(item)
U.uses -= max(cost, 0)
U.used_TC += cost
+ limited_stock--
feedback_add_details("traitor_uplink_items_bought", name)
return new item(loc)
+
/datum/uplink_item/proc/description()
if(!desc)
// Fallback description
@@ -117,8 +146,16 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
*/
//Work in Progress, job specific antag tools
+//Discounts (dynamically filled above)
+
+/datum/uplink_item/discounts
+ category = "Discounted Gear"
+
+//Job specific gear
+
/datum/uplink_item/jobspecific
category = "Job Specific Tools"
+ cant_discount = TRUE
//Clown
/datum/uplink_item/jobspecific/clowngrenade
@@ -1483,6 +1520,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
cost = 20
item = /obj/item/storage/box/syndicate
excludefrom = list(/datum/game_mode/nuclear)
+ cant_discount = TRUE // You fucking wish
/datum/uplink_item/badass/surplus_crate/spawn_item(turf/loc, obj/item/uplink/U)
var/obj/structure/closet/crate/C = new(loc)
diff --git a/code/game/objects/items/devices/uplinks.dm b/code/game/objects/items/devices/uplinks.dm
index 1c3124a74cb..ffbae3d3789 100644
--- a/code/game/objects/items/devices/uplinks.dm
+++ b/code/game/objects/items/devices/uplinks.dm
@@ -65,6 +65,8 @@ var/list/world_uplinks = list()
category_items = 0
for(var/datum/uplink_item/I in uplink_items[category])
+ if(I.limited_stock == 0)
+ continue
if(I.cost > uses)
continue
if(I.job && I.job.len)
@@ -90,6 +92,8 @@ var/list/world_uplinks = list()
for(var/category in uplink_items)
nano[++nano.len] = list("Category" = category, "items" = list())
for(var/datum/uplink_item/I in uplink_items[category])
+ if(I.limited_stock == 0)
+ continue
if(I.job && I.job.len)
if(!(I.job.Find(job)))
continue
From 609d42923336ced79305393a0e021c4f393c15a0 Mon Sep 17 00:00:00 2001
From: AzuleUtama <44248086+AzuleUtama@users.noreply.github.com>
Date: Wed, 21 Nov 2018 00:00:17 +0000
Subject: [PATCH 2/5] Got things working properly... ish
---
code/datums/uplink_item.dm | 17 +++++++++++++----
code/game/objects/items/devices/uplinks.dm | 5 +++++
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/code/datums/uplink_item.dm b/code/datums/uplink_item.dm
index fee33786131..464deb87822 100644
--- a/code/datums/uplink_item.dm
+++ b/code/datums/uplink_item.dm
@@ -3,6 +3,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
/proc/get_uplink_items(var/job = null)
var/list/uplink_items = list()
var/list/sales_items = list()
+ var/newreference = 1
if(!uplink_items.len)
var/list/last = list()
@@ -40,12 +41,15 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
I.refundable = FALSE
A.refundable = FALSE
if(A.cost >= 20)
- discount *= 0.5
- A.cost = max(round(A.cost * discount),1)
+ discount *= 0.5 // If the item costs 20TC 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.reference = "DIS[newreference]"
A.desc += " Only [A.limited_stock] in stock. Normally costs [initial(A.cost)] TC. All sales final"
A.item = I.item
+ newreference++
if(!uplink_items[A.category])
uplink_items[A.category] = list()
@@ -91,7 +95,6 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
if(item)
U.uses -= max(cost, 0)
U.used_TC += cost
- limited_stock--
feedback_add_details("traitor_uplink_items_bought", name)
return new item(loc)
@@ -155,7 +158,6 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
/datum/uplink_item/jobspecific
category = "Job Specific Tools"
- cant_discount = TRUE
//Clown
/datum/uplink_item/jobspecific/clowngrenade
@@ -235,6 +237,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
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.
+ cant_discount = TRUE
//Janitor
@@ -593,6 +596,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
gamemodes = list(/datum/game_mode/nuclear)
surplus = 0
refundable = TRUE
+ cant_discount = TRUE
/datum/uplink_item/dangerous/foamsmg
name = "Toy Submachine Gun"
@@ -630,6 +634,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
cost = 12
refund_path = /obj/item/guardiancreator/tech/choose
refundable = TRUE
+ cant_discount = TRUE
// Ammunition
@@ -800,6 +805,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
cost = 17
excludefrom = list(/datum/game_mode/nuclear)
refundable = TRUE
+ cant_discount = TRUE
/datum/uplink_item/stealthy_weapons/throwingweapons
name = "Box of Throwing Weapons"
@@ -1264,6 +1270,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
item = /obj/item/stack/telecrystal
cost = 1
surplus = 0
+ cant_discount = TRUE
/datum/uplink_item/device_tools/telecrystal/five
name = "5 Raw Telecrystals"
@@ -1445,6 +1452,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
item = /obj/item/storage/box/syndicate
cost = 20
excludefrom = list(/datum/game_mode/nuclear)
+ cant_discount = TRUE
/datum/uplink_item/badass/syndiecards
name = "Syndicate Playing Cards"
@@ -1478,6 +1486,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
reference = "BABA"
item = /obj/item/toy/syndicateballoon
cost = 20
+ cant_discount = TRUE
/datum/uplink_item/implants/macrobomb
name = "Macrobomb Implant"
diff --git a/code/game/objects/items/devices/uplinks.dm b/code/game/objects/items/devices/uplinks.dm
index ffbae3d3789..680da478243 100644
--- a/code/game/objects/items/devices/uplinks.dm
+++ b/code/game/objects/items/devices/uplinks.dm
@@ -136,7 +136,12 @@ var/list/world_uplinks = list()
/obj/item/uplink/proc/buy(var/datum/uplink_item/UI, var/reference)
if(!UI)
return
+ if(UI.limited_stock == 0)
+ to_chat(usr, "You have redeemed this discount already!")
+ return
UI.buy(src,usr)
+ if(UI.limited_stock > 0) // only decrement it if it's actually limited
+ UI.limited_stock--
SSnanoui.update_uis(src)
/* var/list/L = UI.spawn_item(get_turf(usr),src)
From 3bf5c482cec5642e6ab475d7b3ba43b8d04823b5 Mon Sep 17 00:00:00 2001
From: AzuleUtama <44248086+AzuleUtama@users.noreply.github.com>
Date: Fri, 23 Nov 2018 12:03:59 +0000
Subject: [PATCH 3/5] Small changes and merged with master following some
recent additions to uplink items
Keeping it updated alongside master.
---
code/datums/uplink_item.dm | 3 ++-
code/game/objects/items/devices/uplinks.dm | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/code/datums/uplink_item.dm b/code/datums/uplink_item.dm
index 772a8068764..8c800af488a 100644
--- a/code/datums/uplink_item.dm
+++ b/code/datums/uplink_item.dm
@@ -47,7 +47,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
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.reference = "DIS[newreference]"
- A.desc += " Only [A.limited_stock] in stock. Normally costs [initial(A.cost)] TC. All sales final"
+ A.desc += " Limit of [A.limited_stock] per uplink. Normally costs [initial(A.cost)] TC."
A.item = I.item
newreference++
@@ -1355,6 +1355,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
item = /obj/item/implanter/uplink
cost = 14
surplus = 0
+ cant_discount = TRUE
/datum/uplink_item/implants/storage
name = "Storage Implant"
diff --git a/code/game/objects/items/devices/uplinks.dm b/code/game/objects/items/devices/uplinks.dm
index 680da478243..fac5c01cf94 100644
--- a/code/game/objects/items/devices/uplinks.dm
+++ b/code/game/objects/items/devices/uplinks.dm
@@ -137,7 +137,7 @@ var/list/world_uplinks = list()
if(!UI)
return
if(UI.limited_stock == 0)
- to_chat(usr, "You have redeemed this discount already!")
+ to_chat(usr, "You have redeemed this discount already.")
return
UI.buy(src,usr)
if(UI.limited_stock > 0) // only decrement it if it's actually limited
From ad03363936ee24d9e1c2be003ba64c5b82adc62b Mon Sep 17 00:00:00 2001
From: AzuleUtama <44248086+AzuleUtama@users.noreply.github.com>
Date: Fri, 23 Nov 2018 21:37:28 +0000
Subject: [PATCH 4/5] stopped random potentially picking a discount after its
been bought
Fixed a very unlikely to occur bug, also got rid of old code that served no purpose.
---
code/game/objects/items/devices/uplinks.dm | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/code/game/objects/items/devices/uplinks.dm b/code/game/objects/items/devices/uplinks.dm
index fac5c01cf94..d0c0622d1e5 100644
--- a/code/game/objects/items/devices/uplinks.dm
+++ b/code/game/objects/items/devices/uplinks.dm
@@ -65,8 +65,6 @@ var/list/world_uplinks = list()
category_items = 0
for(var/datum/uplink_item/I in uplink_items[category])
- if(I.limited_stock == 0)
- continue
if(I.cost > uses)
continue
if(I.job && I.job.len)
@@ -92,8 +90,6 @@ var/list/world_uplinks = list()
for(var/category in uplink_items)
nano[++nano.len] = list("Category" = category, "items" = list())
for(var/datum/uplink_item/I in uplink_items[category])
- if(I.limited_stock == 0)
- continue
if(I.job && I.job.len)
if(!(I.job.Find(job)))
continue
@@ -113,7 +109,7 @@ var/list/world_uplinks = list()
var/list/random_items = new
for(var/IR in ItemsReference)
var/datum/uplink_item/UI = ItemsReference[IR]
- if(UI.cost <= uses)
+ if(UI.cost <= uses && UI.limited_stock != 0)
random_items += UI
return pick(random_items)
From 3c1c251fd36de883b417dc12df0ae543b9a97d17 Mon Sep 17 00:00:00 2001
From: AzuleUtama <44248086+AzuleUtama@users.noreply.github.com>
Date: Fri, 23 Nov 2018 23:01:12 +0000
Subject: [PATCH 5/5] discount gear now can't be picked in surplus crates
---
code/datums/uplink_item.dm | 1 +
1 file changed, 1 insertion(+)
diff --git a/code/datums/uplink_item.dm b/code/datums/uplink_item.dm
index 8c800af488a..03a36cee7ac 100644
--- a/code/datums/uplink_item.dm
+++ b/code/datums/uplink_item.dm
@@ -48,6 +48,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
A.job = null // If you get a job specific item selected, actually lets you buy it in the discount section
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
newreference++