Jump to content

Dialogue condition checks


lroumen

Recommended Posts

Currently, I am trying to write NPC responsed based on Player1 dialogue choices, but I am uncertain on how it is best done.

 

I have read several dialogue writing tutorials, but there are always questions in my mind about things that seem to be impossible in weidu, but are possible in other scripting languages (C, python, shell, or whatever). For example, in a different thread I learned that IF a == b is not always doable in weidu unless you use workarounds with globals.

In any case...

 

What I would like to achieve is the following.

If a good protagonist illogically gives an evil answer I would like to branch the dialogue into a logical block (with good or neutral continuation) and an illogical block (with evil or neutral continuation). At the same time, an evil protagonist giving an illogical good answer or a lawful protagonist (monk) giving an illogical chaotic answer or vice versa sh/w/could require extra block branches in the same portion of the dialogue. This is rather impractical due to the volume of the branches you would get. Is there a way to shorten it with regards to amount of coding blocks?

 

A concrete example is a paladin responding not very paladin-like by scolding an NPC without reasoning, then I would like to give that NPC the possibility to give the protagonist a reputation hit as a result of his actions. You would create a block that branches the dialogue from the paladin response to the response and reputation hit by the NPC. However, if this block is in a general quest dialogue bit, I would at the same time as branching the paladin part allow branches for an evil thief scolding the NPC without going into the reputation hit or something like that but going towards an extortion branch or such.

 

The impractical part is the number of branches can increase quite a bit in a short time span for even the simplest dialogues let alone the complex ones. I know that I am kind of going towards a world of pain in the writing and coding of these things, but I would like to try to have dialogue options make sense with regards to adapting quest outcomes or quest rewards or introducing subquests and plot twists.

 

Anyway, the code for a short example, which I think should work okay, but it is a lot of branches to go through.

(please ignore the coding typos)

IF ~~ THEN BEGIN Intro
SAY ~I have been robbed, please help me!~
IF ~Alignment(MASK_GOOD)~ THEN REPLY ~Sure, I will help~ GOTO Goodhelp
IF ~Alignment(MASK_NEUTRAL)~ THEN REPLY ~Sure, I will help~ GOTO Neutralhelp
IF ~Alignment(MASK_EVIL)~ THEN REPLY ~Sure, I will help~ GOTO Evilhelp
IF ~Alignment(MASK_GOOD)~ THEN REPLY ~No, I will not help~ GOTO Goodnohelp
IF ~Alignment(MASK_NEUTRAL)~ THEN REPLY ~No, I will not help~ GOTO Neutralnohelp
IF ~Alignment(MASK_EVIL)~ THEN REPLY ~No, I will not help~ GOTO Evilnohelp
END

IF ~~ THEN BEGIN Goodhelp
SAY ~Bless you <SIR_MAAM>. You are a saint. Have a few cookies and my thanks~ DO ~ReputationInc(1) GiveItem("cookie",5)~ EXIT
END

IF ~~ THEN BEGIN Neutralhelp
SAY ~Thank you <SIR_MAAM>. Have a cookie. DO ~GiveItem("cookie",1)~ EXIT
END

IF ~~ THEN BEGIN Evilhelp
SAY ~I cannot believe you will actually help me with this!~ 
IF ~~ THEN REPLY ~Those thieves should stay off my turf. Before I go kill them, give me all your cash. ~ 
SAY ~Sigh. Okay~
DO ~GivePartyGold(25)~ EXIT
END

IF ~~ THEN BEGIN Goodnohelp
SAY ~Well damn you then.~ DO ~ReputationInc(-1)~ EXIT
END

IF ~~ THEN BEGIN Neutralnohelp
SAY ~Fair enough.~ EXIT
END

IF ~~ THEN BEGIN Evilnohelp
SAY ~I could have expected as much from you.~ 
IF ~~ THEN REPLY ~I will do the opposite of helping. Give me all your cash. ~ 
SAY ~Sigh. Okay~
DO ~GivePartyGold(25)~ EXIT
END

 

Not really fair on the rewards, but okay. This is only for two responses. Imagine lawful, chaotic and various dialogue options. My question now is. Is possible to skip the splitting of the conditions into one block at the point of the NPC SAY bit? Hypothetically would look something like this. It would make the amount of dialogue blocks easier as well as the condition setting. The question is, will it work?

 

IF ~~ THEN BEGIN Intro
SAY ~I have been robbed, please help me!~
IF ~~ THEN REPLY ~Sure, I will help.~ GOTO Help
IF ~~ THEN REPLY ~No, I will not help.~ GOTO Nohelp
END

