Jump to content


State Weights (Old post of mine reformatted)


  • Please log in to reply
No replies to this topic

#1 -japh-

-japh-
  • Guest

Posted 02 April 2004 - 02:51 AM

In certain dialogues in BG2/TOB (and possibly IWD/PST as well, I'm not sure) the dialogues are made using weighted systems. Celogan.dlg is an example of one of them, and there are many more.

You can take a look at the decompiled celogan .d file here.

The first thing you'll notice is the warning you get. It tells you right off that the dialog file contains non-trivial weights.

Now, I'll explain how it works.

If you take a look at State #88 in that URL I posted above you'll see this:


IF WEIGHT #16 /* Triggers after states #: 92 95 even though they appear after this state */
~Global("feudplot","GLOBAL",1)
!Dead("trfued01")
!Dead("trfued05")
Global("Loganmantle","GLOBAL",1)~ THEN BEGIN 88 // from:
SAY ~Greetings, <CHARNAME>, how goes the... quest in the tomb? Do you bring the mantle to me, so that this feud of the Lurraxols and the Alibakkars may be ended?~ /* #47095 */
IF ~~ THEN REPLY ~No, I do not have the mantle with me.~ /* #47096 */ GOTO 89
IF ~PartyHasItem("misc8l")~ THEN REPLY ~I have the mantle, but I cannot give it to you, Lord Logan.~ /* #47097 */ GOTO 90
IF ~PartyHasItem("misc8l")~ THEN REPLY ~Yes, I have the mantle... take it so that my involvement with these families is done.~ /* #47098 */ DO ~TakePartyItem("misc8l")~ GOTO 91
END


Now if you look at State #92, you'll see this:


IF WEIGHT #5 ~Dead("cefald01")
Global("LoganMad","GLOBAL",0)
Global("GrovePoisoned","GLOBAL",1)
~ THEN BEGIN 92 // from:
SAY ~By Torm, <CHARNAME>! I have just received word! What have you done?? Are you mad?~ /* #50665 */
IF ~~ THEN REPLY ~What seems to be the problem, Lord Coprith?~ /* #50667 */ GOTO 93
IF ~~ THEN REPLY ~I've taken care of your druid problem. They won't be bothering you again.~ /* #56478 */ GOTO 93
END


Now, if feudplot was 1, trfued01 wasn't dead, trfued05 wasn't dead, LoganMantle was 1, cefald01 was dead, LoganMad was 0 and GrovePoisoned was 1 (basically all the conditions for both states were met), State #92 would trigger *before* State #88 because it's weight takes precedence over State #88's weight.


WeiDU will preserve the conditional weighting in the dialog and you can still append and add state and transition triggers par normal. You can also set state weights with WeiDU as well if you think it's needed (although I don't recommend using SET WEIGHT).