Does Each Gold Piece Or Arrow In A Stack Have Their Own UID?

Post here if you need help getting started with Daggerfall Unity or just want to clarify a potential bug. Questions about playing or modding classic Daggerfall should be posted to Community.
Post Reply
User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Does Each Gold Piece Or Arrow In A Stack Have Their Own UID?

Post by Magicono43 »

This might not be the place for this sort of coding related question, but it relates to something I asked recently in the Modder Discussion board. That being, does each individual gold coin, arrow, whatever in a stack have it's own unique UID? Like could you take every individual piece of gold from a stack of 100,000 pieces and see that it has a different UID from each other one? From how I have seen how the "DaggerfallUnityItem" objects are created this would suggest to me that this is the case.

I know it sounds ridiculous since the UIDs are based of a Ulong type, so it would require like 19 Quintillion or whatever to overflow the value, but would this possibly be of any concern in a game that went on long enough? Speaking of that as well, when is the UID counter reset to 0, at the start of a new game, or is it ever? Thanks.

User avatar
pango
Posts: 3359
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Does Each Gold Piece Or Arrow In A Stack Have Their Own UID?

Post by pango »

From what I understand, player's gold pieces are not reified as items, they're just an int (PlayerEntity.GoldPieces); They're only items in other contexts (loot gold pieces, quest rewards,...)
Arrows (and reified gold pieces) are stacked, so that's the stack that has one UID, and a number of arrows/gold pieces (its stackCount).
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Does Each Gold Piece Or Arrow In A Stack Have Their Own UID?

Post by Magicono43 »

pango wrote: Sat Jan 30, 2021 4:08 pm From what I understand, player's gold pieces are not reified as items, they're just an int (PlayerEntity.GoldPieces); They're only items in other contexts (loot gold pieces, quest rewards,...)
Arrows (and reified gold pieces) are stacked, so that's the stack that has one UID, and a number of arrows/gold pieces (its stackCount).
Hmm, I can obviously check this with debug tools myself, but maybe you know the answer. So what happens when you split a stack? Does the stack get a new UID essentially? Also, I know this does not normally happen, but what happens if you stack items that are the same enough to stack, but have different properties from one another, such as if you would stack a red flower that has half the current condition value of another? I assume the properties of one of them just overrides the properties of the other when they become a single stack?

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Does Each Gold Piece Or Arrow In A Stack Have Their Own UID?

Post by Magicono43 »

I think I answered my own question, apparently it does create an entirely new item when you split a stack. Which would also suggest that a stack is just an item, but with a "stack count" of whatever number, but likely all the same properties of whatever original item gets created.
Capture.JPG
Capture.JPG (40.59 KiB) Viewed 709 times

User avatar
pango
Posts: 3359
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Does Each Gold Piece Or Arrow In A Stack Have Their Own UID?

Post by pango »

Right, and put the new split stack in put the same container as the original stack; It's up to the caller to move it elsewhere, or whatever it wants.

And ItemCollection.FindExistingStack(item) finds a stack a given item could be added to.
The rules may depend on the type of item, but generally speaking you can only stack together items that are indistinguishable from one another.
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Does Each Gold Piece Or Arrow In A Stack Have Their Own UID?

Post by Magicono43 »

pango wrote: Sat Jan 30, 2021 4:31 pm Right, and put the new split stack in put the same container as the original stack; It's up to the caller to move it elsewhere, or whatever it wants.

And ItemCollection.FindExistingStack(item) finds a stack a given item could be added to.
The rules may depend on the type of item, but generally speaking you can only stack together items that are indistinguishable from one another.
Yeah, so I guess in the current implementation of that method than item conditions would not be considered, and probably whatever one comes first would take precedence in that property, unless I added another consideration to the if-statement that specifically checked for current condition values to be equal to one another. Interesting how these things work when you look at them under the hood.

User avatar
pango
Posts: 3359
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Does Each Gold Piece Or Arrow In A Stack Have Their Own UID?

Post by pango »

I think that's the first thing I worked on in Daggerfall Unity code :)
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Does Each Gold Piece Or Arrow In A Stack Have Their Own UID?

Post by Magicono43 »

pango wrote: Sat Jan 30, 2021 4:39 pm I think that's the first thing I worked on in Daggerfall Unity code :)
Damn, I guess I found the perfect person to answer my question then, lol. It's a very interesting way that it all works, now knowing how stacks of items work, it's a lot less likely than I thought for there to be any potential long-term overflow issues for UIDs I suppose. I still worry about that in some of my code where I create multiple item objects just to use their data properties and discard them, but this happening hundreds of times whenever loot is generated concerns me a bit of potentially doing the overflow of UIDs though.

Post Reply