Page 1 of 1

Text string variable replacement

Posted: Tue Aug 29, 2017 10:04 pm
by Hazelnut
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.

Re: Text string variable replacement

Posted: Tue Aug 29, 2017 10:14 pm
by Interkarma
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.

Re: Text string variable replacement

Posted: Tue Sep 05, 2017 7:34 pm
by Hazelnut
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.

Re: Text string variable replacement

Posted: Tue Sep 12, 2017 11:13 pm
by Hazelnut
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.

Re: Text string variable replacement

Posted: Tue Sep 12, 2017 11:23 pm
by Interkarma
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.

Re: Text string variable replacement

Posted: Wed Sep 13, 2017 12:12 pm
by R.D.
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.

Re: Text string variable replacement

Posted: Wed Sep 13, 2017 10:53 pm
by Interkarma
This is great information Allofich, thanks for looking into that. :)

Re: Text string variable replacement

Posted: Wed Sep 13, 2017 10:58 pm
by Hazelnut
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.

Re: Text string variable replacement

Posted: Sun Sep 17, 2017 7:51 pm
by Hazelnut
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.