Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions code/modules/cargo/bounties/mech.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,3 @@
name = "Durand"
reward = 20000
wanted_types = list(/obj/mecha/combat/durand)

/datum/bounty/item/mech/phazon
name = "Phazon"
reward = 50000
wanted_types = list(/obj/mecha/combat/phazon)
6 changes: 3 additions & 3 deletions code/modules/cargo/console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
obj_flags &= ~EMAGGED

/obj/machinery/computer/cargo/proc/get_export_categories()
var/cat = EXPORT_CARGO
. = EXPORT_CARGO
if(contraband)
cat |= EXPORT_CONTRABAND
. |= EXPORT_CONTRABAND
if(obj_flags & EMAGGED)
cat |= EXPORT_EMAG
. |= EXPORT_EMAG

/obj/machinery/computer/cargo/emag_act(mob/user)
if(obj_flags & EMAGGED)
Expand Down
57 changes: 24 additions & 33 deletions code/modules/cargo/exports.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* How it works:
The shuttle arrives at CentCom dock and calls sell(), which recursively loops through all the shuttle contents that are unanchored.

Each object in the loop is checked for applies_to() of various export datums, except the invalid ones.
*/

Expand All @@ -19,19 +19,21 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they
then the player gets the profit from selling his own wasted time.
*/

#define NO_LIMIT INFINITY

// Simple holder datum to pass export results around
/datum/export_report
var/list/exported_atoms = list() //names of atoms sold/deleted by export
var/list/total_amount = list() //export instance => total count of sold objects of its type, only exists if any were sold
var/list/total_value = list() //export instance => total value of sold objects

// external_report works as "transaction" object, pass same one in if you're doing more than one export in single go
/proc/export_item_and_contents(atom/movable/AM, allowed_categories = EXPORT_CARGO, apply_elastic = TRUE, delete_unsold = TRUE, dry_run=FALSE, datum/export_report/external_report)
/proc/export_item_and_contents(atom/movable/AM, allowed_categories = EXPORT_CARGO, apply_limit = TRUE, delete_unsold = TRUE, dry_run=FALSE, datum/export_report/external_report)
if(!GLOB.exports_list.len)
setupExports()

var/list/contents = AM.GetAllContents()

var/datum/export_report/report = external_report
if(!report) //If we don't have any longer transaction going on
report = new
Expand All @@ -45,8 +47,8 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they
for(var/datum/export/E in GLOB.exports_list)
if(!E)
continue
if(E.applies_to(thing, allowed_categories, apply_elastic))
sold = E.sell_object(thing, report, dry_run, allowed_categories , apply_elastic)
if(E.applies_to(thing, allowed_categories, apply_limit))
sold = E.sell_object(thing, report, dry_run, allowed_categories , apply_limit)
report.exported_atoms += " [thing.name]"
break
if(!dry_run && (sold || delete_unsold))
Expand All @@ -60,44 +62,30 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they
var/unit_name = "" // Unit name. Only used in "Received [total_amount] [name]s [message]." message
var/message = ""
var/cost = 100 // Cost of item, in cargo credits. Must not alow for infinite price dupes, see above.
var/k_elasticity = 1/30 //coefficient used in marginal price calculation that roughly corresponds to the inverse of price elasticity, or "quantity elasticity"
var/export_limit = NO_LIMIT //how many times this export can be sold.
var/list/export_types = list() // Type of the exported object. If none, the export datum is considered base type.
var/include_subtypes = TRUE // Set to FALSE to make the datum apply only to a strict type.
var/list/exclude_types = list() // Types excluded from export

//cost includes elasticity, this does not.
var/init_cost

//All these need to be present in export call parameter for this to apply.
var/export_category = EXPORT_CARGO

/datum/export/New()
..()
SSprocessing.processing += src
init_cost = cost
export_types = typecacheof(export_types)
exclude_types = typecacheof(exclude_types)

/datum/export/Destroy()
SSprocessing.processing -= src
return ..()

