Pocket Plane Group

Miscellany, Inc. => Infinity Engine Modding Q&A => Topic started by: Ghreyfain on January 09, 2005, 09:24:50 PM

Title: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on January 09, 2005, 09:24:50 PM
So here's the lowdown, as I'm sure pretty much everyone with BG1 and BG2 knows.  In BG1, if you spoke to a person who had no valid states, his circle would simply glow white and he'd say a random line, as if you'd right-clicked him.  In BG2, an ugly "this person has nothing to say to you" message pops up.

Can anyone think of a decent way of detecting when a creature has been clicked?  I figured the appropriate action would be VerbalConstant(Myself,26 through 31), but the trigger to cause this eludes me.

So far Clicked([ANYONE]) doesn't work.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Echon on January 10, 2005, 02:47:42 AM
There does not appear to be such a trigger.

-Echon
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on January 10, 2005, 03:15:22 AM
Well, yeah.  ;)  I was asking if anyone could think of a reasonably workable way of getting it to work... somehow.  Globals, EFFs, WHILE loops.  I dunno!  Something!  Heheh.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Echon on January 10, 2005, 03:28:25 AM
* And I cannot think of any possible workaround either. :)

-Echon
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Andyr on January 10, 2005, 06:23:42 AM
Well, yeah.  ;)  ... WHILE loops....

You have been contaminated! Flee to G3, infidel!

For a workaround, how about using the strings from their sounds to make them a new dialogue? So they would have something to say, which would be random claptrap from the lines you used to click on them to hear.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on January 10, 2005, 10:49:18 AM
That's what I was thinking, yeah.  Sort of sucks that the dialogue window has to open, but oh well.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Andyr on January 10, 2005, 10:53:27 AM
Roughly how many different creatures in Tutu are there who'd need dialogue like this?
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on January 10, 2005, 11:04:50 AM
Have no clue.  Will need to make a list.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on January 10, 2005, 12:13:18 PM
Okay, here's what I have for code so far.

In the .tp2
Code: [Select]
COMPILE ~tutufix/commoner lines/commonlines.d~

COPY_EXISTING ~_0_ftowb.cre~ ~override~
READ_LONG 0x10c "selected"

COPY_EXISTING ~_ftowbe.dlg~ ~override~
REPLACE 999999 "%selected%"

In commonlines.d
Code: [Select]
APPEND _FTOWBE
 IF WEIGHT #9999 "True()" laststate
  SAY #999999
  IF "" THEN EXIT
 END
END

Now, I figure the variable "selected" isn't carrying over through to the next C_E patch.  But I think I just came up with an idea to get around that, so I'll go test it before continuing here.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: SimDing0™ on January 10, 2005, 12:39:57 PM
I'm not sure this is really an optimal solution. I can't think of BG1 examples, but in BG2, I think it'd be a great shame if every Shadow Thief spat out "No-one crosses the Shadow Thieves and lives!" when you clicked them. In a sense, I guess what I'm saying is that the voiced lines are generally more abstract than the dialogue text. Although maybe that's not the case in BG1. Hmm.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on January 10, 2005, 12:43:13 PM
I think a good example is Farmer Brun.  When you've completed his quest and everything, he has no dialogue states that're valid, but his select_common1 sound is "'t will be hard goin' without my son."
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: SimDing0™ on January 10, 2005, 12:54:02 PM
Oh, right. Okay. Carry on.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on January 10, 2005, 01:10:17 PM
Okay, so far I've worked out a while loop that will read a .cre and patch a .dlg.  Haven't worked out how to replace strref 999999 with "%selected%" yet, though.

COMPILE ~tutufix/commoner lines/commonlines.d~

COPY_EXISTING ~_0_ftowb.cre~ ~override~
              ~_ftowbe.dlg~ ~override~
READ_LONG 0x0 "filetype"
SET "patched" = 1
WHILE ("%patched%" = 1)
 BEGIN
  SET "patched" = 2
  PATCH_IF ("%filetype%" = 0x20455243) // .cre file
   BEGIN
    WRITE_BYTE 0x18 1 // This is just to check if the .cre file gets patched/READ_LONGed
    READ_LONG 0x10c "selected"
   END
  PATCH_IF ("%filetype%" = 0x20474c44) // .dlg file
   BEGIN
    WRITE_LONG 0x1a4 "%selected%" // This is to check if I can write the "%selected%" variable at all, which I can.
//   REPLACE 999999 "%selected%" // This doesn't work worth a damn.
   END
 END
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on January 10, 2005, 01:48:13 PM
Okay.  I've tried adding a bit that will read the first byte of every state to check if it's string 999999, then replace that with "%selected%".  Unfortunately, I get a parse error when trying to run setup.exe.

Code: [Select]
COMPILE ~tutufix/commoner lines/commonlines.d~

COPY_EXISTING ~_0_ftowb.cre~ ~override~
              ~_ftowbe.dlg~ ~override~
READ_LONG 0x0 "filetype"
SET "patched" = 1
WHILE ("%patched%" = 1)
 BEGIN
  SET "patched" = 2
  PATCH_IF ("%filetype%" = 0x20455243) // .cre file
   BEGIN
    WRITE_BYTE 0x18 1
    READ_LONG 0x10c "selected"
   END
  PATCH_IF ("%filetype%" = 0x20474c44) // .dlg file
   BEGIN
    READ_LONG 0x8 "num_states"
    READ_LONG 0xc "off_states"
//    PATCH_IF ("%num_states%" > 0)
     WHILE ("%num_states%" > 0)
      BEGIN
       READ_LONG (("%num_states%" * 0x10) + "%off_states%") "string"
       SET ("%num_states%" - 1)                                         <--- parse error is at the "(" here
       PATCH_IF ("%string%" = 0x000f423f)
        WRITE_LONG (("%num_states%" * 0x10) + "%off_states%")) "%selected%"
      END
   END
 END
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on January 10, 2005, 01:59:36 PM
Never mind, all fixed. :)
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on January 10, 2005, 02:01:40 PM
Okay, it all works now.  WHILE loops are GOD.

Code: [Select]
COPY_EXISTING ~_0_ftowb.cre~ ~override~
              ~_ftowbe.dlg~ ~override~
READ_LONG 0x0 "filetype"
SET "patched" = 1
WHILE ("%patched%" = 1)
 BEGIN
  SET "patched" = 2
  PATCH_IF ("%filetype%" = 0x20455243) // .cre file
   BEGIN
    WRITE_BYTE 0x18 1
    READ_LONG 0x10c "selected"
   END
  PATCH_IF ("%filetype%" = 0x20474c44) // .dlg file
   BEGIN
    READ_LONG 0x8 "num_states"
    READ_LONG 0xc "off_states"
//    PATCH_IF ("%num_states%" > 0)
     WHILE ("%num_states%" > 0)
      BEGIN
       READ_LONG (("%num_states%" * 0x10) + "%off_states%") "string"
       SET "%num_states%" = ("%num_states%" - 1)
       PATCH_IF ("%string%" = 0x000f423f)
        BEGIN
         WRITE_LONG (("%num_states%" * 0x10) + "%off_states%" + 0x10) "%selected%"
        END
      END
   END
 END
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: devSin on February 04, 2005, 09:45:11 PM
Make sure you check out the CRE sound slots at 0x0198 and 0x019c (labeled DIALOG_DEFAULT and DIALOG_HOSTILE in NI). These control the creature's "no valid states" dialogue (this is the reason that Arthur, in the Graveyard District, gives a "You visit again..." speech instead of "has nothing to say to you").
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on February 04, 2005, 10:14:47 PM
Make sure you check out the CRE sound slots at 0x0198 and 0x019c (labeled DIALOG_DEFAULT and DIALOG_HOSTILE in NI). These control the creature's "no valid states" dialogue (this is the reason that Arthur, in the Graveyard District, gives a "You visit again..." speech instead of "has nothing to say to you").

Aha, excellent!  Although it still displays the "X has nothing to say to you" message, the string is done, too.  One thing to note is that this only appears to work if the character has a .dlg file assigned.  I took away the dialogue from _0_ftowbe.cre, set her DIALOG_DEFAULT and _HOSTILE to her select common string, and it didn't work.  This means we may need to assign dummy .dlg file to, say, horses and stuff.

