Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

WeiDU dialog coding questions

Hi. I started (for the first time) implementing my NPC mod and encountered a few problems for which I can't decide upon a best approach. They are both about CHAIN (and its friends) vs APPEND + EXTERN.
1. What do you think is best practice for coding other NPCs interjections on your NPC dialogs.
Example (let NPC's name be Joe):
Protagonist initiates dialog (initial dialog file, Joe.d)
Joe: "How are you doing?"
Rachel (if present)L: "Oh, this guy is handsome."
Then follows protagonist replies.
As I understand you can do it on "low-level" with APPEND and EXTERN transition or you can do it with CHAIN or INTERJECTION, which do the same thing, but save you some time. So I'd like to know what, in your experience, is more convenient. It's just CHAIN doesn't look obviously superior to me yet, because, firstly, EXTERN transition is more explicit, secondly, with EXTERN you can do more than with CHAIN, but that's my second question.
2. Primary question: is there way to elegantly code following dialog using CHAIN or similar command:
MYNPC "My npc sentence"
NPC1 interjection (if present): "npc1 comment on my npc sentence" -> then replies
NPC2 interjection (if present): "npc2 comment on my npc sentence which replaces one of the protagonist replies, so if NPC2 has said something, replies are skipped and we go to REPLY2 transition state" -> then goto special state
NPC3 interjection (if present): "npc3 comment on my npc sentence" -> then replies
REPLY 1: "protagonist reply 1 on my npc sentence" -> goto some state
REPLY 2: "protagonist reply 2 on my npc sentence" -> goto special state
REPLY 3: "protagonist reply 3 on my npc sentence" -> goto some state
REPLY 4: "protagonist reply 4 on my npc sentence" -> goto some state

You see, I like consistency in coding style, so I don't wish to jump between CHAIN and (APPEND+EXTERN)s. Right now I can't decide, should I stick with CHAIN (because possibly I don't realize its full potential) or should go for APPEND+EXTERNS as situations where I will have to use them are unavoidable.

Comments

  • ArunsunArunsun Member Posts: 1,581
    You will probably need to juggle between CHAIN and APPEND+EXTERN:
    CHAIN typically works well for banters that do not require the player's intervention. It is a very simple way to write a dialogue between two or more NPCs. Chains can take conditional interjections as well, if you need some.
    But as soon as your player character has to say something, you'll need to go to a special state with the player answers, and if it so happens that the last state before your PC talks is one in an existing dialog file, you will have to use APPEND to add the state to the file, and then end the CHAIN with an END to go to that state you just added. 
    In general, I would advise using CHAIN as often as you can since it saves a lot of time.


    In the situation you mention, I'm afraid you will have to use APPEND+EXTERN, since your PC has to say things.

    What I do to keep my dialog files somewhat clear is that I manage every dialog one by one following how the dialog unfolds, using Appends and Chain depending on my needs, so that by reading the actual text part of the code in order, it follows the dialog, and every subbranch of the dialog is indented by an extra tab so that I can expend or collapse it easily (VSCode and Sublime Text do that, I assume most text editors do too). For instance, I'll use do something like that (taking a banter with some PC intervention in it):
    // Comment to state what dialog this is. Collapse or expend the dialog by clicking this line in the editor
            CHAIN IF ~conditions~ THEN filename1 chainname1
    		~Blablabla~
    		== filename2 ~blablabla~
    		== filename1 ~blablabla~
    		END filename2 statename1
    
    		APPEND ~filename2~
    		IF ~~ statename1
    		SAY ~blablabla~
    		++ ~Answer 1~ GOTO statename2
    		++ ~Answer 2~ EXTERN filename1 chainname2
    		END
    
    		//Subbranch from answer 1. Same thing, you can collapse or expend the subbranch using indents
    			IF ~~ statename2
    			...
    		//Subbranch from answer 2.
    			CHAIN IF ~~ THEN filename1 chainname2
    			...
    
    
    
    It might take some time to get used to, but eventually this is the most clear and readable way I have found of writing the dialogues without going up and down in huge text files that quickly reach a thousand lines.

    sufflaminandus
Sign In or Register to comment.