Jump to content

Correct use of EraseJournalEntry()


Salk

Recommended Posts

EraseJournalEntry is a transaction like SetGlobal etc. So you wrap it into a DO ~EraseJournalEntry()~ action.

Important part is that the quoted line of teh journal entry needs to match the one inside the journal exactly to the last letter, or the entry will not be recognized (and not removed).

If you are working with tra-files in a mod, I suggest using a tra file that is valid for the whole mod (like setup.tra is), making sure the journal entry line exists only once - for adding and removing both. This makes it easier for translators who do not have to make sure the lines match in different files or the likes.

if you want to remove a journal entry from the game, you can reference the string-ref number. Examples:

IF ~~ THEN DO ~EraseJournalEntry(26816) //existing entry from the game, string ref number #26816
EraseJournalEntry(@123)~ //tra line from your mod
EXIT

 

Link to comment

Hello, jastey!

4 hours ago, jastey said:

if you want to remove a journal entry from the game, you can reference the string-ref number.

That is exactly what I need to do. Not add custom journal entries and then remove them but rather change existing scripts that contain the EraseJournalEntry() action.

The problem is that I cannot use a fixed StrRef when I attempt to do this on Baldur's Gate Trilogy because the dialog.tlk is modified at installation and BG1 StrRef can be different than what they were before.

Example for one journal entry:

"Dear, absent-minded Phlydia has lost another of her books: "The History of Halruaa," this time. Last time she was at Candlekeep, she lost an entire four-volume set in the hay we keep for the cows."

This journal entry use #16002 in Baldur's Gate but in BGT it is using #74453 in my current installation and I am quite sure that the string number may differ depending on the presence of other modifications that may even go as far as modify the text.

So I fear a different method is needed.

Edited by Salk
Link to comment

So, it seems what you need to do is detect the existing string use and then change things with a variable. If you know where they're used...

COPY_EXISTING ~PHYLDI.DLG~ ~override~
	READ_LONG 0x14 ofsResponse // Index of first response
	READ_LONG (ofsResponse + 8) PhlydiaJournal // Journal entry in first response
BUT_ONLY

To continue the example, that gets the string reference number for Phlydia's journal entry - 27362 in BGEE; it's the "Journal entry" field in response #0. Now you can use that PhlydiaJournal variable whenever you need the number to alter the existing EraseJournalEntry actions.

Link to comment

Sounds promising but I have a question: dialogue files can be modified so the responses position could theoretically change?

EDIT: Also, if it is the first response, why add + 8?

EDIT 2: Additionally, shouldn't I use READ_STRREF instead of READ_LONG to get the string number?

Edited by Salk
Link to comment

Theoretically, yes. But how often is that modification going to involve inserting things before the very first response? New stuff is much more likely to be appended at the end.

You can't be compatible with absolutely everything. And here, compatibility with sweeping changes to dialog.tlk is more relevant than compatibility with specific changes to .dlg files.

... Actually, that was a particularly simple example. If the response I was looking for wasn't attached to the first state, I'd need to look at the state it was attached to for its "First response index" parameter. Add a multiple of 32 (the size of a response element) corresponding to that number.

Link to comment

@argent77 wrote a function to grab the correct journal entry. Have a look at bg1re/lib/func_fetch_journal_entries.tph in the bg1re mod. You need to read it in in the tp2:

INCLUDE ~bg1re/lib/func_fetch_journal_entries.tph~

And then you can grab the string ref number for a journal entry in a certain dlg state number. For example, in bg1re, I get the journal entry from CORDYR.dlg, state 1, reply option 0:

COPY_EXISTING ~%tutu_var%cordyr.dlg~ ~override~
	LPF ~READ_JOURNAL_STRREF~
		INT_VAR
		state         = "1"  // state index
		stateResponse = 0     // relative response index (e.g. 0 for first response associated with the state, 1 for second response, and so on...)
		RET
		strref    // returned string reference, or -1 if not available
	END
	SET unsolved_strref = strref

In this case, %unsolved_sstref% is the variable that stores the string ref number, it then can be used like a number (evaluated with EVALUATE BUFFER). (It is used in bg1re/silsblessing/acordyr.d). In your case, it would be:

DO ~EraseJournalEntry(%unsolved_strref%)~

 

Link to comment

Of course someone wrote a function for that. The code I put up was basically the low-level version of READ_JOURNAL_STRREF. Obviously, the function version has more safeties.

(Added in edit)

Here's my example with the READ_JOURNAL_STRREF function:

INCLUDE ~bg1re/lib/func_fetch_journal_entries.tph~

/* May also need a cross-platform library and the %tutu_var% bit; I'm not up on which dialogue files get their file names changed, since I only mod for the EEs. And of course, you might change the path to the library with the function in it. */

COPY_EXISTING ~PHLYDI.DLG~ ~override~
	LPF READ_JOURNAL_STRREF INT_VAR state=0 stateResponse=0 RET strref END
	SET PhlydiaJournal = strref
BUT_ONLY

 

Edited by jmerry
Added recoded example
Link to comment

Hello again!

I was wondering if there is also a quick way to get the str ref from a dialogue state in order to replace the associated text with something else.

Case in point: BELLAM.DLG State 1 includes the text "Good day to ya." and that text comes from a specific string reference (in my case 76167). If the string reference was always 76167 it would not be a problem. I just use STRING_SET 76167 ~My new string replacing the original~ but the string reference can be different so I'd need to extract it from the dialog file.

Looking at jmerry's advice above and considering that the string I need to change is at State 1 in the BELLAM.DLG file, I thought that I could do something like:

COPY_EXISTING ~BELLAM.DLG~             ~override~
    READ_LONG 0xc stateoffset
    READ_STRREF (%stateoffset% + 10) oldstring
    STRING_SET_EVALUATE %oldstring% ~My new string~

but I am quite sure it's not right or ideal and at the moment I am unable to test it directly so I am just asking for theoretical criticisms and advice. 

Any suggestions?

(e) Tested and not working, as expected. I guess it's  because there is no string reference at all there.

Edited by Salk
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...