Thanks a bunch.  Tutu will become that much more like BG1 now.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: SimDing0™ on February 05, 2005, 03:37:03 AM
Make sure you check out the CRE sound slots at 0x0198 and 0x019c (labeled DIALOG_DEFAULT and DIALOG_HOSTILE in NI). These control the creature's "no valid states" dialogue (this is the reason that Arthur, in the Graveyard District, gives a "You visit again..." speech instead of "has nothing to say to you").
You are the best person ever.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Ghreyfain on February 05, 2005, 11:23:13 AM
What do you know about getting charmed critters to talk? ;)
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Andyr on February 05, 2005, 11:42:58 AM
Incidentally, saying SAY DIALOG_DEFAULT or SAY DIALOG_HOSTILE (or SAY UNHAPPY_BREAKING_POINT) in a .tp2 when you're making your CRE gives a WeiDU error (it doesn't recognise the terms), so you have to SAY at the appropriate offsets instead. Unless we can ask Wes to add those three in.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: devSin on February 05, 2005, 08:29:30 PM
Incidentally, saying SAY DIALOG_DEFAULT or SAY DIALOG_HOSTILE (or SAY UNHAPPY_BREAKING_POINT) in a .tp2 when you're making your CRE gives a WeiDU error (it doesn't recognise the terms), so you have to SAY at the appropriate offsets instead.

SAY DIALOGUE_DEFAULT #0
SAY DIALOGUE_HOSTILE ~Whatever.~

