I have seen this used somewhere (and have speculated that it was a good way around some compatability hassles, though in the posts about this idea I think JCompton pointed out I was doing alot of extra garbage playing the "shell game" with swapping around dialog files this way).
(This is old news to Kulyok, but for people who are not as versed in scripting/closing variables in dialog, the breakdown and fleshing out of this idea goes like this:
138 SetDialog(S:DialogFile*)
138 SetDialogue(S:DialogFile*)
in the npc .baf =
IF
RealGlobalTimerExpired("myTimer","GLOBAL")
InParty("myNPC")
!Statecheck("myNPC",CD_STATE_NOTVALID)
InParty(Player1)
See(Player1)
!Statecheck(Player1,CD_STATE_NOTVALID)
Global("myGlovbalVariable","GLOBAL",1)
THEN RESPONSE #100
ActionOverride("myNPC",SetDialog("C-NEWINT"))
Global("myGlobalVariable","GLOBAL",2)
Wait(1)
StartDialogNoSet(Player1)
END
in the .d =
/* reset the [original or joined] dialog file at the end of the state when you advance the variable and set timers */
IF ~Global("myGlobalVariable","GLOBAL",2)~ myNewState
SAY ~[MYNPC] Hey, this line is coming out of a new dialog file that contains only stuff from myMod, thus is not messed with by anyone modifying the original dialog~
IF ~~ THEN DO ~ActionOverride("myNPC",SetDialog("myNPCJ")) Global("myGlobalVariable","GLOBAL",3) RealSetGlobalTimer("myTimer","GLOBAL",400)~ EXIT
END
Only minor problems -
while lots of stuff sets dialog to default using this kind of scripting, not much out there plays this game, so it is theoretical not "tested exensively in the field" I wuz wrong. It is used. If something hangs up on the script running, you end up with a stutter (trying to clear a dialog set on the original dialog file while when the .cre in question is assigned your mod's dialog file). I think if you are looking at doing something like this, you are probably safest using a form of Kulyok's IWD and similar work, scripting using cutscene mode and being aggressive with checks to revert dialog files. I don't know about using separated .bcs blocks under those conditions.
EDIT: serves me right for posting before running the search of existing NPC's code -.
Amber does this, BTL does this, and Chloe does this, Edwin Flirtpack does this, Imoen v12 does this, Kiara-Zaiya does this (once), LongerRoad_v1.5.1 does it once, TSv611 does it once for Yoshimo, and Weimer-SolaufeinMod-v103 does it extensively.
Sample code from Weimer:
///////////////////////////////////////////////////////////////////////
// If we're in ToB, quickly change back to using the old dialogue
// files.
///////////////////////////////////////////////////////////////////////
IF
Global("SolaGoingToBanter","GLOBAL",1)
GlobalGT("Chapter","GLOBAL",7) // >7 --> in ToB
CombatCounter(0)
THEN
RESPONSE #100
StartCutSceneMode()
SetGlobal("SolaPickingBanterTarget","GLOBAL",0)
SetGlobal("SolaGoingToBanter","GLOBAL",0)
ActionOverride("Aerie",SetDialogue("BAERIE"))
ActionOverride("Anomen",SetDialogue("BANOMEN"))
ActionOverride("Cernd",SetDialogue("BCERND"))
ActionOverride("Edwin",SetDialogue("BEDWIN"))
ActionOverride("HaerDalis",SetDialogue("BHAERDA"))
ActionOverride("Imoen2",SetDialogue("IMOEN2J"))
ActionOverride("Jaheira",SetDialogue("BJAHEIR"))
ActionOverride("Jan",SetDialogue("BJAN"))
ActionOverride("Keldorn",SetDialogue("BKELDOR"))
ActionOverride("Korgan",SetDialogue("BKORGAN"))
ActionOverride("Mazzy",SetDialogue("BMAZZY"))
ActionOverride("Minsc",SetDialogue("BMINSC"))
ActionOverride("Nalia",SetDialogue("BNALIA"))
ActionOverride("Valygar",SetDialogue("BVALYGA"))
ActionOverride("Viconia",SetDialogue("BVICONI"))
// Sarevok needs no change
RealSetGlobalTimer("SolaBanter","GLOBAL",6400)
SetGlobal("Sola_Try_Aerie","GLOBAL",0)
SetGlobal("Sola_Try_Anomen","GLOBAL",0)
SetGlobal("Sola_Try_Cernd","GLOBAL",0)
SetGlobal("Sola_Try_Edwin","GLOBAL",0)
SetGlobal("Sola_Try_HD","GLOBAL",0)
SetGlobal("Sola_Try_Imoen","GLOBAL",0)
SetGlobal("Sola_Try_Jan","GLOBAL",0)
SetGlobal("Sola_Try_Jaheira","GLOBAL",0)
SetGlobal("Sola_Try_Keldorn","GLOBAL",0)
SetGlobal("Sola_Try_Korgan","GLOBAL",0)
SetGlobal("Sola_Try_Mazzy","GLOBAL",0)
SetGlobal("Sola_Try_Minsc","GLOBAL",0)
SetGlobal("Sola_Try_Nalia","GLOBAL",0)
SetGlobal("Sola_Try_Valygar","GLOBAL",0)
SetGlobal("Sola_Try_Viconia","GLOBAL",0)
SetGlobal("Sola_Try_Sarevok","GLOBAL",0)
StartDialogueNoSet(Player1)
END
///////////////////////////////////////////////////////////////////////
// Otherwise just banter
///////////////////////////////////////////////////////////////////////
IF
Global("SolaGoingToBanter","GLOBAL",1)
!GlobalGT("Chapter","GLOBAL",7) // >7 --> in ToB
CombatCounter(0)
THEN
RESPONSE #100
StartCutSceneMode()
SetGlobal("SolaPickingBanterTarget","GLOBAL",0)
SetGlobal("SolaGoingToBanter","GLOBAL",0)
RealSetGlobalTimer("SolaBanter","GLOBAL",6400)
SetGlobal("Sola_Try_Aerie","GLOBAL",0)
SetGlobal("Sola_Try_Anomen","GLOBAL",0)
SetGlobal("Sola_Try_Cernd","GLOBAL",0)
SetGlobal("Sola_Try_Edwin","GLOBAL",0)
SetGlobal("Sola_Try_HD","GLOBAL",0)
SetGlobal("Sola_Try_Imoen","GLOBAL",0)
SetGlobal("Sola_Try_Jan","GLOBAL",0)
SetGlobal("Sola_Try_Jaheira","GLOBAL",0)
SetGlobal("Sola_Try_Keldorn","GLOBAL",0)
SetGlobal("Sola_Try_Korgan","GLOBAL",0)
SetGlobal("Sola_Try_Mazzy","GLOBAL",0)
SetGlobal("Sola_Try_Minsc","GLOBAL",0)
SetGlobal("Sola_Try_Nalia","GLOBAL",0)
SetGlobal("Sola_Try_Valygar","GLOBAL",0)
SetGlobal("Sola_Try_Viconia","GLOBAL",0)
SetGlobal("Sola_Try_Sarevok","GLOBAL",0)
StartDialogueNoSet(Player1)
END
///////////////////////////////////////////////////////////////////////
// Restore those TOB dialogue files
///////////////////////////////////////////////////////////////////////
IF
Global("SolaDoneBanter","GLOBAL",1)
GlobalGT("Chapter","GLOBAL",7) // >7 --> in ToB
THEN
RESPONSE #100
SetGlobal("SolaDoneBanter","GLOBAL",0)
ActionOverride("Aerie",SetDialogue("AERIE25J"))
ActionOverride("Anomen",SetDialogue("ANOME25J"))
ActionOverride("Cernd",SetDialogue("CERND25J"))
ActionOverride("Edwin",SetDialogue("EDWIN25J"))
ActionOverride("HaerDalis",SetDialogue("HAERD25J"))
ActionOverride("Imoen2",SetDialogue("IMOEN25J"))
ActionOverride("Jaheira",SetDialogue("JAHEI25J"))
ActionOverride("Jan",SetDialogue("JAN25J"))
ActionOverride("Keldorn",SetDialogue("KELDO25J"))
ActionOverride("Korgan",SetDialogue("KORGA25J"))
ActionOverride("Mazzy",SetDialogue("MAZZY25J"))
ActionOverride("Minsc",SetDialogue("MINSC25J"))
ActionOverride("Nalia",SetDialogue("NALIA25J"))
ActionOverride("Valygar",SetDialogue("VALYG25J"))
ActionOverride("Viconia",SetDialogue("VICON25J"))
EndCutSceneMode()
// Sarevok needs no change
END
IF
Global("SolaDoneBanter","GLOBAL",1)
!GlobalGT("Chapter","GLOBAL",7) // <=7 --> in SoA
THEN
RESPONSE #100
SetGlobal("SolaDoneBanter","GLOBAL",0)
EndCutSceneMode()
END
Looks like he solved the possible problems with those StartCutSceneMode() || EndCutSceneMode() calls. Noone else is as detailed - but Chloe starts the dialog from the file directly for the NPC:
IF
OR(2)
Global("InAbagailQuestCR","GLOBAL",2)
Global("InAbagailQuestCR","GLOBAL",3)
AreaCheck("AR0528")
THEN
RESPONSE #100
SetGlobal("InAbagailQuestCR","GLOBAL",4)
ActionOverride("AbbyHuCR",SetDialog("AbbyCR"))
ActionOverride("AbbyVaCR",SetDialog("AbbyCR"))
Wait(1)
ActionOverride("AbbyHuCR",FaceObject(Player1))
ActionOverride("AbbyVaCR",FaceObject(Player1))
Wait(2)
ActionOverride("AbbyHuCR",StartDialog("AbbyCR",Player1))
ActionOverride("AbbyVaCR",StartDialog("AbbyCR",Player1))
END
with Wait(#) to allow the game to process, I guess.
Amber uses the dialog reset within dialog successfully, too:
// Amber's kidnapping - quest. Dialogs for the Slaver, Corin, Lorraine, Guard captain, Bathing guard, Cook, Maid, Demon, Gabriel, Nyphs, Ymmyrt, Soul Machine and Lorraine's son.
BEGIN ~M#KCUT~
IF ~True()~ THEN BEGIN Intro
SAY @3109 /* @3109 = ~Ah, there you are, tiefling. I have been looking for you.~ */
IF ~RandomNum(4,1)~ THEN DO ~ActionOverride("M#Amber",SetDialog("m#ambern"))~ GOTO Continuation1
IF ~RandomNum(4,2)~ THEN DO ~ActionOverride("M#Amber",SetDialog("m#ambern"))~ GOTO Continuation2
IF ~RandomNum(4,3)~ THEN DO ~ActionOverride("M#Amber",SetDialog("m#ambern"))~ GOTO Continuation3
IF ~RandomNum(4,4)~ THEN DO ~ActionOverride("M#Amber",SetDialog("m#ambern"))~ GOTO Continuation4
END
a .bcs call to make absolutely sure the correct dialog file is set for her kidnapping:
// Amber's Kidnapping Quest
IF
Global("M#AmberKidnap","GLOBAL",8)
AreaCheck("m#ar01")
Detect(Player1)
THEN
RESPONSE #100
Wait(1)
FaceObject(Player1)
DisplayStringHead(Myself,@77)
Wait(2)
SetDialog("m#amberp")
PlaySong(999997)
Dialog(Player1)
END
It looks like the most modern and extensive source is Amber, as she shifts between m#amberj, m#ambern, etc. within both .baf and .d.