Skip to content

[Tutorial] jastey's SoD NPC Modding Tutorials

jasteyjastey Member Posts: 2,669
edited April 2022 in BG:EE Mods
The tutorials contain SoD plot spoilers, obviously.

Here are the links to my SoD modding tutorials:
Modding Tutorial Part 1: Automatic Transition of NPCs into SoD and between Camps in SoD
Modding Tutorial Part 2: Make Your NPC Comment and Move Along at the End of SoD
Modding Tutorial Part 3: Add Other General SoD Behavior to Your NPC: XP Adjustment, Actions in Story Cutscenes, Commenting of Main Story Events
Modding Tutorial Part 4: How to Script the SoD Banter System for Your NPC

And here is all the knowledge of all tutorials bundled into a working NPC mod:
Biff the Understudy Tutorial NPC Mod for SoD
Please note: the mod is working, but Biff has a basic cre, no items, no portrait, and no soundset. The focus of the mod is on the scripting described in the tutorials.

Please Note: The tutorials are to my best knowledge at the current time. I am not done with modding my NPCs for SoD yet, though, so it might well be that some details will change in the future. If you mod using these tutorials, be on the lookout for changes.


Descriptions:
Modding Tutorial Part 1: Automatic Transition of NPCs into SoD and between Camps in SoD

This tutorial deals with the transition of an NPC from BG:EE to SoD and how to move your NPC from one SoD area to another depending on the campaign's progress if they are not in the group. As an example NPC, Biff the Understudy will be the NPC in this guide!
In SoD, joinable NPCs that are not in the party will still be present and waiting in whichever camp the coalition is staying currently. This tutorial lists all relevant scripts that need to be patched for a mod NPC to make them behave the same way.
It contains examples of what and how to add to the scripts so your mod NPC will be moved around SoD camps during the progressing SoD campaign in case they are not in the party, too.

Modding Tutorial Part 2: Make Your NPC Comment and Move Along at the End of SoD

This tutorial deals with how to integrate your NPC into the events and cutscenes at the end of SoD. Biff the Understudy will be the example NPC in this guide.

Note: This tutorial contains heavy SoD spoilers.

Modding Tutorial Part 3: Add Other General SoD Behavior to Your NPC: XP Adjustment, Actions in Story Cutscenes, Commenting of Main Story Events

This tutorial deals with giving your NPC some general script additions like XP adjustment upon joining, removing of Story Mode upon leaving the group, letting the NPC move in cutscenes if not in party, and inclusion into general NPC reaction points to the main game events.

The listed situations in this tutorial are the ones where general reactions depending on class, race, or alignment of all or several NPCs in group are included in the game and where a mod NPC should not be missing. It does not give examples of possible interjection points depending on individual NPCs' character or personal reactions to game events etc.

The tutorial now includes all instances I could find by browsing the game files. Let me know if I missed anything or if you have general critique. The tutorial might change after I finished my own NPC mods for SoD.

Modding Tutorial Part 4: How to Script the SoD Banter System for Your NPC

This tutorial deals with how to make your NPC banter with the other party NPCs like it is custom in SoD. In SoD, banters of party NPCs are done via floating text above their heads while the player wanders about the areas. As an example NPC, Biff the Understudy will be the NPC in this guide, bantering with Corwin two times: the first banter will be started by Biff, the second by Corwin. Read through the chapters to see how the needed files play together.

The examples are such that the banter can be also offered in "dialogue style" like they are in BG2. How to do this as an optional component of your mod is explained in Chapter 4.

Post edited by jastey on
SkitiaGusindaevildevil97RaduzielAedanLavaDelVortelJuliusBorisovRavenslightArdanisTimbo0o0o0AciferVasculioStummvonBordwehr
«1

Comments

  • RaduzielRaduziel Member Posts: 4,714
    Thanks, jastey!

    It is so well made that even I am understanding!
  • jasteyjastey Member Posts: 2,669
    Heh. I'll take that as a compliment. :)

    If anyone spots an error or has suggestions, please let me know!
    RaduzielAcifer
  • SkitiaSkitia Member Posts: 1,052
    I missed a few details in my own interpretation so I'll add those in to my scripts, thanks for sharing this.

    My only suggestion is some embellishment outlines, details to help make your character more immersed in the situation. For example, in BDCUT05, Beamdog puts the followers you can get so far around a table after you wake up for the morning march. It'd be useful to know how to put them in that same situation (I couldn't make it work with an extend of BDCUT05, and called it from the area instead.

    It's similar to when the march starts to Coast Way Crossing, if your NPC is not in the party, they'll just sit there. If you add them to BDCUT08 with the right instructions, they'll march with everyone else in a more immersive experience. Suggestions like that would be helpful!

    I didn't spot any errors.
  • jasteyjastey Member Posts: 2,669
    edited March 2019
    Thanks for the feedback! The next tutorial I'm writing deals with the leaving the group and reappearing and moving across areas in the ending of SoD.
    The "make your NPC react to and add your NPC to SoD main events" or whatever it could be called what you are referring to would be tutorial number 3.
    @Skitia I think by now you have better insight into these points where NPCs are moved / placed / do comment on SoD events. If you would share your findings here, I'd had an easier starting point for writing things up.
    What I identified so far:
    - after Korlasz is defeated (NPCs announce their leaving): DisplayStringHead in bd0120.bcs or bd0130.bcs
    - in case the NPC remained in the party: wake up in Ducal Palace (bd0103.bcs)
    - in case NPC remained in party: move from stairs to middle of the room to the meeting with the Dukes after the attack in the Ducal Palace (bd0102.bcs) - didn't get this to work yet, maybe it's ok for NPCs to remain at the stairs since the Dukes would want to talk to the PC, only
    - Reaction to Caelar's first appearance on bridge (bd1000.bcs)
    - comment after the portal is opened / Hephernann's scheme (bd4300.bcs)
    - portal is opened: comment after first wave of demons (if the PC heistates to go into the portal), bd4300.bcs
    - comment inside Avernus, bd4400.bcs
    - Thrix's game (BDTHRIX.dlg with following reactions of the NPC if his soul was at play)
    - comment in Hell elevator, bd4601.bcs
    - Fugue portal - reaction to enemies (bd5300.bcs)
    - comments on murder accusation, bd4100.bcs
    I identified more interjection points for individual NPC responses, of course, but for the tutorial I wanted to focus on the "must haves" of NPC reactions or "moving with the group" events.
    I'll have a look at BDCUT05.bcs. The cutscenes make adding new NPCs hard at some points. I have full understanding that "addability" of mod NPCs wasn't the devs main concern, but it's still a bit frustrating.
    Acifer
  • jasteyjastey Member Posts: 2,669
    The first post was updated with another tutorial:
    Modding Tutorial Part 4: How to Script the SoD Banter System for Your NPC
    This tutorial deals with how to make your NPC banter with the other party NPCs like it is custom in SoD. In SoD, banters of party NPCs are done via floating text above their heads while the player wanders about the areas. As an example NPC, Biff the Understudy will be the NPC in this guide, bantering with Corwin.

    "Part 4" because I have already other tutorials planned for 2 and 3.
    RaduzielAcifer
  • RaduzielRaduziel Member Posts: 4,714
    Hi,

    Passing by just to say that this tutorial gave me some motivation to make a SoD NPC, even hating SoD.

    Thanks!
    Acifer
  • jasteyjastey Member Posts: 2,669
    Great to hear it! I surely hope the tutorials will save other people a lot of time.

    If anyone spots anything or has comments, please let me know!
    Acifer
  • SkitiaSkitia Member Posts: 1,052
    This is going to save a lot of time. The only unfortunate thing is now I have to re-write my banters for a third time! I can't in good conscience not change it to more flawless coding.
  • jasteyjastey Member Posts: 2,669
    Well, the credit for that goes to BeamDog haha, since I'm just trying to note down how they've done it.

    Let me know in case you find something!
    Acifer
  • SkitiaSkitia Member Posts: 1,052
    edited April 2019
    I notice you have small waits in your BD0103 script. Is it because Beamdog does the same, or is it good practice to give the game a bit of pause between each command line?

    I also wrote all of my kickout dialogue in example, X32mily.dlg, rather than a X32milyP.dlg, does that make a difference? Or is it better practice to have the kickout dialogue in its own file?


    I tried doing it with a P style inside, but that didn't seem to work at all for me.
    Post edited by Skitia on
  • jasteyjastey Member Posts: 2,669
    If it works for your NPC, then you don't need to switch to using another dialogue. Just keep in mind to set / reset the mentioned local variables if you want to make use of the SoD specific scripts (pdparty.bcs etc.)
    If you do want to find out why using the P didn't work for you, I can help you debug. Maybe I missed something in my tutorial (I hope not, of course). I used my experiences with Breagar and three private NPCs in the making for the tutorials but it might well be I overlooked a tiny detail.

    I used the SmallWait() because BeamDog used them, but I made experiences with script commands not being executed in cutscenes unless there is a short waiting, so I just left them in, trusting on the devs experiences. I don't know how many times I fought with cutscenes not working properly although all commands where ok in principle, and then finally a "Wait(1)" did the miracle, so if I have a template that uses a (Small)Wait() somewhere, I'm not going to try whether it will work without. :D
    Acifer
  • SkitiaSkitia Member Posts: 1,052
    My educated guess is that I did not set up my TP2/TPA file correctly. That said I reverted it to having everything called within the regular X32mily file and just set up variables in a way that the correct parameters would always be called.

    Would the prefix matter, by the way? I am using (2) instead of (B).

    Is there also a clean way to assign the imported NPC their new scripts? When working on my mod yesterday, my NPC was constantly trying to start up dialogue until I reloaded, in which the correct script finally came in place. I had to add a line for her "recruit me" dialogue to fire only in the area it was supposed to do so to patch it.
  • jasteyjastey Member Posts: 2,669
    What is an X32mily file?
    Is there also a clean way to assign the imported NPC their new scripts?
    You mean when coming from BG:EE, switching to the SoD script? I think that's done in bdintro.bcs, for example for Minsc:
    IF
    	Global("SOD_fromimport","global",1)
    	InMyArea("minsc")  // Minsc
    THEN
    	RESPONSE #100
    		CutSceneId(Player1)
    		ActionOverride("minsc",SetDialog("bdminscj"))
    		ActionOverride("minsc",ChangeAIScript("bdminsc",OVERRIDE))
    END
    
    It needs to be patched using EXTEND_TOP, and I would try making the CutSceneId() your NPC.
    Would the prefix matter, by the way? I am using (2) instead of (B).
    What for? My guess would be the banter file, but since SoD doesn't use banter files, I am not sure what you are referring to. As long as you set the references right (for example, if it's the banter file, it needs to be assigned to the interdia.2DA) then the actual name dosn't matter. The system of J.dlg for joined dialogue, D.bcs for dream script, P.dlg for kickout etc. is only important for the structure so people do not get confused, the game doesn't care how these files are called as long as they are assigned accordingly (and as long as they do not exceed the 8 letter maximum, of course).

    I spotted a slight oversight in my tutorial for the case NPC joined in BG city - was left standing - is talked to again in front of the Ducal Palace before marching against the crusade. I'll upload the new version shortly.

    Also, I am about to make the Biff material from the tutorials into an NPC mod. This will not be as extensive as Kulyok's Branwen as I do not deal with how to create the cre file and how to script a friendship dialogue, the mod will only cover the SoD specific content from the tutorials.
    (Biff is a fighter with Str 9, Dex 9, Con 9, Int 9, Wis 9, Char 9 - I'm not making this up, it's his original game file.)
    RaduzielAcifer
  • SkitiaSkitia Member Posts: 1,052
    edited April 2019
    Whoops, I mistyped, my error in that and a poor explanation, sorry!

    Where I erroneously said B, I meant s, like xxBiff(s).dlg and xxBiff(s)P.dlg. One of my NPC's name is Emily, and her file structure I've used 2 instead of the s, thus her normal dialogue file is X3mily.dlg and her SoD one is X32mily.dlg.

    My question was is there any rules or guidelines over this?


    A tutorial NPC mod would probably help even further, so my thanks ahead of time if you achieve this. That would really allow me to see how some of the things I could not get working are worked in and adjust, or future modders.
  • jasteyjastey Member Posts: 2,669
    My question was is there any rules or guidelines over this?
    The J,P, etc. dialogue names are just conventions, the engine doesn't care which is which as long as they are assigned accordingly. It just helps the devs and modders not to lose oversight. In case of the BG:EE / SoD dialogues, the devs chose to use a diffeent prefix (bd) for one, and so the greetings dialogues of the NPC are, for example:
    Minsc BG1: minsc.dlg; SoD: bdminsc.dlg
    Khalid BG1: khalid.dlg; SoD: bdkhalid.dlg

    For the joined dialogue files, it's the J.dlg structure is used again, so it's:
    Minsc joined dialogue BG:EE: minscj.dlg; SoD: bdminscj.dlg
    Khalid joined dialogue BG:EE: khalij.dlg; SoD: bdkhalij.dlg

    But as long as the engine knows which dialogues to call (i.e. you patched the names to the bddialog.2da) it really doesn't matter how they are called.
    Acifer
  • SkitiaSkitia Member Posts: 1,052
    edited April 2019
    Omg, that makes so much sense now, I now better understand why the append line for bddialog.2da is there, Danke!
    Post edited by Skitia on
  • jasteyjastey Member Posts: 2,669
    The first post has been updated:
    Modding Tutorial Part 1 updates to v3 and now also includes the transition from BG:EE to SoD (change of script and dialogue to the SoD one). Changes are:
    fixed missing greetings dialogue in case Biff joined the party in BG city and was left standing again but should join the party then before leaving for the crusade (greetings dialogue xxBiffs.d was changed)
    added new paragraph: "Transition into SoD: change Biff's OVERRIDE script to the SoD one for a continuous BG:EE-SoD game"
    moved sidenote about detecting SoD into here (from Tutorial no 4 "SoD Banter System for Your NPC")
    changed tutorial's title to reflect it now also deals with the transition into SoD
    fixed some typos and added some comments

    Modding Tutorial Part 2 added: Make Your NPC Comment and Move Along at the End of SoD
    This tutorial deals with how to integrate your NPC into the events and cutscenes at the end of SoD. Biff the Understudy will be the example NPC in this guide.
    Note: This tutorial contains heavy SoD spoilers.

    Modding Tutorial Part 4 updated to v2:
    • moved sidenote about detecting SoD into tutorial no. 1 "Automatic Transition of NPCs into SoD and between Camps in SoD"
    • typo corrections
    • changed title slightly
    GusindaAcifer
  • jasteyjastey Member Posts: 2,669
    And another addition to the first post: I actually made this into a Biff for SoD mod!

    Biff the Understudy Tutorial NPC Mod for SoD
    Please note: the mod is working, but Biff has a basic cre, no items, no portrait, and no soundset. The focus of the mod is on the scripting described in the tutorials.
    SkitiaAcifer
  • RaduzielRaduziel Member Posts: 4,714
    Congratulations for not throwing your PC out of the window!
  • jasteyjastey Member Posts: 2,669
    edited April 2019
    Ha! :) Yeah, I went for option one, instead.
    EDIT: Just so this doesn't make the wrong impression: I complained to @Raduziel via PM that I can't get one of the cutscenes to work and will either leave it or throw my comp out of the window.
    RaduzielAcifer
  • SkitiaSkitia Member Posts: 1,052
    edited April 2019
    Thanks for this, it really helps. I had another question, slightly off-topic but relates to the use of I_C_T3 I saw:

    How many different I_C_Ts are there, and when is it best to use each one? I tried reading the Weidu guide to understand, and have a vague understanding of how each one should be used, but it's still a bit confusing, and this is the first I've ever seen I_C_T3
  • jasteyjastey Member Posts: 2,669
    edited April 2019
    Kaeloree wrote a wonderful tutorial about interjections here. The formatting is out of order and some links might be outdated (although I just updated those I saw), but it explains the I_C_T / I_C_T3 difference and also what to use when here.

    In short:
    I_C_T will only show if the triggers are met, and will put the actions of the state to the creature that spoke last. If there are several lines in the I_C_T, they will only show if the line in front of them (starting with the first) has true triggers. If there is actions that should not be performed by your NPC, you need to include a "passback line" where the original character speaks the last line.

    I_C_T2 is like I_C_T (only shows if triggers of the first are true and ends as soon as there is a line with untrue triggers, regardlaess of whether there would be true triggers in a later line), but the actions are performed by the original creature. CAUTION: this only works (if at all) if there is only ONE transaction in the state. If there are more than one for different conditions, then the result is unforseeable (or it takes the first one or whatever, in short: the result is not desirable.) And: since you never know whether another mod didn't just add another transaction to the state you are interjecting into, using I_C_T2 is always risky. It shouldn't be used, actually. I'm not sure why I even wrote about it. Don't use it.

    I_C_T3:
    -All lines can have different triggers, and all lines with true trigger will show, regardless of where they are. This means, the first one can be False(), but the second one could have true triggers, so the second one would show. The actions at the end are (like I_C_T) performed by the NPC talking last, so a passback line at the end to the original creature is needed.
    I like using this if my NPC interjects with different lines depending on e.g. romance status or the like.

    And there is an I_C_T4 which would also play all lines with true consitions but it has the same drawback than I_C_T2, so it shouldn't be used.
    SkitiaRaduzielAcifer
  • RaduzielRaduziel Member Posts: 4,714
    @jastey First, let me say once again, good job with the tutorial.

    One question: why do you keep changing the creature AI Script at every camp transition?

    As you know, I'm making an NPC that is SoD-exclusive, all his scripts are already from SoD (BDNAME, BDFIST, BDSHOUT...) is it mandatory?

    Thanks!
  • SkitiaSkitia Member Posts: 1,052
    edited April 2019
    SoD did it that way, so the question of questions is why did Beamdog do that, which I'm curious too.

    Granted their techniques do seem to have meaning so far. I did learn that smallwait(1) as I asked above really makes a difference. It was the difference between my game crashing and not during a cutscene.
    Raduziel
  • jasteyjastey Member Posts: 2,669
    If you use only one script and that is already patched into the cre, it is probably not necessary. I see it as a safety feature. It makes sense in case the NPC was moved from BG:EE into SoD or if the cre is spawned for the first time and has a BG:EE script attached - this is for the two first instances (inside BG city).
    After that, it is probably no longer needed: if the NPC had this script attached before leaving or DestroySelf(), this script will still be active as OVERRIDE if they are MoveGlobal-ed.
    I see it as a safety feature, though, and SoD does it for the NPCs, too.
    One example where it makes sense: if the NPC is supposed to visit the PC in the prison, the game does it by changing the OVERRIDE script to another script ("bdvisit") temporarily where the NPC's path towards the prison door and the EscapeArea() afterwards is scripted. This is at the ending of the game, of course. Still, if the NPC now spawns in the last meeting area at the prison exit, if we do not reset the SoD Override script, the "bdvisit" would still be active. (I'll add the "visit PC in prison" to tutorial 2 in the next update, and I'm not even sure I'll suggest to use this script, but it's an example.)
    Acifer
  • jasteyjastey Member Posts: 2,669
    Didn't see @Skitia's response when typing.
    Yeah, exactly. Cutscenes not doing what they should (just skipping things) or not ending the sutscene mode is a great fun, too. Nowadays, I tend to add a "WaitSomething" after every action that might take a small moment (like applying spells and the likes).
    Acifer
  • jasteyjastey Member Posts: 2,669
    edited April 2019
    I am working on the EET compatibility (which needs rather little work for a pure SoD NPC, fortunately), but I came across something I don't understand with regard to the EET_NPC_TRANSITION function as described here. If anyone else than k4thos could enlighten me, I'd be grateful. (EDIT: I meant someone else as well as to k4thos, of course.)
    RaduzielAcifer
  • jasteyjastey Member Posts: 2,669
    I finally understood how to use the EET_NPC_TRANSITION (yay me...)

    Please note: inside the 1st tutorial and the tutorial mod, there is still copy&paste errors where Minsc's Death Variable is inside the scripts instead of Biff's. This will be corrected in the next version.
    RaduzielAcifer
  • RaduzielRaduziel Member Posts: 4,714
    @jastey Based on your post at G3 may I assume that a SoD-exclusive NPC should keep BG1's override entry empty only filling the one related to SoD?

    Thanks!
  • jasteyjastey Member Posts: 2,669
    @Raduziel Exactly. Specifying a BG:EE override script name will add the DestroySelf() for chapter greater than 7 to this script. It does make sense if you have a BG:EE+SoD NPC that uses different scripts for BG:EE and SoD: in that case, any version of the NPC still standing around after chapter 7 with the BG:EE script active is treated as a relic that needs to be removed.
    RaduzielAcifer
Sign In or Register to comment.