Author Topic: Getting a spell effect text into the dialog.tlk  (Read 1763 times)

Offline plainab

  • Sasha al'Therin
  • Planewalker
  • *****
  • Posts: 491
    • Infinity Engine Modding
Getting a spell effect text into the dialog.tlk
« on: April 11, 2009, 06:11:47 PM »
Let's say that I have a spell which as one of its effects will display a text string.  Should the text that I want to display not be present currently within the game, what are my options as far as getting it into the game?  I would prefer a method that would allow for a future possibility of language translation.

String_Set only changes existing stings so that is out...

I would think that I would need to copy the file and patch the effect with a write_ascii or write_ascii_evaluate?  If so, doesn't that require a text string within the tp2 and not a call to a tra reference?

Or is there a better method?

Any help would be appreciated...
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altherin.webs.com

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: Getting a spell effect text into the dialog.tlk
« Reply #1 on: April 11, 2009, 06:27:00 PM »
SAY where ~my string~

If "my string" does not exist in dialog.tlk, it is added and the strref written at 'where,' else the existing strref is used.

It accepts a TRA @ reference, so you can SAY eff_off + 0x4 @1 and then handle it in your mod TRA/TRB.

Offline plainab

  • Sasha al'Therin
  • Planewalker
  • *****
  • Posts: 491
    • Infinity Engine Modding
Re: Getting a spell effect text into the dialog.tlk
« Reply #2 on: April 11, 2009, 10:49:26 PM »
So SAY can work with an offset number not just a predefined word?

I'll have to try it out...

I'll be back if I have any problems.  It'll be a few days though. I gotta finish up some other parts before I work on the actual tp2 structure...

My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altherin.webs.com

Offline GeN1e

  • Planewalker
  • *****
  • Posts: 267
  • Gender: Male
Re: Getting a spell effect text into the dialog.tlk
« Reply #3 on: April 12, 2009, 01:41:42 PM »
REPLACE, I believe, is the function best suited for this.

WRITE_LENGTH where 9999
REPLACE ~9999~ ~new text line~

Though I haven't tried that myself. My needs were slightly different, so I went with

<<<<<<<<file.2da
name_ref1
name_ref2
>>>>>>>>
COPY ~file.2da~ ~somewhere~
REPLACE ~name_ref1~ ~this is what shall get planted into dialog.tlk...~
REPLACE ~name_ref2~ ~...leaving file.2da with new string values instead of 'name_ref's~

Offline plainab

  • Sasha al'Therin
  • Planewalker
  • *****
  • Posts: 491
    • Infinity Engine Modding
Re: Getting a spell effect text into the dialog.tlk
« Reply #4 on: April 12, 2009, 04:26:22 PM »
No that definitely won't work. I'm not even doing anything with 2da files.  I'm actually referring to the spell effect opcode 139 in IWD+HOW+TOTLM which is the DisplayString effect.  I'm all setup to try devSin's suggestion and will do so once I get my game cleaned up from all the mod work.  I'll be back to report on that soon... shouldn't take too much longer...
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altherin.webs.com

Offline plainab

  • Sasha al'Therin
  • Planewalker
  • *****
  • Posts: 491
    • Infinity Engine Modding
Re: Getting a spell effect text into the dialog.tlk
« Reply #5 on: April 12, 2009, 04:51:29 PM »
I just tried your suggestion devSin.  It didn't work.  At least the following didn't work

do note that the custom file was previously copied from the mod dir to the override in a mass directory copy
Code: [Select]
COPY ~override/ab_r8h1.spl~ ~override~
 READ_LONG 0x64 ~ext_off~
 READ_SHORT 0x68 ~ext_num~
 FOR (x=0;x<%ext_num%;x+=1) BEGIN
  READ_SHORT (%ext_off% + (%x% * 40) + 0x1e) ~fx_num~
  READ_SHORT (%ext_off% + (%x% * 40) + 0x20) ~fx_off~
  FOR (y=0;y<%fx_num%;y+=1) BEGIN
   READ_SHORT (%fx_off% + (%y% * 48) + 0x0) ~opcode~
   PATCH_IF (%opcode% = 139) BEGIN
    SAY (%fx_off% + (%y% * 48) + 0x4) @3
   END
  END
 END
BUT_ONLY_IF_IT_CHANGES
Wonders out loud to self.... If I did a SAY on the description and put in my text there (it's not going to be seen so I don't care if it is there) could I then re-read my file and apply the strref then?  I'll go try....
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altherin.webs.com

Offline plainab

  • Sasha al'Therin
  • Planewalker
  • *****
  • Posts: 491
    • Infinity Engine Modding
Re: Getting a spell effect text into the dialog.tlk
« Reply #6 on: April 12, 2009, 05:19:51 PM »
Got it... found out my problem.  The IESDP is off...
This is found in the extended header portion
Quote
0x001e     2 (word)     Count of feature blocks
0x0020    2 (word)    Offset to feature blocks
It turns out that 0x20 within the extended header is actually an index number into the total effect blocks

I needed to read
Quote
0x006a     4 (dword)     Feature Block Table offset
first before I could get to the correct effect.

Now that I've done that I'm sure that what devSin suggested would work. However, I've already modified things to change the description entry and then pull the strref from there.
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altherin.webs.com

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: Getting a spell effect text into the dialog.tlk
« Reply #7 on: April 12, 2009, 07:19:01 PM »
That's correct. 0x6a contains the offset from the start of the file to the effects list (which may be separated into any number of abilities), and 0x20 into the ability structure is the index of the start of the effects for this ability (for a spell with no global effects, the first ability would have 0, the second would have the number of effects of the first ability, etc.). So your calculation would be fx_off + ab_fx_index * 0x30 to find the effects list for the ability you're working with.

SAY will work. What you're trying to do is exactly what it's designed for. You can also use it in places where you'd normally write an strref but don't want to look up the actual strref (say if you had to use the string "Imoen"; if you don't want to find an occurrence of Imoen in dialog.tlk, you can just use SAY where ~Imoen~ instead of WRITE_LONG where strref and WeiDU will gladly find the first "Imoen" string in dialog.tlk and write the strref of that string).

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: