Pocket Plane Group Logo Xan Friendship Logo
Welcome, Guest. Please login or register.
May 25, 2013, 09:52:55 AM

Login with username, password and session length
Search:     Advanced search
Xan friendship path for BG1 is available! Download now!
137829 Posts in 14217 Topics by 4643 Members
Latest Member: irbis
* Home Help Search Login Register RSS feed
+  Pocket Plane Group
|-+  Miscellany, Inc.
| |-+  Tutorials (Moderator: Ghreyfain)
| | |-+  State Weights - by Japheth
« previous next »
Pages: [1] Go Down Reply Print
Author Topic: State Weights - by Japheth  (Read 11097 times)
Ghreyfain
Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 4590


WWW
« on: April 01, 2004, 06:25:30 PM »
Reply with quote

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).
Logged

Earn Money Sleeping.
Awake
Enigma
Planewalker
*****
Offline Offline

Gender: Male
Posts: 56


The Raven


WWW
« Reply #1 on: September 07, 2004, 08:50:23 PM »
Reply with quote

Ghreyfain (or did Japheth do this), i love your tutorials Grin, but i just don't understand this one. If you could direct me to a stronger one, more directed at someone who has no idea what he is reading, that would be great, or if you could just add on to this one a little bit, thanks.
« Last Edit: September 07, 2004, 08:53:59 PM by Awake » Logged

icelus
Global Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 3180



« Reply #2 on: September 07, 2004, 08:54:06 PM »
Reply with quote

Try this one on for size: http://forums.pocketplane.net/index.php?topic=15975.0

Smiley
Logged

<Moongaze> Luckily BWL has a very understanding and friendly admin.
Awake
Enigma
Planewalker
*****
Offline Offline

Gender: Male
Posts: 56


The Raven


WWW
« Reply #3 on: September 08, 2004, 07:05:49 PM »
Reply with quote

yeah, i tried that one, but i don't get it still. well, i get the idea but that's it. I'm working on some dialogue right now, and i need to know if this will be important, i don't know how to incorporate it or anything. Cry

Actually, i don't think i even get the idea, i get the idea, but i don't get the idea. Why is it necessary to set weights? Doesn't the dialogue just go by the conditions, like NumTimesTalkedTo(0) or !StateCheck(...) or those kinds of things? I really don't think i understand. Please help. Somebody, anybody.  Cry
« Last Edit: September 10, 2004, 06:19:05 PM by Awake » Logged

guest
Guest
« Reply #4 on: September 18, 2004, 08:25:37 PM »
Reply with quote

I think the poster is making it more complicated than it is.

I must say that I haven't done any dialog scripting, but you don't have to use weights.  I think weights are used to give a dialog more precedence over others.  Yes, the dialogs go by the conditions.  But what if conditions for two different dialogs are met at the same time?  Then the dialog with less weight will show.

For example:
==================
IF
 true()
blah blah 1

IF
 true()
blah blah 2
===================
Since both conditions for the dialogs are true, and only one dialog will show, the blah blah 1 dialog will show because it appears first.

example:
==================
IF WEIGHT #10
 true()
blah blah 1

IF WEIGHT #1
 true()
blah blah 2
===================
This time, since both conditions are true again, the blah blah 2 dialog will show because it has less weight (less weight = higher priority).

Hope this helps.
Logged
Awake
Enigma
Planewalker
*****
Offline Offline

Gender: Male
Posts: 56


The Raven


WWW
« Reply #5 on: September 18, 2004, 08:52:32 PM »
Reply with quote

thank you. i understand it perfectly now. That was exactly what i needed
Logged

ScriptKiddie
Guest
« Reply #6 on: January 23, 2005, 09:55:59 AM »
Reply with quote

I'm not sure I'm understanding yet. In the following dialog from Bentley (Friendly Arms Inn) I'm not sure I see how the last dialog path is ever accomplished. As I understood the above, it would first check WEIGHT #0 (Bad reputation), then WEIGHT #2 (50/50 chance), then WEIGHT #3 (Always true), before proceeding onto the unweighted option. But since it should always stop at WEIGHT #3, I don't see how that dialog ever happens.

Thanks.



IF WEIGHT #2 /* Triggers after states #: 2 even though they appear after this state */
~RandomNum(2,1)
~ THEN BEGIN 0 // from:
  SAY #1467 /* ~Iron is the lifeblood of this whole region and it's sure painful when it gets scarce.  So what can I do for ya?~ */
  IF ~~ THEN REPLY #15248 /* ~What do you have to sell?~ */ DO ~StartStore("friend",LastTalkedToBy())~ JOURNAL #6615 /* ~Bentley, the owner of the Friendly Arm inn, told us that the iron trade has slowed greatly over the past few weeks.~ */ EXIT
  IF ~~ THEN REPLY #15249 /* ~Nothing for me today.~ */ DO ~~ EXIT
END

IF WEIGHT #3 /* Triggers after states #: 2 even though they appear after this state */
~True()
~ THEN BEGIN 1 // from:
  SAY #1468 /* ~None too many travelers have been through lately, what with the supposed troubles down south.   So what can I do for ya?~ */
  IF ~~ THEN REPLY #15251 /* ~What do you have to sell me?~ */ DO ~StartStore("friend",LastTalkedToBy())~ JOURNAL #6616 /* ~Bentley told us that there has been some sort of trouble in the south.  Perhaps we should go to Nashkel?~ */ EXIT
  IF ~~ THEN REPLY #15252 /* ~Nothing today thank you.~ */ DO ~~ EXIT
END

IF WEIGHT #0 ~ReactionLT(LastTalkedToBy(),NEUTRAL_LOWER)
~ THEN BEGIN 2 // from:
  SAY #1469 /* ~Sorry, I'm right out of the cheap stuff.   So what can I do for ya?~ */
  IF ~~ THEN DO ~StartStore("friend",LastTalkedToBy())~ EXIT
END

IF ~~ THEN BEGIN 3 // from:
  SAY #1470 /* ~Things haven't been very busy as of late, with all the troubles in the south.  I've heard though, that the mines at Nashkel have been re-opened.  Some heroic folk dealt with whatever was plaguing the mine. So what can I do for ya?~ */
  IF ~~ THEN REPLY #15259 /* ~What do you have to sell me?~ */ DO ~StartStore("friend",LastTalkedToBy())~ EXIT
  IF ~~ THEN REPLY #15260 /* ~Nothing for today.~ */ EXIT
END

Logged
ScriptKiddie
Guest
« Reply #7 on: January 23, 2005, 10:05:52 AM »
Reply with quote

Oh, and if I understood guest properly, one could have avoided using weights at all by simply placing the Bad Reputation check first?

Thanks again.
Logged
Kismet
Devil's Minion #5
Global Moderator
Planewalker
*****
Offline Offline

Gender: Female
Posts: 649


Veni; Vidi; Velcro.


WWW
« Reply #8 on: January 23, 2005, 10:15:39 AM »
Reply with quote

Do you actually get state 3 in game?  I can't see how you could, WEIGHT not withstanding, since it has no state triggers and could never return true, unless it's called by another state that is.  Of course I haven't done any modding for BG1 so perhaps things work differently there.
Logged

Cailean - An archer NPC for the insatiably nosy!  Guaranteed more fun than shampooing cats!
Ghreyfain
Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 4590


WWW
« Reply #9 on: January 23, 2005, 10:19:37 AM »
Reply with quote

Kismet's right.  A state without a trigger never appears as a top-level dialogue (i.e. you click them and that's what you get), it can only be seen as a reply to a PC reply, or otherwise being GOTO'ed. Smiley

IF ~~ replystate
  SAY ~Even though this state is at the top, it won't appear right off the bat.~
  IF ~~ THEN EXIT
END

IF ~True()~ FirstState
  SAY ~Yo.  The player just clicked me and this is the dialogue that will appear first.  After you hit enter, it'll GOTO the state named "replystate".~
  IF ~~ THEN GOTO replystate
END
Logged

Earn Money Sleeping.
ScriptKiddie
Guest
« Reply #10 on: January 23, 2005, 04:30:25 PM »
Reply with quote

Thanks for the quick responses!

We just started playing again after a long time off. I don't recall ever hearing Bentley getting to State 3, and as I was reading the script, I couldn't figure out how it could play. I did a bunch of stuff trying to get it to play, and couldn't. Presumably, then Black Isle messed up the script?

So if I'm following the discussion, if BI had placed State#2 at the top, then all weighting would have been superflous? I exported, then WeiDU'd Bent2.cre and Frnd2.sto and the script seemed to operate the same way, but I'm a little afraid that there is a reason that BI used weights instead of just order of blocks in the script, and misunderstanding their rationale wil mess up the modding I'm dinking with.

Thanks!
Logged
Ghreyfain
Moderator
Planewalker
*****
Offline Offline

Gender: Male
Posts: 4590


WWW
« Reply #11 on: January 23, 2005, 11:49:35 PM »
Reply with quote

They had different tools for editing dialogues than WeiDU, I recall David Gaider saying once upon a time.

Basically, it had four "levels" you could put your state into, and beyond that I imagine they would just play in the order you wrote them in.

So if they decided, after the fact, that they wanted State 2 to run before State 0 and 1, they'd just shuffle State 0 and 1 into the second weight level.  Or something.  Who knows.
Logged

Earn Money Sleeping.
Pages: [1] Go Up Reply Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.1 | SMF © 2006, Simple Machines LLC Valid XHTML 1.0! Valid CSS!