Author Topic: WeiDU Basics - by Japheth  (Read 36751 times)

Offline Ghreyfain

  • Moderator
  • Planewalker
  • *****
  • Posts: 4705
  • Gender: Male
    • Pocket Plane Group
WeiDU Basics - by Japheth
« on: April 01, 2004, 03:21:11 AM »
  WeiDU Basics 

Okay, I'm writing this tutorial from the standpoint that you have absolutely *no* knowledge of WeiDU whatsoever. If your reading this and going, "What the hell is WeiDU?", please check out this link and download WeiDU.

Now then, on to the tutorial...

First off, I'll tell you how to install WeiDU (don't worry, it isn't very hard). Then I'm basically going to run you through the basic syntax of a dialog file, and, more importantly, how to use WeiDU itself. Later on I'll show you how to use APPEND and EXTEND, as well as how to use EXTERN and other things. And, finally, at the end I'll show you how to set up an install file for WeiDU.

Installing WeiDU

Okay, you've downloaded the latest version of WeiDU from the website I listed above (FYI: Weimer updates WeiDU quite often, so check back regularly to see if there's is a new version) and now you want to install WeiDU right? Well, here's what you do. Open up the zip file in your archiving program (WinAce, WinZip, WinRAR, etc), and then just extract it to your Desktop for now. (WeiDU, when extracted, creates it's own folder called WeiDU, so don't worry about creating a folder to unzip it to) So there now should be a folder called "WeiDU" on your Desktop. Open up the folder and delete everything except README-WEiDU.html, WEiDU.exe and the examples folder. Now highlight everything else in the folder, right click your mouse and select Cut. (You should see 1 folder now called examples, as well as a WeiDU.exe and README-WeiDU.html.) Now go to your root BG2 directory. (This is usually X:\Program Files\Black Isle\BGII - SOA where X=your drive letter.) Just right click and paste everything in there. There, you've installed WeiDU, pretty simple eh?

Basic Dialog File Syntax

Okay, so you have a dialog file you want to make, but after looking through the examples that come with WeiDU, your still going "howzawhaza?" I'll go through some basics below and then we'll get a bit more into the nitty gritty of WeiDU.

In WeiDU all of your dialog, conditions and actions (more on conditions and actions below) have to be surrounded by either quotes or tildes. (A tilde is that funky character you get by holding SHIFT and pressing the key directly above your TAB key.) In this case, I've used tildes, but you can use whatever you want to use. Secondly, spacing helps a lot when coding out your dialog. You'll notice, for instance that if I have more than 2 conditions/actions (again, more on that below), I do a return spacing and put the second condition below the first one. You would just keep doing this if you had more conditions to add in one block.

Dialogs use two types of functions quite frequently. Conditions and actions. I'll give you a real life example of a condition and an action for you non-technical types out there ;)

IF ~I'm being attacked by big scary wolves~ THEN BEGIN WOLFATTACK0
SAY ~Holy shit, look at those wolves, I'm out of here!~
IF ~~ THEN DO ~Running away from big scary wolves~ EXIT
END

The SAY part of the dialog is for the dialog that you are creating. So if I'm writing this dialog for a nerdy geek (double nerdative???), the part of SAY ~Holy shit, look at these wolves, I'm out of here!~, would be what the nerdy geek would be saying.

Obviously these conditions and actions don't exist in any of the Infinity Engine games, but do you see how it works? The condition would be "I'm being attacked by big scary wolves", and the action would be "Running away from big scary wolves". And, as you'll notice, to specify a condition at the start you just do IF ~Condition goes here~ THEN BEGIN BLAH. BLAH is just an internal label I chose to use. You could make BLAH anything you wanted, it could be WOLFIE, WOLFMEISTER, WOLFENSTEIN3D...you get the picture right? However, it's a good idea to keep the same internal label throughout your dialog and just put a number beside each of your labels for every new block. (ie, I have two blocks of dialog. I could put MYFIRSTNPC0 as the first label for the first block, and then put MYFIRSTNPC1 as the second label for the second blcok).

