Jump to content


Photo

WEIGHT #xy


  • Please log in to reply
11 replies to this topic

#1 Dyara

Dyara
  • Member
  • 262 posts

Posted 09 February 2003 - 06:53 AM

I tried to write a dialogue with weights. The dialogue is assigned to a creature that says 'Test1' or 'Test2'. But if the global Test2 is set to 1 it should say 'Test3'. I thought that using a weight for state T3 I donīt have to change the state triggers T1 and T2:

BEGIN ~Test~

IF ~Global("TEST1","GLOBAL",0)~ THEN BEGIN T1
   SAY ~Test1~
   IF ~~ THEN EXIT
END

IF ~!Global("TEST1","GLOBAL",0)~ THEN BEGIN T2
   SAY ~Test2~
   IF ~~ THEN EXIT
END

IF WEIGHT #0 ~Global("TEST2","GLOBAL",1)~ THEN BEGIN T3
   SAY ~Test3~
   IF ~~ THEN EXIT
END

Unfortunately it seems not to work regardless of the weight (Iīve tried -999, -1, 0, 1 and many more).

Looking at the dlg file with InfExplorer, decompiling it with WeiDU again (or playing the dialogue with BG2) there are no weights:

BEGIN ~TEST~

IF ~Global("TEST1","GLOBAL",0)~ THEN BEGIN 0 // from:
  SAY #78411 /* ~Test1~ */
  IF ~~ THEN EXIT
END

IF ~!Global("TEST1","GLOBAL",0)~ THEN BEGIN 1 // from:
  SAY #78412 /* ~Test2~ */
  IF ~~ THEN EXIT
END

IF ~Global("TEST2","GLOBAL",1)~ THEN BEGIN 2 // from:
  SAY #78413 /* ~Test3~ */
  IF ~~ THEN EXIT
END

Of course I could write the dialogue without weights but using weights would make it much more simple.

Is it a bug in WeiDU,have I misunderstood the usage of weights or is there something wrong in my d file?

#2 Dyara

Dyara
  • Member
  • 262 posts

Posted 09 February 2003 - 11:00 AM

I found out that it works if I use weights in every state
BEGIN ~Test~

IF WEIGHT #2 ~Global("TEST1","GLOBAL",0)~ THEN BEGIN T1
   SAY ~Test1~
   IF ~~ THEN EXIT
END

IF WEIGHT #3 ~!Global("TEST1","GLOBAL",0)~ THEN BEGIN T2
   SAY ~Test2~
   IF ~~ THEN EXIT
END

IF WEIGHT #1 ~Global("TEST2","GLOBAL",1)~ THEN BEGIN T3
   SAY ~Test3~
   IF ~~ THEN EXIT
END
but... hmmm, at least itīs not as itīs written in the readme.

#3 -jcompton-

-jcompton-
  • Guest

Posted 09 February 2003 - 03:47 PM

Tell Wes what version you're on.

You're right to expect the Test3 response to win IF Test1=0 and Test2=1.

"All states with WEIGHT directives come before all states without them." - WeiDU Readme

So really, regardless of the WEIGHT number you assign in the .d, it SHOULD generate the order you want.

#4 Dyara

Dyara
  • Member
  • 262 posts

Posted 09 February 2003 - 04:04 PM

Iīve used WeiDU 105.

#5 -jcompton-

-jcompton-
  • Guest

Posted 10 February 2003 - 01:25 PM

Tried it with 107? :) There was a (seemingly unrelated) piece of WEIGHT code that got fixed in 106, perhaps this too was taken care of.

#6 Dyara

Dyara
  • Member
  • 262 posts

Posted 10 February 2003 - 02:40 PM

I used 105 because itīs our current version in RTW, but I will try it with 107 :).

#7 japheth

japheth

    Codewalker

  • Member
  • 317 posts

Posted 10 February 2003 - 04:25 PM

I just tested that piece of code with v107 and it still isn't working.
Check out BG1Tutu.

#8 weimer

weimer
  • Member
  • 1569 posts

Posted 11 February 2003 - 01:00 PM

The README is right (conceptually), so I have changed our handling of WEIGHTs (yet again). It passes Dyara's test and also compiles JAHEIRA.D correctly. Look for it shortly.

#9 Dyara

Dyara
  • Member
  • 262 posts

Posted 11 February 2003 - 01:06 PM

Great :), it will make a lot of things much simpler.

#10 Quitch

Quitch

    Perfection

  • Modder
  • 1132 posts

Posted 11 February 2003 - 01:51 PM

Not that I can remember exactly what this is for, but wouldn't it have been easier to simply add the reverse of the TEST2 check to the first two states, or is this now considered sloppy WeiDUing?

#11 -Ghreyfain-

-Ghreyfain-
  • Guest

Posted 11 February 2003 - 03:26 PM

Not that I can remember exactly what this is for, but wouldn't it have been easier to simply add the reverse of the TEST2 check to the first two states, or is this now considered sloppy WeiDUing?

I believe it's more for APPENDing to existing dialogues, in which you don't want to add a !MyTrigger() trigger to every single state that's above your addition.

#12 Dyara

Dyara
  • Member
  • 262 posts

Posted 11 February 2003 - 03:53 PM

Not that I can remember exactly what this is for, but wouldn't it have been easier to simply add the reverse of the TEST2 check to the first two states, or is this now considered sloppy WeiDUing?

Of course you can do that but I donīt think itīs simpler. My example is simple but think of it as a more complex dialogue with more states t1 and t2 and with more states t3. For each 't3' you have to add the reverse check to all the states t1/t2 and the whole dialogue becomes very difficult to read.

I would uses weights (and a LOCALS which is only true under that specific condition) to restart a dialogue after a cutscene for example (dialogue starts cutscene and cutscene restarts dialogue). Without weights you have to add that locals to each and every root state. Perhaps later you will change that local for some reason (or drop the cutscene) and again you have to edit each trigger.

I believe it's more for APPENDing to existing dialogues, in which you don't want to add a !MyTrigger() trigger to every single state that's above your addition.

Or adding to an existing dialogue (of your own mod) without changing the allready existing (and perhaps tested) part of the dialogue.