Text string variable replacement

Discuss coding questions, pull requests, and implementation details.
User avatar
Hazelnut
Posts: 220
Joined: Sat Aug 26, 2017 2:46 pm

Text string variable replacement

Postby Hazelnut » Tue Aug 29, 2017 10:04 pm

Where are we with replacement of variables in text strings from TEXT.RSC? Has any work been done on this yet?

Tried a forum search but found nothing.
User avatar
Interkarma
Posts: 1979
Joined: Sun Mar 22, 2015 1:51 am

Re: Text string variable replacement

Postby Interkarma » Tue Aug 29, 2017 10:14 pm

A fair way along - not 100% by a long shot though.

These are feature-dependent and will be built out as needed. Right now most attention has gone towards text macros in quest system, which is where the bulk of them are used.

If you'd like to make a start on some these (e.g. Info popup in inventory), I'd be happy to accept that PR. Just keep in mind that a full implementation won't be possible until a few more systems are developed (e.g. spells) as these are present in Info popup as well.
User avatar
Hazelnut
Posts: 220
Joined: Sat Aug 26, 2017 2:46 pm

Re: Text string variable replacement

Postby Hazelnut » Tue Sep 05, 2017 7:34 pm

While testing item popup text replacement I noticed that some item templates for ingredients have hitPoints set to -15536 in Resources/ItemTemplates.txt

Not sure if that is just for time being or if it's an unnoticed bug with the generation of this file, so thought I would mention it.
User avatar
Hazelnut
Posts: 220
Joined: Sat Aug 26, 2017 2:46 pm

Re: Text string variable replacement

Postby Hazelnut » Tue Sep 12, 2017 11:13 pm

I've made a couple of attempts now to figure out how to populate the %hs macro - the held soul in a soul trap. I think it may be in the sub-record attached however it's not one DFU understands, can't find anything on web, and also comparing a few in hex I can't see any patterns.

Suspect this will require some DF.exe code exploring. So I'm leaving it for now, unless anyone can enlighten me.
User avatar
Interkarma
Posts: 1979
Joined: Sun Mar 22, 2015 1:51 am

Re: Text string variable replacement

Postby Interkarma » Tue Sep 12, 2017 11:23 pm

I don't know either at this stage, and have never looked. Allofich is a rockstar at finding stuff like this, he might be able to make some progress here.

In any case, this would only impact item import for now (as no soul trap or gems in DFU gameplay yet). It's OK for this to have a few limitations and work around them until later. Soul gems are scheduled for around 0.7 as part of Guilds & Services.
R.D.
Posts: 124
Joined: Fri Oct 07, 2016 10:41 am

Re: Text string variable replacement

Postby R.D. » Wed Sep 13, 2017 12:12 pm

I looked into it and think I understand it.

First of all, the held soul record is a type 0x14 record. We don't have it identified yet, so maybe you could add it to the list in SaveTree.cs.

This record has the ID of its parent record (4 bytes), which will be the soul trap's recordID, at offset 39 (0x27). This should match the soul trap's recordID, at offset 31 (0x1F) of the Soul Trap record. The parentID and recordID for saved records are in SaveTreeBaseRecord.cs but I don't think they're used for anything yet.

The soul record has its monster ID (2 bytes) at offset 27 (0x1B).

The parsing function returns the name of the monster, or "Nothing" if the soul trap doesn't have a held soul. There's also code to return "Humanoid" if the monsterID is not < 43, but I believe the game doesn't actually let you capture enemy classes.

Edit: The above should allow us to get held souls and the soul traps they belong to from classic saves, but the actual parse function in classic looks at the soul trap's "SublistHead" (also labeled in SaveTreeBaseRecord.cs) pointer. We need to somehow associate souls with soul traps that hold them.
User avatar
Interkarma
Posts: 1979
Joined: Sun Mar 22, 2015 1:51 am

Re: Text string variable replacement

Postby Interkarma » Wed Sep 13, 2017 10:53 pm

This is great information Allofich, thanks for looking into that. :)
User avatar
Hazelnut
Posts: 220
Joined: Sat Aug 26, 2017 2:46 pm

Re: Text string variable replacement

Postby Hazelnut » Wed Sep 13, 2017 10:58 pm

Yes, agreed. Honestly amazed how quick you came up with that. Will try to put it to use when I have broken the back of this selling business.
User avatar
Hazelnut
Posts: 220
Joined: Sat Aug 26, 2017 2:46 pm

Re: Text string variable replacement

Postby Hazelnut » Sun Sep 17, 2017 7:51 pm

Have implemented this now. Soul names are displaying like classic as far as I can see.

Looks odd because the record is basically just the root record with a single byte (value = 150 in all my tests) content. The SpriteIndex is actually what's used to index the monster type trapped.

Thanks again Allofich. I'd spent 3 hours trying to figure out how the save record defined the soul held and got absolutely nowhere.

Return to “Developer Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest