Thought I'd try to post my rumour-adding code (originally used in the Gavin mod) as an actual tutorial. It's fairly straightforward to add tavern rumours, but it requires a bit of hackery to work with
BG2.
BG1/Tutu rumours are easy, because apparently they have a built in randomiser, but
BG2 rumour .dlg files have a hardcoded randomness. So we have to read that and increment it by the number of rumours we're adding, something like this:
//! Dialogue and script compiling (BG2 and BGT) /////////////////////////////
OUTER_SET t-rda = 14 //Variables that get replaced by random numbers
OUTER_SET t-rdb = 14
OUTER_SET t-rdc = 13
COPY_EXISTING ~rumora.dlg~ ~override~ //Athkatla rumors
PATCH_IF SOURCE_SIZE > 0x34 BEGIN
DECOMPILE_DLG_TO_D
REPLACE_TEXTUALLY CASE_SENSITIVE EXACT_MATCH ~,GLOBAL~ ~,"GLOBAL~
REPLACE_EVALUATE CASE_INSENSITIVE ~RandomNum(\([0-9]+\),~ BEGIN
t-rdm = %MATCH1%
PATCH_IF t-rdm > 11 BEGIN
t-rda = %MATCH1% + 2
t-rdb = %MATCH1% + 2
t-rdc = %MATCH1% + 1
END ELSE BEGIN
t-rda = %MATCH1%
END
END ~RandomNum(%t-rda%,~
COMPILE_D_TO_DLG
END
BUT_ONLY
COPY ~mymod/compile/t-rumora.d~ ~mymod/compile/t-rumora.d~
REPLACE_TEXTUALLY CASE_INSENSITIVE ~t-rdb~ ~%t-rdb%~
REPLACE_TEXTUALLY CASE_INSENSITIVE ~t-rdc~ ~%t-rdc%~
COPY_EXISTING ~rumori.dlg~ ~override~ //Imnesvale rumors
PATCH_IF SOURCE_SIZE > 0x34 BEGIN
DECOMPILE_DLG_TO_D
REPLACE_EVALUATE CASE_INSENSITIVE ~RandomNum(\([0-9]+\),~ BEGIN
t-rda = %MATCH1% + 2
t-rdb = %MATCH1% + 1
END ~RandomNum(%t-rda%,~
COMPILE_D_TO_DLG
END
BUT_ONLY
COPY ~mymod/compile/t-rumori.d~ ~mymod/compile/t-rumori.d~
REPLACE_TEXTUALLY CASE_INSENSITIVE ~t-rda~ ~%t-rda%~
REPLACE_TEXTUALLY CASE_INSENSITIVE ~t-rdb~ ~%t-rdb%~
COPY_EXISTING ~rumort.dlg~ ~override~ //Trademeet rumors
PATCH_IF SOURCE_SIZE > 0x34 BEGIN
DECOMPILE_DLG_TO_D
REPLACE_EVALUATE CASE_INSENSITIVE ~RandomNum(\([0-9]+\),~ BEGIN
t-rda = %MATCH1% + 2
t-rdb = %MATCH1% + 1
END ~RandomNum(%t-rda%,~
COMPILE_D_TO_DLG
END
BUT_ONLY
COPY ~mymod/compile/t-rumort.d~ ~mymod/compile/t-rumort.d~
REPLACE_TEXTUALLY CASE_INSENSITIVE ~t-rda~ ~%t-rda%~
REPLACE_TEXTUALLY CASE_INSENSITIVE ~t-rdb~ ~%t-rdb%~
COPY_EXISTING ~rumoru.dlg~ ~override~ //Underdark rumors
PATCH_IF SOURCE_SIZE > 0x34 BEGIN
DECOMPILE_DLG_TO_D
REPLACE_EVALUATE CASE_INSENSITIVE ~RandomNum(\([0-9]+\),~ BEGIN
t-rda = %MATCH1% + 2
t-rdb = %MATCH1% + 1
END ~RandomNum(%t-rda%,~
COMPILE_D_TO_DLG
END
BUT_ONLY
COPY ~mymod/compile/t-rumort.d~ ~mymod/compile/t-rumort.d~
REPLACE_TEXTUALLY CASE_INSENSITIVE ~t-rda~ ~%t-rda%~
REPLACE_TEXTUALLY CASE_INSENSITIVE ~t-rdb~ ~%t-rdb%~
COMPILE ~mymod/compile~
The actual dialogues we're compiling look like this (well, they don't really - I've substituted generic text here to avoid spoiling actual mods):
APPEND rumora //Athkatla rumors
IF ~RandomNum(t-rdb,t-rdc)
~ THEN BEGIN t-ath1
SAY @0 /* ~I heard this about that. Possibly an old wives' tale, but there may be something to it... a traveler from Trademeet said something about this or that too, it seems.~ */
IF ~~ THEN EXIT
END
//Enables a rumour for all Athkatla rumourmongers *except* Aurora
IF ~RandomNum(t-rdb,t-rdb)
!Dead("agaurora")
!Name("agaurora",Myself)
~ THEN BEGIN t-ath2
SAY @1 /* ~Think there's a lot of gossip in the taverns? Ha! Go talk to the boot-vendor Aurora in the Bridge District.~ */
IF ~~ THEN EXIT
END
END
APPEND rumori //Imnesvale rumors
IF ~RandomNum(t-rda,t-rdb)
Global("t-gnome2","GLOBAL",0)
~ THEN BEGIN t-imn1
SAY @0 /* ~Some damn fool went up north and did something foolish. The fool's been gone for a while now. If the wandering monsters didn't get him, he probably slipped and broke his head.~ */
IF ~~ THEN EXIT
END
IF ~RandomNum(t-rda,t-rda)
~ THEN BEGIN t-imn2
SAY @1 /* ~Local legends something about some brave so-and-so and some bad guy who was terrorizing these parts.~ */
IF ~~ THEN EXIT
END
END
APPEND rumort //Trademeet rumors
IF ~RandomNum(t-rda,t-rdb)
~ THEN BEGIN t-tr1
SAY @0 /* ~Might want to check the stock in some shop or other, I'd give you more details if this were a real rumor.~ */
IF ~~ THEN EXIT
END
IF ~RandomNum(t-rda,t-rdb)
!Dead("agkaraea")
~ THEN BEGIN t-tr2
SAY @1 /* ~This is yet another potentially bogus rumor.~ */
IF ~~ THEN EXIT
END
END
APPEND rumoru //Underdark rumors
IF ~RandomNum(t-rda,t-rdb)
~ THEN BEGIN t-ud1
SAY @0 /* ~Dark times indeed, dark even for the Underdark.~ */
IF ~~ THEN EXIT
END
IF ~RandomNum(t-rda,t-rda)
~ THEN BEGIN t-ud2
SAY @1 /* ~Blah, blah blah.~ */
IF ~~ THEN EXIT
END
END
There's one each for Athkatla, Imnesvale, Trademeet and the Underdark. Tutu/
BG1/
BGT rumours are a bit more straightforward (there are examples of this in the Gavin mod). But it's similar to
BG2. You can cover Tutu/
BGT/
BG1 by using a "tutu_var" that is set to ~_~ if GAME_IS ~tutu tutu_totsc~ but ~~ otherwise (plenty of mods that use this, also covered in posts on gibberlings3.net).
//Baldur's Gate rumours
APPEND %tutu_var%rbaldu
IF ~True()~ THEN BEGIN t-bald1
SAY @0 /* ~I heard this about that, or maybe that about this.~ */
IF ~~ THEN EXIT
END
END
//Beregost rumours
APPEND %tutu_var%rbereg
IF ~Global("myvar","GLOBAL",0)
~ THEN BEGIN t-ber1
SAY @0 /* ~Local legends say that someone vanished to do this, that or perhaps something else entirely.~ */
IF ~~ THEN UNSOLVED_JOURNAL @1 /* ~Journal heading
We heard about a possible quest to do this and that.~ */ EXIT
END
END
//Candlekeep rumours
APPEND %tutut_var%rcandl
IF ~True()~ THEN BEGIN t-can1
SAY @0 /* ~I shouldn't be tellin' you much about anything at this point, you neophyte.~ */
IF ~~ THEN EXIT
END
END
//Friendly Arm rumours
APPEND %tutu_var%rfrien
IF ~Global("myvar2","GLOBAL",0)
~ THEN BEGIN ag_frn1
SAY @0 /* ~Yet another lead for your foolish band to investigate goes here.~ */
IF ~~ THEN UNSOLVED_JOURNAL @1 /* ~Journal entry
Sigh, I'm getting sick of these quests, but we heard about this or that again.~ */ EXIT
END
END
//Nashkel rumours
APPEND %tutu_var%rnashk
IF ~True()~ THEN BEGIN t-nsh1
SAY @0 /* ~There's something odd going on hereabouts, or haven't you heard yet?~ */
IF ~~ THEN EXIT
END
END
Apparently you can just COMPILE
BG1 rumours without doing the fancy jiggling to append random numbers in
BG2. (Presumably, these files handle the random weighting internally, though I haven't tested that extensively.) Note that these examples assume you're using .tra files and AUTO_TRA as the
WeiDU documentation details. If not, you can omit the @ references and comments and just use plain text (so SAY ~Blah blah blah.~ instead of SAY @1 /* ~Blah blah blah.~ */). Use your own modder's prefix instead of t- and your own mod name instead of mymod, etc. (Also real rumour text instead of generic rubbish heh.)