Text string variable replacement

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

Text string variable replacement

Post 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.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Text string variable replacement

Post 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.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Text string variable replacement

Post 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.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Text string variable replacement

Post 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.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Text string variable replacement

Post 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.

R.D.
Posts: 379
Joined: Fri Oct 07, 2016 10:41 am

Re: Text string variable replacement

Post 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.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Text string variable replacement

Post by Interkarma »

This is great information Allofich, thanks for looking into that. :)

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Text string variable replacement

Post 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.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Text string variable replacement

Post 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.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

Post Reply