I've been trying to figure out how Daggerfall sets the prices for books. Here's what I've found so far:
[*]Each book's maximum price is defined at offset 0xE0 in its file (2 bytes).
[*]In-game book prices seem to be defined by a RNG of some sort. I've tried starting multiple new games and the prices remain consistent. Therefore, we can assume the seed is the same every time.
Has anyone else looked into this before? If so, please share your insights.
Book prices
- numidium3rd
- Posts: 187
- Joined: Sun Mar 25, 2018 12:34 am
- Location: United States
Book prices
Nexus DFU Mods:
https://www.nexusmods.com/daggerfalluni ... user+files
Mod source repo:
https://github.com/numidium/dfu-mods
https://www.nexusmods.com/daggerfalluni ... user+files
Mod source repo:
https://github.com/numidium/dfu-mods
-
- Posts: 379
- Joined: Fri Oct 07, 2016 10:41 am
Re: Book prices
I've got the book worth values figured out.
Book worth is gotten like:
Each book file has its title at the beginning, so it's the first 4 characters of the title that determine the worth.
Example: For "Notes for Redguard History", the first 4 characters are "Note", or 4E 6F 74 65, which is 1702129486 in decimal. Feed that in to the above as the random seed and you'll get the result, 597 gold.
Book worth is gotten like:
Code: Select all
DFRandom.Seed = (first 4 bytes of book file as a uint);
int worth = DFRandom.random_range_inclusive(300, 800);
Example: For "Notes for Redguard History", the first 4 characters are "Note", or 4E 6F 74 65, which is 1702129486 in decimal. Feed that in to the above as the random seed and you'll get the result, 597 gold.
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Book prices
I actually thought we'd already handled this with the mercantile code formulas, but that's based on the fixed cost for all books in item templates.
Now I realise that the base price varies I will get that implemented ASAP. As ever, thanks for the classic algorithm info Allofich!
Now I realise that the base price varies I will get that implemented ASAP. As ever, thanks for the classic algorithm info Allofich!
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- numidium3rd
- Posts: 187
- Joined: Sun Mar 25, 2018 12:34 am
- Location: United States
Re: Book prices
Thanks, Allofich! Interesting that the "price" value isn't factored into the books' prices at all. I got that tidbit from UESP. Either the field is for something else (I can't imagine what) or Bethesda decided not to use it. Either way, much appreciated.
Nexus DFU Mods:
https://www.nexusmods.com/daggerfalluni ... user+files
Mod source repo:
https://github.com/numidium/dfu-mods
https://www.nexusmods.com/daggerfalluni ... user+files
Mod source repo:
https://github.com/numidium/dfu-mods
- Interkarma
- Posts: 7247
- Joined: Sun Mar 22, 2015 1:51 am
Re: Book prices
You are a genius mate. Hats off to you. Wow!R.D. wrote: ↑Fri Dec 07, 2018 11:48 am I've got the book worth values figured out.
Book worth is gotten like:
Each book file has its title at the beginning, so it's the first 4 characters of the title that determine the worth.Code: Select all
DFRandom.Seed = (first 4 bytes of book file as a uint); int worth = DFRandom.random_range_inclusive(300, 800);
Example: For "Notes for Redguard History", the first 4 characters are "Note", or 4E 6F 74 65, which is 1702129486 in decimal. Feed that in to the above as the random seed and you'll get the result, 597 gold.
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Book prices
Allofich, can you confirm that the Price field identified on https://en.uesp.net/wiki/Daggerfall:Book_format has no bearing on the value?
I've modified BookFile to use the method you posted instead of the bytes 0xe0-e3 which that page says is an unsigned long (UInt32) of Price, but I would like to check this is correct.
EDIT: I tested another couple and the values match classic. Kind of wierd because every book title starting with "The " has the same value.
So, UESP is wrong or this data just wasn't used in the final game. UESP is correct that the field mostly has value 1000, but also values of 10, 300, 400, 5000, and 10000 are allocated to some books. My first thought was it might have been intended as a multiplier, but that's unlikely with the high value of 10k I think. We'll probably never know what it was for.
I was also wondering if the rarity field from that page should affect the random generation of books? Sounds like it should, but maybe it's another unused data element?
I've modified BookFile to use the method you posted instead of the bytes 0xe0-e3 which that page says is an unsigned long (UInt32) of Price, but I would like to check this is correct.
EDIT: I tested another couple and the values match classic. Kind of wierd because every book title starting with "The " has the same value.
So, UESP is wrong or this data just wasn't used in the final game. UESP is correct that the field mostly has value 1000, but also values of 10, 300, 400, 5000, and 10000 are allocated to some books. My first thought was it might have been intended as a multiplier, but that's unlikely with the high value of 10k I think. We'll probably never know what it was for.
I was also wondering if the rarity field from that page should affect the random generation of books? Sounds like it should, but maybe it's another unused data element?
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods