@@ -60,6 +60,7 @@ 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/contraband = FALSE // Export must be unlocked with multitool.
|
||||
var/emagged = FALSE // Export must be unlocked with emag.
|
||||
var/list/export_types = list() // Type of the exported object. If none, the export datum is considered base type.
|
||||
@@ -69,10 +70,33 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they
|
||||
// Used by print-out
|
||||
var/total_cost = 0
|
||||
var/total_amount = 0
|
||||
var/init_cost
|
||||
|
||||
/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 *= GLOB.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, contr = 0, emag = 0)
|
||||
return cost * get_amount(O, contr, emag)
|
||||
var/amount = get_amount(O, contr, emag)
|
||||
if(k_elasticity!=0)
|
||||
return round((cost/k_elasticity) * (1 - GLOB.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
|
||||
|
||||
// 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.
|
||||
@@ -87,7 +111,7 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they
|
||||
return FALSE
|
||||
if(!include_subtypes && !(O.type in export_types))
|
||||
return FALSE
|
||||
if(include_subtypes && (!is_type_in_list(O, export_types) || is_type_in_list(O, exclude_types)))
|
||||
if(include_subtypes && (!is_type_in_typecache(O, export_types) || is_type_in_typecache(O, exclude_types)))
|
||||
return FALSE
|
||||
if(!get_cost(O, contr, emag))
|
||||
return FALSE
|
||||
@@ -99,12 +123,17 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they
|
||||
// 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, contr = 0, emag = 0)
|
||||
var/cost = get_cost(O)
|
||||
var/the_cost = get_cost(O)
|
||||
var/amount = get_amount(O)
|
||||
total_cost += cost
|
||||
total_amount += amount
|
||||
total_cost += the_cost
|
||||
if(istype(O,/datum/export/material))
|
||||
total_amount += amount*MINERAL_MATERIAL_AMOUNT
|
||||
else
|
||||
total_amount += amount
|
||||
|
||||
cost *= GLOB.E**(-1*k_elasticity*amount) //marginal cost modifier
|
||||
SSblackbox.add_details("export_sold_amount","[O.type]|[amount]")
|
||||
SSblackbox.add_details("export_sold_cost","[O.type]|[cost]")
|
||||
SSblackbox.add_details("export_sold_cost","[O.type]|[the_cost]")
|
||||
|
||||
// Total printout for the cargo console.
|
||||
// Called before the end of current export cycle.
|
||||
|
||||
Reference in New Issue
Block a user