/datum/export/process()
..()
cost *= NUM_E**(k_elasticity * (1/30))
if(cost > init_cost)
cost = init_cost

// Checks the cost. 0 cost items are skipped in export.
/datum/export/proc/get_cost(obj/O, allowed_categories = NONE, apply_elastic = TRUE)
/datum/export/proc/get_cost(obj/O, allowed_categories = NONE, apply_limit = TRUE)
var/amount = get_amount(O)
if(apply_elastic)
if(k_elasticity!=0)
return round((cost/k_elasticity) * (1 - NUM_E**(-1 * k_elasticity * amount))) //anti-derivative of the marginal cost function
else
return round(cost * amount) //alternative form derived from L'Hopital to avoid division by 0
if(apply_limit && export_limit != NO_LIMIT)
return clamp(amount, 0, export_limit) * cost
else
return round(init_cost * amount)
return round(cost * amount)

// Checks the amount of exportable in object. Credits in the bill, sheets in the stack, etc.
// Usually acts as a multiplier for a cost, so item that has 0 amount will be skipped in export.
Expand All @@ -121,23 +109,23 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they
// Called only once, when the object is actually sold by the datum.
// Adds item's cost and amount to the current export cycle.
// get_cost, get_amount and applies_to do not neccesary mean a successful sale.
/datum/export/proc/sell_object(obj/O, datum/export_report/report, dry_run = TRUE, allowed_categories = EXPORT_CARGO , apply_elastic = TRUE)
var/the_cost = get_cost(O, allowed_categories , apply_elastic)
/datum/export/proc/sell_object(obj/O, datum/export_report/report, dry_run = TRUE, allowed_categories = EXPORT_CARGO , apply_limit = TRUE)
var/the_cost = get_cost(O, allowed_categories , apply_limit)
var/amount = get_amount(O)

if(amount <=0 || the_cost <=0)
if(amount <=0 || the_cost <=0 || export_limit <=0)
return FALSE

report.total_value[src] += the_cost
if(istype(O, /datum/export/material))

if(istype(src, /datum/export/material))
report.total_amount[src] += amount*MINERAL_MATERIAL_AMOUNT
else
report.total_amount[src] += amount

if(!dry_run)
if(apply_elastic)
cost *= NUM_E**(-1*k_elasticity*amount) //marginal cost modifier
if(apply_limit && export_limit != NO_LIMIT)
export_limit-= amount
SSblackbox.record_feedback("nested tally", "export_sold_cost", 1, list("[O.type]", "[the_cost]"))
return TRUE

Expand All @@ -150,7 +138,7 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they

var/total_value = ex.total_value[src]
var/total_amount = ex.total_amount[src]

var/msg = "[total_value] credits: Received [total_amount] "
if(total_value > 0)
msg = "+" + msg
Expand All @@ -166,6 +154,9 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they
msg += message

msg += "."

if(export_limit <= 0)
msg += " No further units are required."
return msg

GLOBAL_LIST_EMPTY(exports_list)
Expand Down
7 changes: 5 additions & 2 deletions code/modules/cargo/exports/gear.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,20 @@
export_types = list(/obj/item/clothing/suit/bomb_suit)

/datum/export/gear/lizardboots
cost = 350
cost = 3000
export_limit = 50
unit_name = "lizard skin boots"
export_types = list(/obj/item/clothing/shoes/cowboy/lizard)
include_subtypes = FALSE

/datum/export/gear/lizardmasterwork
cost = 1000
cost = 5000
export_limit = 10
unit_name = "Hugs-the-Feet lizard boots"
export_types = list(/obj/item/clothing/shoes/cowboy/lizard/masterwork)

