Jump to content

how to efficiently add conditional dialogue triggers


Recommended Posts

As a quick aside: unless you're doing something that absolutely requires a complicated regexp, you're better served doing dialogue modifications with d code over Ye Olde DECOMPILE_AND_PATCH. Even in those edge cases, there's likely a d code regexp that you can restrict it to triggers or actions or whatever, making it a better option.

Circling back to the compatibility discussion there's not really an ideal way to do this.

  1. You can follow the original example and EXTEND_TOP. This is bad for compatibility as any other mods targeting transitions in this state will now be off by one. The odds on this actually occurring will vary--if you're doing this to Commoner #8 in Athkatla you're probably fine; if you're doing this to the Tree of Life gut check you're in trouble.
  2. You can EXTEND_BOTTOM. This is good compatibility-wise as it preserves the existing transition order. The downside is that your new reply sticks out like a sore thumb because it's no longer in its original order. This is especially true for IWD where the reply options hew to a pattern.
  3. You can fork the dialogue before or after. In the DAMBERE example, you could leave the transitions in 9 and look if you could fork them afterward (in state 18) or try to intercept transitions into state 9. This is a hit-and-miss prospect, and you won't be able to do it everywhere.
  4. Combining 1 and 2, you add a new trigger to all existing transitions in the targeted state, and then EXTEND_BOTTOM all of the transitions with the opposite trigger added. So instead of A-B-C turning into A1-A2-B-C you end up with A1-B1-C1-A2-B2-C2. It's more complicated and a little more fragile but it will provide a seamless insertion of a reply while not re-ordering the existing transitions.
Link to comment

Interesting. Option 4 is probably the best idea, though this will only alter a small handful of dialogues, so #2 might be good enough. Of course neither gets around the potential language mismatch. But that is a hypothetical problem at the moment, so whatever. 

Shifting gears: for one select NPC (Yxunomei), I want write a completely new dialogue from the ground up. Then, when you face her at the end of Dragon’s Eye, I want the game to check how you got there - did your journey originate in Easthaven, or in Athkatla? And depending on the answer, send her down two completely different dialogue paths. 

I am contemplating the following: 

1) Add a variable check to the very first state of the .DLG file. Then EXTEND_BOTTOM and add a whole series of new states, the first of which would contain the opposite variable check. Maybe set WEIGHT = 0 in the first new state? Not sure if that’s necessary. 

2) If the above is insufficient, maybe add the variable check to every state in the original dialogue? And add the opposite variable check to every state in the new dialogue addition? This sounds like overkill/sheer crazy, but I’m not sure. 

3) Possibly, a script action can change a creature’s dialogue in-game? So I could put the variable check in the area script and simply direct the creature to use a new, different dialogue. The only thing that gives me pause here is the sequence where the little girl teleports around making cryptic remarks at the beginning of the level. I would not want to mess that up. 

Link to comment

Right, so a few options here:

  1. You can branch transitions in state 0 using the same methods and limitations as discussed for DAMBERE.
  2. You can add new dialogue (via APPEND) with a new entry state for these alternative circumstances. You then make it take effect either by weighting it ahead of the existing state 0, or add a mutually exclusive trigger to state 0 so that it'll fall to the new entry state.

The benefit of approach 2 is that, if Xyunomei's original line doesn't fit the alternative path, this is the best way have her start with a different line. The downside is that having a second,  separate path through a previously unitary dialogue is very bad for compatibility--if you pursue the second option, I'd link it back into the original dialogue flow as early as possible to minimize conflict. (As an aside: while you can change assigned dialogue via script, it's even more worse for compatibility. You can expect someone else may branch a dialogue into something unrecognizable, but at least it's the same file.)

It would look something like

ADD_STATE_TRIGGER DXYUN 0 ~!sometrigger~
APPEND DXYUN

  IF ~sometrigger~ THEN BEGIN cd_new_entry SAY #123
    IF ~~ THEN GOTO 1
    // other transitions as needed
  END
 
  // other new states as needed

END

or

APPEND DXYUN

  IF WEIGHT #-1 ~sometrigger~ THEN BEGIN cd_new_entry SAY #123
    IF ~~ THEN GOTO 1
    // other transitions as needed
  END
 
  // other new states as needed

END

 

