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
Conversation
for the module folder, could you use an underscore for the folder name instead of a space. Names with spaces don't work that well on Linux. |
I had trouble with git mv so I decided to manually rename it. |
this will need squashing before merge at the very least |
return item_worth | ||
|
||
/obj/structure/Destroy() | ||
station_damage_score += get_worth() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there not a more applicable proc than Destroy()? This will be called even if the structure is dismantled, not just if it's bashed to pieces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure to be honest. I don't think the game differentiates something getting blown up and dismantled since it ultimately QDELs them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I can cause a zillion points of damage by repeatedly creating then dismantling diamond tables, does that not count as a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose I could add something to the various dismantling procs, but I don't think that it'd work very nicely, as it were, then.
I could shelve the damage score until damage/dismantling/etc becomes more generic.
var/worth_multiplier = 1 | ||
|
||
/obj/item/weapon/material/get_worth() | ||
return material.material_worth * worth_multiplier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there no declarations for other /obj/item/weapon/material
? This should be with them if there are.
Commits squashed. |
Looks fine 👍
since could do
|
if only var/list/worths = list(
/atom/movable = 0,
/obj/foo = 5,
/obj/structure/bar = 10
)
/atom/movable/proc/get_worth()
var/atom/movable/t = type
while(!(t in worths))
t = initial(t.parent_type)
return worths[t]
// The above is roughly equivalent to having `worths` sorted most to least specific, and doing the following, except it should be significantly faster (not as fast as defining vars on the type though!)
for(var/t in worths)
if(istype(src, t))
return worths[t] That'd avoid potentially accidentally defining the obj types in the worth module, which we can't currently check for. Unfortunately doing Really what we need is a way to define a var on a type if and only if that type already exists. I'll poke around a bit, see if I can figure out some syntax that works. edit: Submitted a feature request over on the BYOND forums for something like: @datum/foo // this would error at compilation if /datum/foo is not already defined
worth = 5
@datum/bar // ditto for /datum/bar
worth = 3 |
I tried to do the parent_type thing, but yeah I ran into similar problems. I could do something like:
and then kind of parse the / and delete the end of it. I haven't been able to fiddle with the code recently though (mostly due to #13408 which I've been trying to figure out) |
item_worth = 30 | ||
|
||
/obj/item/ammo_magazine/c45m/empty | ||
item_worth = 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If get_item_worth()
includes the contents thereof, I don't know why ammo magazines would be cheaper because they started empty. Furthermore, emptying a magazine doesn't change the type path, and they're all reloadable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its mainly for use with the merchants, since they have to spreen that stuff via initial(item_worth)
Of course I don't think any uses empty casings, so it might be a moot point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a good idea to make magazines have the same worth empty or full, then add the worth of the bullets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd be a bit weird cause I don't want people buying full magazines and trading it back for profit.
I suppose I could use a secondary var but it'd again, be very odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand how that would be the case, though I'm not familiar with the mechanics of buying and selling yet. The way you are doing it now is ripe for weirdness though.
For example I can buy a full mag, dump out the bullets and the mag's worth is unaffected.
Not sure what you are referring to about needing an additional var, there must be some kind of misunderstanding going on.
EDIT: missed what you said about having to use initial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more I think about this though the more I feel like having a /datum/economy is working against the language rather than with it. I can't think of any initialization scheme that isn't really complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Datums aren't gonna work, we had this with event datums and it didn't work then either. Lists or vars, either using istype()
to find it in the list or initial(parent_type)
when that gets fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I tried it out, as you mentioned previously, it sends a compile error about being unable to modify the value.
So I'm unsure where to go from here.
To get the list implementation working, if slowly, replace:
var/atom/t = ispath(A) ? A : A.type
while(!(t in worths)) // Find the first parent that is in the list
if(t == /atom) return 0 // We hit /atom and didn't find it.
t = initial(t.parent_type)
with:
var/t = null
for(var/type in worths)
if(istype(A, type))
t = type
break
if(!t) return
This will require that specific types come before base ones (ie /obj/thing
must come before /obj
), but it'll work until initial(t.parent_type)
is fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list would be extremely large, like over 500+ entries. Would it still be viable to do it this way?
I suppose we only check this once per type, but it is still quite the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. The initial(t.parent_type)
should be reasonably fast, but the istype()
s might be quite a bit slower.
Big lists aren't a huge problem, the problem (if there is one) is going to be all the istype()
calls. Try it and see!
Ok changed to a list. Should work now. |
Fails due to the version travis uses 509.1318, while regex needs 510.1320 |
@Kearel, change |
@@ -0,0 +1,740 @@ | |||
var/list/worths = list( | |||
//REAGENT CONTAINERS | |||
/obj/item/weapon/reagent_containers/hypospray = -90, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should likely leave a comment on the top of the file explaining the negatives :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
DNM until server is running 510. |
…to mercPartOne
I wonder if we could someday overhaul the cargo points system using this. |
Probably :D |
When should we expect 510 to hit the server? |
Since the server's running 510 now this should be mergable, I believe. |
Server is 510. |
@Kearel you'll need to revert the |
Ok so I fixed the merge conflicts |
👍 |
After this I think I only have to add the merchant job and a fix to figure out how to override latespawning. |
Basically this is what I had previously, except without the extra baggage of all the other commits. I also decided to do the merchant machinery/programs later, as the comments/discussion mostly concentrated on this part primarily and I'd like to make sure that its done right.
Item worth is defined in the item worth module. There shouldn't be any code that is effected outside of said module (outside of the damage score). The proc get_worth() is defined to get said item's cost, and is overridden so that item_worth isn't changed.