Page 1 of 4

Closed: House and Ship information

Posted: Mon Jan 29, 2018 12:16 am
by Hazelnut
I need the following information, and I suspect it will probably need reverse engineering from the classic binary. (in priority order)

1) How is the list of houses for sale created?

2) How is a place defined as a seaport in the datafiles, and so allows a ship to be purchased?

3) What are the houses for sale you see around in classic for, since they don't seem to appear on the house purchase list.

4) When given a house as a reward for a quest, can you choose or is it a specific/random house? (and which place is it in?)

Will need this info to round out banking.

Thanks.

Re: Open: House and Ship information

Posted: Wed Jan 31, 2018 3:30 pm
by R.D.
I'll answer what I know so far.
4) When given a house as a reward for a quest, can you choose or is it a specific/random house? (and which place is it in?)
You mean the house given by the knightly orders, right? As far as I know it is a random house chosen from the same list of houses that you can buy from. It will be a house in the location you are in when you talk to the NPC to receive it.
3) What are the houses for sale you see around in classic for, since they don't seem to appear on the house purchase list.
Are you sure? The original game seems to create the list of houses to sell by iterating over all the buildings in a location and collecting up the ones that have a building type of 1, which is the HouseForSale type.

A couple additional things

1) The sale price of a house/ship when you are selling it to the bank is

PurchasePrice - 15 * PurchasePrice / 100

The purchase price for each is recorded in the Savevars file, at offsets 174D (house) and 1751 (ship), as 4-byte values.

2) The player's purchased house and ship are stored in the player's character record in classic. (They're already identified in the character record in DF Unity, but not used.) I think they are the record ID (offset 31 for all game objects) of the house or ship that was purchased. I don't know how those record IDs are created. I think the same value is in the building record, split across the "sector" and "LocationId" values in DaggerfallUnity, which are one 32-bit combined value in classic. I was going to combine these once before but Interkarma had an objection to doing that because I think he was worried it would interfere with something he had implemented, but I don't remember the details.

Re: Open: House and Ship information

Posted: Wed Jan 31, 2018 4:47 pm
by Hazelnut
Thanks for the info. So the sale price = buy price * 0.85 which is what I've observed.

I based my thought that house for sale are not used for list of houses in the bank on finding one near a bank and then no house in the list looking like it. I could be mistaken or maybe it doesn't use all the houses. I'll check again tonight.

Re: Open: House and Ship information

Posted: Fri Feb 02, 2018 1:25 pm
by R.D.
2) How is a place defined as a seaport in the datafiles, and so allows a ship to be purchased?
I think this one is the 47th byte in the ExteriorData read for locations.

Right now it's in the dfLocation.Exterior.ExteriorData.Unknown2 byte array. The bytes are read in MapsFile.cs, line 1063.

If you change ReadBytes(7) to ReadBytes(5), and then read the next byte, that byte you just read should be it. If it's 0, the location isn't a "port town" and doesn't sell ships. If it's not 0, it does sell ships.

Re: Open: House and Ship information

Posted: Fri Feb 02, 2018 7:13 pm
by Hazelnut
Thanks for the info on seaports, that's great. I'll add the check when I do some more work on ship purchasing.

Regarding the houses for sale, I tested again and found that the houses can change textures. No idea what prompts that to occur, and I can't repeat it again but that explains why I couldn't find it in the for sale list at the bank. Sounds like creating the list will be relatively easy then.

Re: Open: House and Ship information

Posted: Sat Feb 03, 2018 5:43 pm
by R.D.
The price of houses seems to be 5 * the radius, which is in the 3d model header. It's read in line 563 of Arch3dFile.cs.

Re: Open: House and Ship information

Posted: Sat Feb 03, 2018 6:51 pm
by Hazelnut
Thanks for the info, I was wondering that.

I think I am going to need some guidance to load the spinning 3d model, I have not enough knowledge of how the DF data is turned into 3d models onscreen.

I did add code that searched the current location building directory for type = for sale, but only got 1 or 2 buildings so I think that must be the wrong approach.

Re: Open: House and Ship information

Posted: Sat Feb 03, 2018 10:45 pm
by Interkarma
I can help with loading the model. Just let me know where you're up to and we'll go from there. Also have a gander at Nystul's dungeon automap UI. It has a good approach to combining 3D geometry with the UI.

Re: Open: House and Ship information

Posted: Sat Feb 03, 2018 10:46 pm
by Interkarma
R.D. wrote:The price of houses seems to be 5 * the radius, which is in the 3d model header. It's read in line 563 of Arch3dFile.cs.
Nice find! I was curious how houses were priced. :)

Re: Open: House and Ship information

Posted: Sat Feb 03, 2018 11:13 pm
by Hazelnut
Interkarma wrote:I can help with loading the model. Just let me know where you're up to and we'll go from there. Also have a gander at Nystul's dungeon automap UI. It has a good approach to combining 3D geometry with the UI.
I have a BuildingSummary object with a buildingKey obtained from the building directory.

And no idea what to do next. :D I assume I have to load the correct mesh or something.. :oops:

Thanks for the pointer, I will take a look at that automap class and figure it out.