Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds item_worth list that says how much different atoms are worth. #13367

Merged
merged 6 commits into from
Jul 3, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,18 @@
#include "code\modules\hydroponics\trays\tray_soil.dm"
#include "code\modules\hydroponics\trays\tray_tools.dm"
#include "code\modules\hydroponics\trays\tray_update_icons.dm"
#include "code\modules\item_worth\_helpers.dm"
#include "code\modules\item_worth\item_worth.dm"
#include "code\modules\item_worth\material_weapons.dm"
#include "code\modules\item_worth\materials.dm"
#include "code\modules\item_worth\reagents.dm"
#include "code\modules\item_worth\worths_list.dm"
#include "code\modules\item_worth\Value_procs\atoms.dm"
#include "code\modules\item_worth\Value_procs\mob.dm"
#include "code\modules\item_worth\Value_procs\obj.dm"
#include "code\modules\item_worth\Value_procs\obj\items.dm"
#include "code\modules\item_worth\Value_procs\obj\machinery.dm"
#include "code\modules\item_worth\Value_procs\obj\structures.dm"
#include "code\modules\library\lib_items.dm"
#include "code\modules\library\lib_machines.dm"
#include "code\modules\library\lib_readme.dm"
Expand Down
7 changes: 3 additions & 4 deletions code/datums/trading/trade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
/datum/trader/proc/get_item_value(var/trading_num)
if(!trading_items[trading_items[trading_num]])
var/type = trading_items[trading_num]
var/value = 0
//<INSERT CALCULATED COST HERE>
var/value = get_value(type)
value = round(rand(90,110)/100 * value) //For some reason rand doesn't like decimals.
trading_items[type] = value
return trading_items[trading_items[trading_num]]

Expand All @@ -140,8 +140,7 @@
return 0

var/trading_worth = get_item_value(num)
var/offer_worth = 0
//<INSERT CODE FOR DETERMINING ITEM WORTH HERE>
var/offer_worth = get_value(offer)
if(is_wanted)
offer_worth *= 2
if(!offer_worth)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/item_worth/Value_procs/atoms.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/atom/proc/Value(var/base)
return base
4 changes: 4 additions & 0 deletions code/modules/item_worth/Value_procs/mob.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/mob/living/carbon/human/Value(var/base)
. = ..()
if(species)
. *= species.rarity_value
4 changes: 4 additions & 0 deletions code/modules/item_worth/Value_procs/obj.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/obj/Value()
. = ..()
for(var/a in contents)
. += get_value(a)
35 changes: 35 additions & 0 deletions code/modules/item_worth/Value_procs/obj/items.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/obj/item/slime_extract/Value(var/base)
return base * Uses

/obj/item/ammo_casing/Value()
if(!BB)
return 1
return ..()

/obj/item/weapon/reagent_containers/Value()
. = ..()
if(reagents)
for(var/a in reagents.reagent_list)
var/datum/reagent/reg = a
. += reg.value * reg.volume
. = round(.)

/obj/item/stack/Value(var/base)
return base * amount

/obj/item/stack/material/Value()
if(!material)
return ..()
return material.value * amount

/obj/item/weapon/ore/Value()
var/material/mat = get_material_by_name(material)
if(mat)
return mat.value
return 0

/obj/item/weapon/material/Value()
return material.value * worth_multiplier

/obj/item/weapon/spacecash/Value()
return worth
5 changes: 5 additions & 0 deletions code/modules/item_worth/Value_procs/obj/machinery.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/obj/machinery/Value()
. = ..()
if(stat & BROKEN)
. *= 0.5
. = round(.)
5 changes: 5 additions & 0 deletions code/modules/item_worth/Value_procs/obj/structures.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/obj/structure/barricade/Value()
return material.value

/obj/structure/bed/Value()
return ..() * material.value
3 changes: 3 additions & 0 deletions code/modules/item_worth/_helpers.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//Workaround by Ginja due to the fact initial(parent_type) does not work.

#define PARENT(x) text2path(replacetext("[x]", regex("/\[^/\]+$"), ""))
13 changes: 13 additions & 0 deletions code/modules/item_worth/item_worth.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/proc/get_value(atom/A) // A can be either type *or* instance; ie get_value(/obj) is valid, as is get_value(new /obj)
var/atom/t = ispath(A) ? A : A.type
while(!(t in worths)) // Find the first parent that is in the list
t = PARENT(t)
if(!t)
return 0
var/value = worths[t]
if(value >= 0) // Value zero or greater than zero, all instances have same value
return value
else // Negative. If it's a path, use -x, otherwise call Value() on the instance
if(ispath(A))
return -value
return A.Value(-value)
32 changes: 32 additions & 0 deletions code/modules/item_worth/material_weapons.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/obj/item/weapon/material
var/worth_multiplier = 1

//Rule of thumb is: worth more than the parts put in
//Finished good is worth more than its individual parts

/obj/item/weapon/material/kitchen
worth_multiplier = 1.1

/obj/item/weapon/material/butterfly
worth_multiplier = 8

/obj/item/weapon/material/harpoon
worth_multiplier = 15

/obj/item/weapon/material/hatchet
worth_multiplier = 6

/obj/item/weapon/material/minihoe
worth_multiplier = 6

/obj/item/weapon/material/scythe
worth_multiplier = 20

/obj/item/weapon/material/sword
worth_multiplier = 30

/obj/item/weapon/material/twohanded/fireaxe
worth_multiplier = 31

/obj/item/weapon/material/twohanded/spear
worth_multiplier = 7 //blade + stuff
74 changes: 74 additions & 0 deletions code/modules/item_worth/materials.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/material
var/value = 1

/material/uranium
value = 100

/material/diamond
value = 70

/material/gold
value = 40

/material/silver
value = 35

/material/phoron
value = 200

/material/stone/marble
value = 4

/material/steel
value = 4

/material/diona
value = 5

/material/steel/holographic
value = 0

/material/plasteel
value = 12

/material/plasteel/titanium
value = 10

/material/glass/reinforced
value = 2

/material/glass/phoron
value = 30

/material/glass/phoron/reinforced
value = 40

/material/osmium
value = 30

/material/tritium
value = 300

/material/mhydrogen
value = 100

/material/platinum
value = 80

/material/iron
value = 5

/material/voxalloy
value = 100

/material/wood
value = 3

/material/wood/holographic
value = 0

/material/cardboard
value = 0

/material/leather
value = 3