Jump to content


Photo

Dialogue/string patching


  • Please log in to reply
47 replies to this topic

#41 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 23 May 2009 - 02:25 PM

I'd be more interested in seeing commands (or at least standard macros) to do stuff like ADD_CONTAINER_TO_AREA or ADD_DOOR_TO_AREA or ADD_INFO_TRIGGER to replace your long sheets of code

So there is an need in those. Several times I've been thinking about sitting down and defining a few area-patching macros after seeing the question repeatedly asked.

Retired from modding.


#42 Kaeloree

Kaeloree

    Head Molder

  • Administrator
  • 9198 posts

Posted 23 May 2009 - 02:58 PM

I'm pretty sure Qwinn has a few such macros that he's said anyone can use in the PS:T Fixpack--might be worth asking him about it?

#43 Miloch

Miloch

    Barbarian

  • Modder
  • 6573 posts

Posted 09 June 2009 - 01:44 AM

Miloch, if you know the string you want the word replaced in, why not simply use STRING_SET? It takes both full strings and indexes as the first parameter.

Ok, it seems I hit another glitch here. I want to change a string of unknown index that has an associated sound clip, for example:
STRING_SET ~[TANAR'RI 01]~ [_ANAR_01] ~[TANAR'RI 01]~ [TANAR01]
Doesn't like that, or: STRING_SET "~[TANAR'RI 01]~ [_ANAR_01]" "~[TANAR'RI 01]~ [TANAR01]" or anything else I can think of offhand.

Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#44 Sasha Al'Therin

Sasha Al'Therin
  • Modder
  • 615 posts

Posted 09 June 2009 - 12:07 PM

Miloch, if you know the string you want the word replaced in, why not simply use STRING_SET? It takes both full strings and indexes as the first parameter.

Ok, it seems I hit another glitch here. I want to change a string of unknown index that has an associated sound clip, for example:
STRING_SET ~[TANAR'RI 01]~ [_ANAR_01] ~[TANAR'RI 01]~ [TANAR01]
Doesn't like that, or: STRING_SET "~[TANAR'RI 01]~ [_ANAR_01]" "~[TANAR'RI 01]~ [TANAR01]" or anything else I can think of offhand.

It doesn't like it because it can't find the sound clip within the strings data. For that, you're going to have to go back to READING the dialog.tlk file. See my initial idea/post and see the IESDP for adjustments to make. You will need to search for the matching sound clip and then use the reference number that is associated with it...

If your afraid of doing
COPY_EXISTING ~dialog.tlk~ ~dialog.tlk~
//your reads
BUT_ONLY_IF_IT_CHANGES

Then change it to
COPY_EXISTING ~dialog.tlk~ ~yourmod\dialog.tlk~
//your reads
BUT_ONLY_IF_IT_CHANGES

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-altheri...s.com/index.htm


#45 Miloch

Miloch

    Barbarian

  • Modder
  • 6573 posts

Posted 09 June 2009 - 03:41 PM

For that, you're going to have to go back to READING the dialog.tlk file.

Eh, no... I'd rather overwrite the bogus sound clips, but there's got to be a better way. The sound clips are directly linked to the strings, so this really shouldn't be difficult to do with STRING_SET or a similar command.

COPY_EXISTING ~dialog.tlk~ ~yourmod\dialog.tlk~
//your reads
BUT_ONLY_IF_IT_CHANGES

That's probably worse than copying it directly (WeiDU will make a backup anyway).

Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#46 Sasha Al'Therin

Sasha Al'Therin
  • Modder
  • 615 posts

Posted 09 June 2009 - 05:14 PM

For that, you're going to have to go back to READING the dialog.tlk file.

Eh, no... I'd rather overwrite the bogus sound clips, but there's got to be a better way. The sound clips are directly linked to the strings, so this really shouldn't be difficult to do with STRING_SET or a similar command.

COPY_EXISTING ~dialog.tlk~ ~yourmod\dialog.tlk~
//your reads
BUT_ONLY_IF_IT_CHANGES

That's probably worse than copying it directly (WeiDU will make a backup anyway).

You forget that BUT_ONLY_IF_IT_CHANGES prevents weidu from actually copying the file unless it actually changes. The file is placed into memory and read for the data. You will NOT be doing any writes, only getting the string reference number so that you can do STRING_SET strref# ~[TANAR'RI 01]~ [TANAR01] where strref# is the number that you discovered by READING the dialog.tlk

Trust me this is one thing that I KNOW will work without overwriting your dialog.tlk file. I can't stress this enough you will NOT be doing ANY WRITES so weidu will NOT copy it nor will there be a backup made...

But if you are still afraid...

Then try this out and see if it will work for you...
<<<<<<<< blank.file
>>>>>>>>
COPY ~blank.file~ ~get_strings_for_sound.txt~
 INNER_PATCH_FILE ~dialog.tlk~ BEGIN		  //read dialog.tlk as an inner_patch_file which gets thrown away and not saved
  READ_LONG 0xa strref_num
  FOR(index=0;index<%strref_num%;index+=1)BEGIN
   READ_ASCII (0x12 + (0x1a * %index%) + 0x2) sound
   PATCH_IF (~%sound%~ STRING_EQUAL_CASE ~_ANAR_01~) BEGIN  //if sound file matches what you want
	SET string_ref = %index%
	INNER_ACTION BEGIN
	 OUTER_APPEND ~get_strings_for_sound.txt~ ~Found %sound% at %string_ref%~
	END
   END
  END
BUT_ONLY_IF_IT_CHANGES

//STRING_SET_EVALUATE %string_ref% ~[TANAR'RI 01]~ [TANAR01]
If after reading the report file, there is only one instance un-comment the string_set line. If there are multiple instances and they all need changed, you can move the string_set line to where the outer_append is at...

The nature of inner_patch_file requires that it be inside of a patch so some file must be copied to get into the patch state, in this case I used an inlined empty file to use for generating a report. If it works (I don't know if inner_patch_file can handle the dialog.tlk), you could do it inside of another copy block within the same component....

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-altheri...s.com/index.htm


#47 Miloch

Miloch

    Barbarian

  • Modder
  • 6573 posts

Posted 09 June 2009 - 06:22 PM

I have a bunch of these very small, surgical changes to make, and my goal is to keep the code to a single line (maybe 3 lines at most) for each change, and not to get clever with inlined files, copying or fake-copying dialog.tlk or the like. Otherwise it just isn't worth it, and I'll just clone sound references, which is stupid but takes 1 line of code each. STRING_SET, or something very similar, should really be able to do it.

Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#48 GeN1e

GeN1e

    A very GAR character

  • Modder
  • 1604 posts

Posted 09 June 2009 - 06:50 PM

Not sure if it'll actually work though...
<<<<<<<< table.2da
_ANAR_01 @1 TANAR01
_ANAR_02 @2 TANAR02
>>>>>>>>
COPY ~table.2da~ ~table.2da~
  COUNT_2DA_ROWS 3 rows
  FOR (i=0;i<rows;i+=1) BEGIN
	READ_2DA_ENTRY i 0 3 ~old_sound~
	READ_2DA_ENTRY i 1 3 ~string~
	READ_2DA_ENTRY i 2 3 ~new_sound~
	INNER_PATCH_FILE ~dialog.tlk~ BEGIN
	  READ_LONG 0xa strref_num
	  FOR(index=0;index<%strref_num%;index+=1)BEGIN
		READ_ASCII (0x12 + (0x1a * %index%) + 0x2) sound
		PATCH_IF (~%sound%~ STRING_EQUAL_CASE ~%old_sound%~) BEGIN
		SET string_ref = %index%
		STRING_SET_EVALUATE %string_ref% ~%string%~ %new_sound%
	  END
	END
  END
BUT_ONLY_IF_IT_CHANGES

PS Bah, typos...

Edited by GeN1e, 09 June 2009 - 06:54 PM.

Retired from modding.