IF ~~ THEN BEGIN Help
IF ~Alignment(MASK_GOOD)~ THEN SAY ~Bless you <SIR_MAAM>. You are a saint. Have a few cookies and my thanks~ DO ~ReputationInc(1) GiveItem("cookie",5)~ EXIT
IF ~Alignment(MASK_NEUTRAL)~ THEN SAY ~Thank you <SIR_MAAM>. Have a cookie. DO ~GiveItem("cookie",1)~ EXIT
IF ~Alignment(MASK_EVIL)~ SAY ~I cannot believe you will actually help me with this!~ 
IF ~~ THEN REPLY ~Those thieves should stay off my turf. Before I go kill them, give me all your cash. ~ 
SAY ~Sigh. Okay~
DO ~GivePartyGold(25)~ EXIT
END

IF ~~ THEN BEGIN Nohelp
IF ~Alignment(MASK_GOOD)~ THEN SAY ~Well damn you then.~ DO ~ReputationInc(-1)~ EXIT
IF ~Alignment(MASK_NEUTRAL)~ THEN SAY ~Fair enough.~ EXIT
IF ~Alignment(MASK_EVIL)~ THEN SAY ~I could have expected as much from you.~ 
IF ~~ THEN REPLY ~I will do the opposite of helping. Give me all your cash. ~ 
SAY ~Sigh. Okay~
DO ~GivePartyGold(25)~ EXIT
END

 

I'm quite certain that the IFs with the SAYs will not work though, but can I accomplish something like it in the same block? Are there perhaps alternatives of what I am attempting that I did not pick up properly in the various dialogue tutorials?

 

For reading and responding, thank you very much in advance.

Link to comment
What I would like to achieve is the following.

If a good protagonist illogically gives an evil answer I would like to branch the dialogue into a logical block (with good or neutral continuation) and an illogical block (with evil or neutral continuation). At the same time, an evil protagonist giving an illogical good answer or a lawful protagonist (monk) giving an illogical chaotic answer or vice versa sh/w/could require extra block branches in the same portion of the dialogue. This is rather impractical due to the volume of the branches you would get. Is there a way to shorten it with regards to amount of coding blocks?

You can write macros and manipulate code with WeiDU, so it's technically possible that you won't have to write out each and every thing. Your dialogue will still end up having tons of different states, though.

Link to comment

What you are looking for is CHAIN.

You'd need an always-true intro line, but after that, the NPC can say lines with different triggers.

 

Your example would look like this (please read the tutorial to CHAINs, could be I introduce an error):

 

BEGIN ~dlgname~

IF ~~ THEN BEGIN Intro
SAY ~I have been robbed, please help me!~
IF ~~ THEN REPLY ~Sure, I will help.~ GOTO Help
IF ~~ THEN REPLY ~No, I will not help.~ GOTO Nohelp
END

CHAIN
IF ~~ THEN ~dlgname~ Help
~Aha!...~ //no SAY for CHAIN
== ~dlgname~ IF ~Alignment(Player1,MASK_GOOD)~ THEN ~Bless you <SIR_MAAM>. You are a saint. Have a few cookies and my thanks~ DO ~ReputationInc(1) GiveItem("cookie",5)~   
== ~dlgname~ IF ~Alignment(Player1,MASK_NEUTRAL)~ THEN ~Thank you <SIR_MAAM>. Have a cookie. DO ~GiveItem("cookie",1)~ 
== ~dlgname~ IF ~Alignment(Player1,MASK_EVIL)~ THEN ~I cannot believe you will actually help me with this!~ 
END
IF ~~ THEN REPLY ~Those thieves should stay off my turf. Before I go kill them, give me all your cash. ~ + ok

APPEND ~dlgname~ //after CHAIN, you have to specify the dlg name into which the states should be compiled
IF ~~ THEN ok
SAY ~Sigh. Okay~
IF ~~ THEN DO ~GivePartyGold(25)~ EXIT
END
END //APPEND

 

things that seem to be impossible in weidu, but are possible in other scripting languages (C, python, shell, or whatever). For example, in a different thread I learned that IF a == b is not always doable in weidu unless you use workarounds with globals.
That would not be WeiDU, but the restrictions of the IE engine itself. There is just no such trigger. Also something like (A AND B) OR (C AND D) does not exist, unfortunately!
Link to comment

Thank you for the tip Mike, though I'm not certain whether that would make my work much easier :undecided: .

 

Thanks Jastey!

I didn't know you could use IFs in chains, so I discarded it as a possibility. It seems that this will make life a bit easier on me. No worries about the mistakes (a few EXITs missing I guess). It is the concept that matters for me. This helped lots!

 

things that seem to be impossible in weidu, but are possible in other scripting languages (C, python, shell, or whatever). For example, in a different thread I learned that IF a == b is not always doable in weidu unless you use workarounds with globals.
That would not be WeiDU, but the restrictions of the IE engine itself. There is just no such trigger. Also something like (A AND B) OR (C AND D) does not exist, unfortunately!

I stand corrected. I knew I should have typed IE, since weidu is updated with features regularly. These mistakes do slip out sometimes :hm: .
Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...