Link to comment
26 minutes ago, CamDawg said:

 2. You can add new dialogue (via APPEND) with a new entry state for these alternative circumstances. You then make it take effect either by weighting it ahead of the existing state 0, or add a mutually exclusive trigger to state 0 so that it'll fall to the new entry state.

The benefit of approach 2 is that, if Xyunomei's original line doesn't fit the alternative path, this is the best way have her start with a different line. The downside is that having a second,  separate path through a previously unitary dialogue is very bad for compatibility--if you pursue the second option, I'd link it back into the original dialogue flow as early as possible to minimize conflict.

Okay, I think this is the way. Conveniently, all of the dialogue with Yxunomei starts from a single state. Unfortunately, her statement there does not work for this mod (the word "vendetta" doesn't fit). So I need to make the initial state a completely different one depending on the variable value.

Also unfortunately, my added dialogue will never loop back to the existing dialogue; nothing in Yxunomei's existing dialogue is appropriate for this mod. For all intents and purposes, if you come upon Yxunomei via my mod, it might not be Yxunomei at all, but perhaps some other marilith with another agenda. So I will be adding an entirely independent branch of conversation. But this should not really be bad for compatibility, because apart from the new state trigger, her existing dialogue will be completely untouched, and therefore free to be modded by others.

The variable in question is set in the Easthaven area script, so if you are playing the IWD campaign, you will get the original dialogue and that dialogue can be modded by other people. Only if you come to Yxunomei from the BG2 campaign (you get to ID4005.ARE after having been to AR1301.ARE and never having been to ID1000.ARE) will you see my modified dialogue branch. If you use a "smush the campaigns together" mod to go from Baldur's Gate to Easthaven to Athkatla in one game, then all of my content will be closed off to the player and this will be irrelevant. So I think from a compatibility perspective, 1) players will have various options to play the content as they please; and 2) the content will be responsive to the way they play it and will respect other mods that touch the same parts of the game. It's shaping up pretty well, I should have a playable beta very soon.

Edited by subtledoctor
Link to comment

Okay last question (...for now?? )

I want to add a line of dialogue to KPCAPT01.DLG. Right now the dialogue does this:

IF ~~ THEN BEGIN 3 // from: 0.1 2.0 10.1 13.0 14.1 15.1 30.1
  SAY #39783 /* ~Has Mistress Nalia not told you? We were beset by trolls and yuan-ti...~ */
  IF ~~ THEN GOTO 4
END

IF ~~ THEN BEGIN 4 // from: 3.0
  SAY #39784 /* ~ 'Twas little that could be done, truly enough...~ */
  IF ~~ THEN GOTO 5
END

IF ~~ THEN BEGIN 5 // from: 4.0
  SAY #39785 /* ~Once Lord de'Arnise disappeared, it was hopeless...~ */
  IF ~~ THEN GOTO 6
END

IF ~~ THEN BEGIN 6 // from: 5.0
  SAY #39786 /* ~The trolls and those yuan-ti have shut the keep up tight...~ */
  IF ~~ THEN GOTO 7
END

I would like to change the line he speaks in state 3, or else insert a line somewhere. I suppose I could do STRING_SET #39783... but I try to avoid STRING_SET if at all possible.

So maybe it make sense to APPEND a new state:

APPEND KCAPT01
~~~~~
IF ~~ THEN BEGIN d5_new_state
  SAY ~Many local villagers had taken refuge in the Keep when the troll attack began; unfortunately that left them vulnerable to capture when the yuan-ti tunnelers sudden appeared inside the castle.~
  IF ~~ THEN GOTO 4
END
~~~~~

Then I could either alter the transition in state 3 to point to the new state... something like:

ALTER_TRANS KCAPT01 BEGIN 3 END BEGIN 0 END BEGIN "EPILOGUE" ~GOTO d5_new_state~ END

...Or, I recall this from another thread:

On 9/30/2018 at 1:37 AM, CamDawg said:

the important bit with dialogues is understanding how the engine evaluates branches. Any transition without a player reply is evaluated from the bottom up, and the first one with a true condition is followed.

So I could perhaps do something like:

EXTEND_BOTTOM KCAPT01 3 
~~~~~
IF ~~ THEN GOTO d5_new_state
~~~~~

Not sure what would be best for compatibility.

Also, neither here nor there, but when APPENDing or EXTEND_BOTTOMing, I need  those delimiters to mark out the content being added, right?

Edited by subtledoctor
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...