To do an action you would go DO ~action goes here~ EXIT. You can specify more than 1 condition or action anywhere. Also, if we look at the above example again, and wanted to reply to the guy that was running away from the wolves, we could do this.

IF ~I'm being attacked by big scary wolves~ THEN BEGIN WOLFATTACK0
SAY ~Holy shit, look at those wolves, I'm out of here!~
IF ~~ THEN REPLY ~You chicken shit!~ DO ~kill big scary wolves~ EXIT
IF ~~ THEN REPLY ~Uh...good idea, let's get out of here!~ DO ~Running away from big scary wolves~ EXIT
END

So now the geek will say to you "Holy shit, looks at these wolves, I'm out of here!", and you could either reply with "You chicken shit!", which would invoke the action of killing the big scary wolves or "Uh...good idea, let's get out of here!", which would invoke the action of running away from the wolves.

The EXIT command is used for when you are done with the dialog. So after replying with "Uh...good idea, let's get out of here!", the dialog would exit and you would run away from the wolves. However, if you didn't want the dialog to exit after you ran away you could do this instead of using EXIT.

IF ~I'm being attacked by big scary wolves~ THEN BEGIN WOLFATTACK0
SAY ~Holy shit, look at those wolves, I'm out of here!~
IF ~~ THEN REPLY ~You chicken shit!~ DO ~kill big scary wolves~ EXIT
IF ~~ THEN REPLY ~Uh...good idea, let's get out of here!~ DO ~Running away from big scary wolves~ GOTO WOLFATTACK1
END

IF ~~ THEN BEGIN WOLFATTACK1
SAY ~Heh, you wimp! I'm was just kidding! Harhh!~
IF ~~ THEN REPLY ~You ass! You gonna get it geek boy!~ DO ~smacking around the geek boy~ EXIT
END

So now instead of the dialog ending after you reply with "Uh...good idea, let's get out of here!", the dialog continues on to the next block, which is labeled WOLFATTACK1. So by using GOTO, you're just telling WeiDU to GOTO the label you specify.

The END command of WeiDU just tells WeiDU that "I'm done with this block of dialog, go to the next one!"

That pretty much wraps up the basics of WeiDU. Hopefully you understand it a little better now. Now I'll show you a basic conversation below (which was written by Death), and then show you how to code it correctly.

BLOCK 1(Quest not accepted, first time being talked to)
Skrymir - Greetings mortal! Come, sup' with me, share my bread and mead.
Response
1: Who are you? (to BLOCK 3)
2: Sure. (Party rests)
3: Maybe another time. (to BLOCK 4)
4: Not right now, I am too busy. (Dialog ends)
5: You are a monster, prepare to die! (Battle begins)

BLOCK 2 (If party has accepted the quest, first time being talked to)
Skrymir - Ho! The mortal lackeys of Odin come! Have ye come to tempt fate against the King of the Frost Giants, Skrymir? Not even the mighty Thor would attempt such a foolish thing out his hammer Mjollnir.
Response
1: Who are you? (to BLOCK 5)
2: Give me the belongings you stole from the gods and I might let you live!(to BLOCK 6)
3: Die evil monster! (Battle begins)
4: Please don't hurt me!! (to BLOCK 7)

