Pocket Plane Group

Miscellany, Inc. => Infinity Engine Modding Q&A => Topic started by: KingMick on March 16, 2006, 06:49:28 PM

Title: Appending Chains with WeiDU?
Post by: KingMick on March 16, 2006, 06:49:28 PM
Hey all! I'm brand new to the modding process and have just created an NPC mod.  Now I'm trying to add some banters, after reading Blue's excellent tutorial on the subject.

This NPC usually has to be approached by another character (he's rather quiet), so most of his banters begin with the other person speaking first. From the tutorial I infer that the only way to do this is through the APPEND command.  However, these are long conversations and WeiDU does not seem to like it when I try to Append a CHAIN.  Here is an example of what I tried to do:

APPEND BJAN
CHAIN

<the banter goes here>

EXIT
END

WeiDU encounters a problem as soon as it sees "CHAIN" here.  Is it not possible to Append Chains? I am also worried about the EXIT before END, even though WeiDU has said nothing about it yet. As far as I can tell it would be correct--the EXIT refers to leaving the dialogue and the END refers to the append block--but it still makes me nervous.

Any help on these issues is appreciated!
Title: Re: Appending Chains with WeiDU?
Post by: Kismet on March 16, 2006, 07:56:53 PM
You wouldn't use APPEND with CHAIN.  You'd just use

CHAIN
IF ~SomeConditions~ THEN BJAN JanBanter
~I'm going to say something longwinded and perhaps witty.~
.
.
.
.
EXIT
Title: Re: Appending Chains with WeiDU?
Post by: KingMick on March 16, 2006, 08:00:45 PM
Ahhhhhh, ok. I wondered if that might work.  Thanks again Kismet!

*thinks he should make mention of Kismet somewhere when the mod is released because of all the help he's had*
Title: Re: Appending Chains with WeiDU?
Post by: cmorgan on April 17, 2006, 04:24:50 PM
OK, to piggyback on the use of CHAIN: could this work (one long D file, with somewhat alternating CHAIN and APPEND blocks)

CHAIN ~_BNPC2~                                           //does this successfully say "CHAIN from _BNPC2"?
IF WEIGHT#-1 ~Global("myGlobal","GLOBAL",1) InParty("NPC2") !Dead("NPC2")~ Quest1.2
~Well met, my friend. I see you have found a strange item?~
== ~_BNPC1~ ~yes I did.~
== ~_BNPC2~ ~can you tell me about it?~
== ~_BNPC1~ ~well ,if <CHARNAME> says so...~
END
++ ~no way~ EXIT         //does this successfully NOT exit the chain, but instead say Player1 says "no way" and exits dialog?
++ ~most assuredly~ GOTO Quest2.3
++ ~And what will I get for allowing this?~ EXTERN ~_BNPC1~ Quest2.8
EXIT
Title: Re: Appending Chains with WeiDU?
Post by: Grim Squeaker on April 17, 2006, 04:35:47 PM
No...

Code: [Select]
CHAIN
IF WEIGHT#-1 ~Global("myGlobal","GLOBAL",1) InParty("NPC2") !Dead("NPC2")~ ~_BNPC2~ Quest1.2 //That means _BNPC2 starts the dialogue
~Well met, my friend. I see you have found a strange item?~
== ~_BNPC1~ ~yes I did.~
== ~_BNPC2~ ~can you tell me about it?~
== ~_BNPC1~ ~well ,if <CHARNAME> says so...~
END
++ ~no way~ EXIT         //does this successfully NOT exit the chain, but instead say Player1 says "no way" and exits dialog?
++ ~most assuredly~ GOTO Quest2.3
++ ~And what will I get for allowing this?~ EXTERN ~_BNPC1~ Quest2.8

You don't need that EXIT as well, it isn't attached to anything.  There are only three ways to end this block (your 3 PC responses) and each of them have transitions already (EXIT, GOTO and EXTERN respectively), so there's no way for it to EXIT afterwards.
Title: Re: Appending Chains with WeiDU?
Post by: cmorgan on April 17, 2006, 05:03:49 PM
cool - so the CHAIN structure only needs an EXIT when there is a response that does not end or transition the dialog. Can I EXTERN to a CHAIN to continue? e.g.

++ ~Why don't we ask Alice?~ EXTERN ~_BNPC3~ Quest 2.9
++ ~And what will I get for allowing this?~ EXTERN ~_BNPC1~ Quest2.8


CHAIN
IF Quest2.9 THEN ~_BNPC3~ AliceAnswers
~Hey, I can help too - I'm Alice!~
== ~_BNPC1~ ~no way, you slell funny~
== ~_Montaron~ ~And I want to fry it up for dinner anyways..~
END
++ ~Hey there, whoa back. Let's get this example back on track, now.~ DO ~SetGlobal("LostInComplexity","GLOBAL",1) EXIT
++ ~I wish I could just get my brain around CHAIN *sigh*~ EXIT
++

Title: Re: Appending Chains with WeiDU?
Post by: Grim Squeaker on April 17, 2006, 05:25:50 PM
Yup.  CHAINs are just a special kind of construction to allow you to juggle between speakers, but you can still do the normal shit like GOTOing or EXTERNing to them.  EXITs are only ever used when you actually want to EXIT the dialogue, so either at the end of transition or instead of the END in the case that you want no PC options.
Title: Re: Appending Chains with WeiDU?
Post by: cmorgan on April 27, 2006, 10:49:14 PM
Well, skipping boards now, but wanted to make sure that the information is organized "like with like", anyways!

Instead of the {END player response TRANSITION} structure, is the syntax correct to use

Code: [Select]
CHAIN
IF Quest2.9 THEN ~_BNPC3~ AliceAnswers
~Hey, I can help too - I'm Alice!~
== ~_BNPC1~ ~no way, you slell funny~
== ~_BMONTAR~ ~And I want to fry it up for dinner anyways..~
EXTERN ~_BMONTAR~ Quest3.0

CHAIN
IF Quest3.0 THEN ~_BMONTAR~ DinnerTime
~after all, it is time to eat.~
== ~_BALICE~ ~don't you want to go on?~
== ~_BMONTAR~ ~NO.~
DO ~SetGlobal ("Dinner","LOCALS",1)~
EXIT

It looks funny here, because the dialogue here could be put all in one chain, but I am using fragments of chain to tie together common dialogue: more than one CHAIN conversations (Quest2.7, 2.8, 2.9) all tied to the same CHAIN (Quest3.0)

The reason I ask is I have a nagging doubt that
IF ~~ QUEST3.0
SAY ~text~
IF ~~ THEN EXIT
END

then I might have to include that IF ~~ QUEST3.0 THEN ~_BMONTAR~ DinnerTime structure. the "~~" you indicate were default ~noncodition~, and we have a direct call with no need for conditions...
Title: Re: Appending Chains with WeiDU?
Post by: Grim Squeaker on April 28, 2006, 02:54:22 AM
You seem to have some confusion with statenames.

Code: [Select]
IF ~~ QUEST3.0
SAY ~text~
IF ~~ THEN EXIT
END

This is shorthand for:

Code: [Select]
IF ~~ BEGIN QUEST3.0
SAY ~text~
IF ~~ THEN EXIT
END

Giving us the statename QUEST3.0.  However with this:

Code: [Select]
CHAIN
IF Quest2.9 THEN ~_BNPC3~ AliceAnswers
~Hey, I can help too - I'm Alice!~
== ~_BNPC1~ ~no way, you slell funny~
== ~_BMONTAR~ ~And I want to fry it up for dinner anyways..~
EXTERN ~_BMONTAR~ Quest3.0

CHAIN
IF Quest3.0 THEN ~_BMONTAR~ DinnerTime
~after all, it is time to eat.~
== ~_BALICE~ ~don't you want to go on?~
== ~_BMONTAR~ ~NO.~
DO ~SetGlobal ("Dinner","LOCALS",1)~
EXIT

You have 'CHAIN IF Quest2.9 THEN ~_BNPC3~ AliceAnswers'.  In this I'm not sure what you're trying to do.  What should go between 'CHAIN IF' and 'THEN filename' are the conditions for the block to run (in tildes) e.g. CHAIN IF ~True()~ THEN ~_BNPC3~ AliceAnswers or if you don't want any conditions: CHAIN ~_BNPC3~ AliceAnswers, which I think is what you want here.

In these examples your statenames are AliceAnswers and DinnerTime but you've got with Quest2.9 and Quest3.0 sitting where the requirements should be, so I think you're kind of confused.

The structure for CHAIN (slightly simplified) is:

CHAIN  [ IF stateTriggerString THEN ] entryFilename entryLabel
chainText  list
chainEpilogue

The red square brackets represent optional coding, in this case the conditions.  Conditions would only be there if this CHAIN was the start of the dialogue.  entryLabel is our statement, if that makes sense to you, as I think you've got the syntax kind of confused in your head.

Edit: So my guess at what you wanted is:

Code: [Select]
CHAIN
IF ~somestartingconditions~ THEN ~_BNPC3~ Quest2.9
~Hey, I can help too - I'm Alice!~
== ~_BNPC1~ ~no way, you slell funny~
== ~_BMONTAR~ ~And I want to fry it up for dinner anyways..~
EXTERN ~_BMONTAR~ Quest3.0

CHAIN ~_BMONTAR~ Quest2.9
~after all, it is time to eat.~
== ~_BALICE~ ~don't you want to go on?~
== ~_BMONTAR~ ~NO.~
DO ~SetGlobal ("Dinner","LOCALS",1)~
EXIT

Although I don't know if Quest2.9 is the start of the dialogue, so I've left 'IF ~somestartingconditions~ THEN' in there.  If its not, just remove it.
Title: Re: Appending Chains with WeiDU?
Post by: cmorgan on April 28, 2006, 03:35:34 PM
Yep -- final example was what i was trying for. While the tutorials (and your explanations) are clear, I am looking at varied examples by pretty experienced folks, and I am finding that jumping in to the deep end of the pool that way is leading to some random flailing around in the water! Learning a language by studying shorthand alongside longhand is kind of like learning English and American at the same time (from a good Scotsman no less -- What's a "trunk" or "boot" anyways?  ;D).

I don't understand where I got the idea that I should come into statename1 and then immediately change to another statename to progress. Putting
CHAIN  IF ~True()~ THEN ~_BNPC3~ Quest2.9 = CHAIN ~_BNPC3~ Quest2.9 clarified it.

Quote
Conditions would only be there if this CHAIN was the start of the dialogue
is where I really got confused.  Now clear: conditions are only set to trigger the initial CHAIN. If the CHAIN is triggered off a dialog path(EXTERN-ed to), then CHAIN ~NPCfile~ statename1 [all banter END playerresponse EXTERN statename2] CHAIN ~NPC2file~ statename2   rinse-repeat-vamp 'til ready

and so on. Thanks again!
Title: Re: Appending Chains with WeiDU?
Post by: Grim Squeaker on April 28, 2006, 03:44:30 PM
That's it exactly.
Title: Re: Appending Chains with WeiDU?
Post by: cmorgan on April 28, 2006, 10:15:31 PM
Aaaand you are a very kind person to go through this for the umpteenth time. I just found the post that would have shortcircuited some of my questions, if I had expanded my search parameters...  For anyone thread-searching for other (somewhat parallel) explorations to understand CHAIN, see Grim Squeaker, Vlad, jcompton, and "the bigg" in this post http://forums.pocketplane.net/index.php/topic,21733.msg283010.html#msg283010.

Sometimes the old "read everything plus everything on the shelf next to it" works as well electronically as it does in a (non-virtual, actual) library  8)