Text Database

From PBnWModdingWIKI

Several scripting commands (say, tooltip and dyke/sign creation) use references to the TEXT database. :The say command uses a number as an argument, whereas tooltip and sign creation use a string literal as argument. Unfortunately, passing a string literal as an argument does not seem to work in the latest version of the script compiler. This problem is described in the Black & White II Scripting Issues article.
While it might be possible to modify/hack the text database, Neil Wakefield advised against this as the Text Database is not designed to be modified (as in, it's very very hard to modify).
However, I still want to documentate any Reverse Engineering efforts.
--ShadowCode 05:48, 16 March 2006 (PST)

Contents

bw2text.lhts

In Kalev's example batch file, this file is passed as an argument to the compiler. One of the difficulties related to the text-database problem is that the script files are compiled against the text-database. This text-database, specifically. If we modify the textdatabase, it is quite possible that the existing scripts will need to be recompiled. ALso, the text database also contains string data of the interface (So B&W2 might crash).
Overall, the format of this file seems pretty straight forward.

HEADER

Hex:                                                  ASCII:

4C 48 54 53                                             LHTS
Default sign for humans. LHTS presumably stands for Lionhead Text System or Text Source.

01 02
Might be version signing or a filler.

00 
00-byte, just a divider

65 6E 2D 75 6B                                          EN-UK
Language code. This is the english version of B&W2.

00 00 00
End of header, it seems!

CONTENTS

Bytes:
0x12 - 0x21: 15 bytes of Unknown.
0x22 - 0x23: 2 bytes, ID number.
0x24 - 0x47: var bytes, constant name.
0x48: 1 byte, always 0x00, divider.
0x49 - 0x4F: var bytes, Profile (who says it, spells DEFAULT for GUI components and HELP texts).
0x50 - 0x51: 2 bytes, always seems to be "00 FF"
0x52: 1 byte, always 0x00, divider.
0x53 - 0x103: var bytes, String. How does the engine know the length of the string?
15 bytes of Unknown again, etc. 

bw2text.bin


Some entries

  • Script ID: The ID used as an argument for the say single line database id {id} statement.
  • Hex Line: Address of string in bw2text.lhts. I use XVI32 as my hex editor (Know a better one? Please let me know!), hex line is the address of the line that contains the text string. If your editor uses a different/proper 'line'width, jump to that location anyway as the string should be near that.
  • Text: Self explainatory
  • TextID: Some kind of ID, see bw2text.lhts
  • Const: The const name of the string.
Script	Hex line	Text					TextID	CONST
ID

1	194A89		"Begin charging the Earthquake"		FF 4E	BW2T_SCRIPT_10_FINAL_EARTHQUAKE_30
2	0ECCE4		"Opening and Closing the Toolbar"	FF 00
3	19A77E		"Fatness"				5E CB