BLOCK 3 (from BLOCK 1/Response #1)
Skrymir - Ho ho! I be Skrymir, King of the Frost giants! The most hated enemy of the Aesir!(to BLOCK 1)

BLOCK 4 (from BLOCK 1/Response #3)
Skrymir - Have it your way. (dialog ends)

BLOCK 5 (from BLOCK 2/Response #1)
Skrymir - Ho ho! I be Skrymir, King of the Frost giants! The most hated enemy of the Aesir! But ye already knew that. (to BLOCK 2)

BLOCK 6 (from BLOCK 2/Response #2)
Skrymir - Ho ho! Ye let ME live! That is a good one! What makes ye think ye can do what even the gods have yet to do? (battle begins)

BLOCK 7 (from BLOCK 2/Response #4)
Skrymir - Flee pesky mortals! (reputation drops 1, dialog ends)

BLOCK 8 (Talked to more than once, quest not accepted)
Skrymir - Ah, ye've returned, are you willing to converse and sup with me now?
Response
1: Yes, we've changed our minds. (Party rests)
2: Sorry, but we don't have time for this. (Dialog ends)
3: Your evil must be purged! Prepare to die! (Battle begins)

BLOCK 9 (Talked to more than once, quest is accepted)
Skrymir - Hah, the gophers have returned!
Response
1: You shall soon see how gophers deal with vermin like you! (Battle begins)
2: S-sorry, Skrymir. We didn't mean to bother you. (to BLOCK 7)
3: Hand over the items you wrongfully stole from the gods! (to BLOCK 10)

BLOCK 10
Skrymir - Ho ho! I don't think so you little worms. Ye are nothing but muck beneath me boot (Battle Begins)

Here's the proper way to code this particular dialog. You'll notice above that I specified things like talked to more than once, quest is accepted, first time talked to, etc. These are all conditions that need to be done. So if you follow along, hopefully you'll understand. For instance, to tell IE that you only want to start a block if this is the first time you've talked to the NPC, you use NumTimesTalkedTo(0). And for the vague action of (Battle begins), I've used

ChangeEnemyAlly(Myself,EVILCUTOFF)
Enemy()
Attack(NearestEnemyOf(Myself))

This changes his ENEMY/ALLY to EVILCUTOFF, makes you the enemy of him and then he attacks you, or if you move far enough away from him, he attacks the next closest person, etc.

(You can find a listing of the valid actions in the actions.ids file, all the valid conditions in the triggers.ids file and all the valid Enemy/Ally states in the ea.ids. All these files are in the script compiler directory of BG2)

Anyway, on with the code!

BEGIN fwdskrym

IF ~NumTimesTalkedTo(0)
Global("GiantQuestCheck","GLOBAL",0)~ THEN BEGIN D#SKY0
SAY ~Greetings mortal! Come, sup' with me, share my bread and mead.~
IF ~~ THEN REPLY ~Who are you?~ GOTO D#SKY2
IF ~~ THEN REPLY ~Sure.~ DO ~Rest()~ EXIT
IF ~~ THEN REPLY ~Maybe another time.~ GOTO D#SKY3
IF ~~ THEN REPLY ~Not right now, I am too busy.~ EXIT
IF ~~ THEN REPLY ~You are a monster, prepare to die!~ DO ~ChangeEnemyAlly(Myself,EVILCUTOFF)
Enemy()
Attack(NearestEnemyOf(Myself))~ EXIT
END

IF ~NumTimesTalkedTo(0)
Global("GiantQuestCheck","GLOBAL",1)~ THEN BEGIN D#SKY1
SAY ~Ho! The mortal lackeys of Odin come! Have ye come to tempt fate against the King of the Frost Giants, Skrymir? Not even the mighty Thor would attempt such a foolish thing out his hammer Mjollnir.~
IF ~~ THEN REPLY ~Who are you?~ GOTO D#SKY4
IF ~~ THEN REPLY ~Give me the belongings you stole from the gods and I might let you live!~ GOTO D#SKY5
IF ~~ THEN REPLY ~Die evil monster!~ DO ~ChangeEnemyAlly(Myself,EVILCUTOFF)
Enemy()
Attack(NearestEnemyOf(Myself))~ EXIT
IF ~~ THEN REPLY ~Please don't hurt me!!~ GOTO D#SKY6
END

IF ~~ THEN BEGIN D#SKY2
SAY ~Ho ho! I be Skrymir, King of the Frost giants! The most hated enemy of the Aesir!~
IF ~~ THEN GOTO D#SKY0
END

IF ~~ THEN BEGIN D#SKY3
SAY ~Have it your way.~
IF ~~ THEN EXIT
END

IF ~~ THEN BEGIN D#SKY4
SAY ~Ho ho! I be Skrymir, King of the Frost giants! The most hated enemy of the Aesir! But ye already knew that.~
IF ~~ THEN GOTO D#SKY1
END

IF ~~ THEN BEGIN D#SKY5
SAY ~Ho ho! Ye let ME live! That is a good one! What makes ye think ye can do what even the gods have yet to do?~
IF ~~ THEN DO ~ChangeEnemyAlly(Myself,EVILCUTOFF)
Enemy()
Attack(NearestEnemyOf(Myself))~ EXIT
END

IF ~~ THEN BEGIN D#SKY6
SAY ~Flee pesky mortals!~
IF ~~ THEN DO ~ReputationInc(-1)~ EXIT
END

IF ~NumTimesTalkedToGT(0)
Global("GiantQuestCheck","GLOBAL",0)~ THEN BEGIN D#SKY7
SAY ~Ah, ye've returned, are you willing to converse and sup with me now?~
IF ~~ THEN REPLY ~Yes, we have changed our minds.~ DO ~Rest()~ EXIT
IF ~~ THEN REPLY ~Sorry, but we don't have time for this.~ EXIT
IF ~~ THEN REPLY ~Your evil must be purged! Prepare to die!~ DO ~ChangeEnemyAlly(Myself,EVILCUTOFF)
Enemy()
Attack(NearestEnemyOf(Myself))~ EXIT
END

IF ~NumTimesTalkedToGT(0)
Global("GiantQuestCheck","GLOBAL",1)~ THEN BEGIN D#SKY8
SAY ~Hah, the gophers have returned!~
IF ~~ THEN REPLY ~Gophers? You shall soon see how gophers deal with vermin like you!~ DO ~ChangeEnemyAlly (Myself,EVILCUTOFF)
Enemy()
Attack(NearestEnemyOf(Myself))~ EXIT
IF ~~ THEN REPLY ~S-sorry Skrymir. We didn't mean to bother you.~ GOTO D#SKY6
IF ~~ THEN REPLY ~Hand over the items you wrongfully stole from the gods!~ GOTO D#SKY9
END

IF ~~ THEN BEGIN D#SKY9
SAY ~Ho ho! I don't think so you little worms. Ye are nothing but muck beneath me boot~
IF ~~ THEN DO ~ChangeEnemyAlly(Myself,EVILCUTOFF)
Enemy()
Attack(NearestEnemyOf(Myself))~ EXIT
END

That's the end of the code. I'll show you how to use some of the functions of WeiDU now.

Compiling Dialogs

To compile a dialog, first open your command prompt. This can be done by going to run and then typing in command. Go to your root directory of BG2 by typing in:

cd x:pathtobg2directory (Where x=your drive letter and pathtobg2directory=your path. In most cases it would be c:\Program Files\Black Isle\BGII - SOA)

Now that your in your root bg2 directory, to compile a dialog with WeiDU you can type this:

weidu pathtofile/filename.d --tlkout dialog.tlk --out override

(where path to filename is the directory that your .d file is in and filename is the filename)

What this will do is compile the dialog, and then put the dialog into your override folder. Your dialog.tlk file in the root directory of bg2 will also be updated with the additional text strings. Your dialog is good to go!

Decompiling Dialogs

Say you wanted to look at aerie's dialog in .d format, you can decompile the dialog with weidu as well. All you would need to do to decompile aerie's dialog is type this:

weidu aerie.dlg --out override

This will put aerie.d into your override folder.

If you have any major questions, you can post them on Westley Weimer's message board, which you can get to by going here.
« Last Edit: April 01, 2004, 03:40:05 AM by Ghreyfain »
Earn Money Sleeping.