If you're ever unsure about which named constants are supported, you should always check src/var.ml. For reference, WeiDU v174 =
Code: [Select]
  assoc "AREA_CITY" 0252 ;
  assoc "AREA_DAY" 0260 ;
  assoc "AREA_DUNGEON" 0256 ;
  assoc "AREA_FOREST" 0248 ;
  assoc "AREA_NIGHT" 0264 ;
  assoc "ATTACK1" 0220 ;
  assoc "ATTACK2" 0224 ;
  assoc "ATTACK3" 0228 ;
  assoc "ATTACK4" 0232 ;
  assoc "BATTLE_CRY1" 0200 ;
  assoc "BATTLE_CRY2" 0204 ;
  assoc "BATTLE_CRY3" 0208 ;
  assoc "BATTLE_CRY4" 0212 ;
  assoc "BATTLE_CRY5" 0216 ;
  assoc "BIO"  0x1cc ;
  assoc "BORED" 0196 ;
  assoc "COMPLIMENT1" 0352 ;
  assoc "COMPLIMENT2" 0356 ;
  assoc "COMPLIMENT3" 0360 ;
  assoc "CRITICAL_HIT" 0424 ;
  assoc "CRITICAL_MISS" 0428 ;
  assoc "DAMAGE" 0236 ;
  assoc "DESC"  0x54 ;
  assoc "DIALOGUE_DEFAULT" 0412 ;
  assoc "DIALOGUE_HOSTILE" 0408 ;
  assoc "DYING" 0240 ;
  assoc "EXISTANCE1" 0444 ;
  assoc "EXISTANCE2" 0448 ;
  assoc "EXISTANCE3" 0452 ;
  assoc "EXISTANCE4" 0456 ;
  assoc "EXISTANCE5" 0460 ;
  assoc "HAPPY" 0172 ;
  assoc "HURT" 0244 ;
  assoc "IDENTIFIED_DESC"  0x54 ;
  assoc "INITIAL_MEETING" 0164 ;
  assoc "INSULT" 0340 ;
  assoc "INTERACTION1" 0320 ;
  assoc "INTERACTION2" 0324 ;
  assoc "INTERACTION3" 0328 ;
  assoc "INTERACTION4" 0332 ;
  assoc "INTERACTION5" 0336 ;
  assoc "INVENTORY_FULL" 0436 ;
  assoc "LEADER" 0188 ;
  assoc "MISCELLANEOUS" 0384 ;
  assoc "MORALE" 0168 ;
  assoc "NAME1" 8 ;
  assoc "NAME2" 12 ;
  assoc "PICKED_POCKET" 0440 ;
  assoc "REACT_TO_DIE_GENERAL" 0376 ;
  assoc "REACT_TO_DIE_SPECIFIC" 0380 ;
  assoc "RESPONSE_TO_COMPLIMENT2" 0388 ;
  assoc "RESPONSE_TO_COMPLIMENT3" 0392 ;
  assoc "RESPONSE_TO_INSULT1" 0396 ;
  assoc "RESPONSE_TO_INSULT2" 0400 ;
  assoc "RESPONSE_TO_INSULT3" 0404 ;
  assoc "SELECT_ACTION1" 0292 ;
  assoc "SELECT_ACTION2" 0296 ;
  assoc "SELECT_ACTION3" 0300 ;
  assoc "SELECT_ACTION4" 0304 ;
  assoc "SELECT_ACTION5" 0308 ;
  assoc "SELECT_ACTION6" 0312 ;
  assoc "SELECT_ACTION7" 0316 ;
  assoc "SELECT_COMMON1" 0268 ;
  assoc "SELECT_COMMON2" 0272 ;
  assoc "SELECT_COMMON3" 0276 ;
  assoc "SELECT_COMMON4" 0280 ;
  assoc "SELECT_COMMON5" 0284 ;
  assoc "SELECT_COMMON6" 0288 ;
  assoc "SELECT_RARE1" 0416 ;
  assoc "SELECT_RARE2" 0420 ;
  assoc "SPECIAL1" 0364 ;
  assoc "SPECIAL2" 0368 ;
  assoc "SPECIAL3" 0372 ;
  assoc "TARGET_IMMUNE" 0432 ;
  assoc "TIRED" 0192 ;
  assoc "UNHAPPY_ANNOYED" 0176 ;
  assoc "UNHAPPY_BREAKING" 0184 ;
  assoc "UNHAPPY_SERIOUS" 0180 ;
  assoc "UNIDENTIFIED_DESC" 0080 ;
  assoc "HIDDEN_IN_SHADOWS" 0444 ;
  assoc "SPELL_DISRUPTED" 0448 ;
  assoc "SET_A_TRAP" 0452 ;
  assoc "STORE_NAME" 12 ;
  assoc "SCRIPT_OVERRIDE" 0x248 ;
  assoc "SCRIPT_CLASS" 0x250 ;
  assoc "SCRIPT_RACE" 0x258 ;
  assoc "SCRIPT_GENERAL" 0x260 ;
  assoc "SCRIPT_DEFAULT" 0x268 ;
  assoc "DEATHVAR" 0x280 ;
  assoc "DIALOG" 0x2cc ;
  assoc "AREA_SCRIPT" 0x94 ;
  assoc "SCRIPT_AREA" 0x94 ;
  assoc "PORTRAIT_SMALL" 0x34 ;
  assoc "PORTRAIT_LARGE" 0x3c ;
Longest post EVAR. :P
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Andyr on February 06, 2005, 10:27:49 AM
Oh, hmm. I copy-pasted from NI and it gave me an error because I had DIALOG not DIALOGUE. Still might be nice to ask for both spellings (US and UK) to be supported.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: devSin on February 06, 2005, 11:35:42 AM
Oh, hmm. I copy-pasted from NI and it gave me an error because I had DIALOG not DIALOGUE. Still might be nice to ask for both spellings (US and UK) to be supported.

Dialogue is "proper" English (think "monologue," "epilogue," "prologue," etc.). That said, I personally hate it, but what can you do?
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: Andyr on February 06, 2005, 11:39:05 AM
Yeh, I know. I'm an Englishman myself. ;) It's good that the scripting actions and so forth accept both spellings, else there'd be many a typo.
Title: Re: Simulating BG1 dialogue behaviour in BG2 (when an NPC has no valid dialogue)
Post by: jcompton on February 06, 2005, 11:39:58 AM
Generally if you send Wes the synonyms you want, formatted for those files, and say, "Yo, please put these in file blah.ml for the next version", he does so.