/datum/export/gear/bilton
cost = 2500
export_limit = 40
unit_name = "bilton wrangler boots"
export_types = list(/obj/item/clothing/shoes/cowboy/fancy)
40 changes: 39 additions & 1 deletion code/modules/cargo/exports/large_objects.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/datum/export/large/crate
cost = 500
k_elasticity = 0
unit_name = "crate"
export_types = list(/obj/structure/closet/crate)
exclude_types = list(/obj/structure/closet/crate/large, /obj/structure/closet/crate/wooden, /obj/structure/closet/crate/secure/cheap, /obj/structure/closet/crate/secure/owned)
Expand Down Expand Up @@ -121,3 +120,42 @@
cost = 25
unit_name = "security barrier"
export_types = list(/obj/item/grenade/barrier, /obj/structure/barricade/security)

//Mecha
/datum/export/large/mech
export_types = list(/obj/mecha)
var/sellable

/datum/export/large/mech/applies_to(obj/O)
if(!..())
return FALSE

var/obj/mecha/ME = O
ME.wreckage = null // So the mech doesn't blow up in the cargo shuttle
if(sellable)
return TRUE

/datum/export/large/mech/sellable
export_types = list()
sellable = TRUE

/datum/export/large/mech/sellable/firefighter
cost = 9000
unit_name = "APLU \"Firefighter\""
export_types = list(/obj/mecha/working/ripley/firefighter)

/datum/export/large/mech/sellable/phazon
cost = 50000 // 15767 material + anomaly core. Fuck it, if you're willing to try selling one of these you should get BIG FUCKING MONEY
unit_name = "phazon"
export_types = list(/obj/mecha/combat/phazon)
export_limit = 10 //you get half of a bike if you for some reason mass produce these, diversify your holdings

/datum/export/large/mech/sellable/syndiegygax
cost = 50000 // You somehow stole a nuke op's gygax and sold it to nanotrasen. Go you.
unit_name = "captured syndicate gygax"
export_types = list(/obj/mecha/combat/gygax/dark)

/datum/export/large/mech/sellable/mauler
cost = 87500 // Whoa, momma.
unit_name = "captured mauler"
export_types = list(/obj/mecha/combat/marauder/mauler)
2 changes: 0 additions & 2 deletions code/modules/cargo/exports/manifest.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// +200 credits flat.
/datum/export/manifest_correct
cost = 200
k_elasticity = 0
unit_name = "approved manifest"
export_types = list(/obj/item/paper/fluff/jobs/cargo/manifest)

Expand All @@ -19,7 +18,6 @@
// Refunds the package cost minus the cost of crate.
/datum/export/manifest_error_denied
cost = -500
k_elasticity = 0
unit_name = "correctly denied manifest"
export_types = list(/obj/item/paper/fluff/jobs/cargo/manifest)

Expand Down
18 changes: 12 additions & 6 deletions code/modules/cargo/exports/materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,38 @@
// Materials. Nothing but plasma is really worth selling. Better leave it all to RnD and sell some plasma instead.

/datum/export/material/bananium
cost = 1000
cost = 2500
export_limit = 50
material_id = /datum/material/bananium
message = "cm3 of bananium"

/datum/export/material/diamond
cost = 500
cost = 1000
export_limit = 100
material_id = /datum/material/diamond
message = "cm3 of diamonds"

/datum/export/material/plasma
cost = 200
k_elasticity = 0

material_id = /datum/material/plasma
message = "cm3 of plasma"

/datum/export/material/uranium
cost = 100
cost = 400
export_limit = 300
material_id = /datum/material/uranium
message = "cm3 of uranium"

/datum/export/material/gold
cost = 125
cost = 250
export_limit = 500
material_id = /datum/material/gold
message = "cm3 of gold"

/datum/export/material/silver
cost = 50
cost = 100
export_limit = 500
material_id = /datum/material/silver
message = "cm3 of silver"

Expand Down Expand Up @@ -87,6 +92,7 @@

/datum/export/material/hot_ice
cost = 400
export_limit = 250
message = "cm3 of Hot Ice"
material_id = /datum/material/hot_ice
export_types = list(/obj/item/stack/sheet/hot_ice)
Expand Down
Loading