9- Creating an NPC

* An NPC is a non-playable character.  NPCs are the people who live in your game world and who give your player good advice on things.  We are going to put an NPC on our first board.

* The first thing you must do is go into the tile editor and create a tile of a person.  Try making an old man or something.  When that's done, save the graphic into your new tileset (mytiles.tst).

* Before we do anything else, we must decide what the NPC will say.  This is done by the Toolkit's internal programming language, RPGCode.  As you will quickly see, this is very easy to use.

* Let's make a little program that causes our NPC to say something on the main screen, select Edit Program.  This opens up the RPGCode editor (it's basically just a text editor).

* Now, RPGCode is a programming language, which means that you give the computer instructions and the computer follows them out.  

* One of these instructions is called #Mwin, which means that we want the computer to put some text into a message window (i.e., the NPC talking to us).

* You can type out a few lines of RPGCode in the RPGCode editor.  Try typing this in:

#Mwin("Man: Hello, I am your very first NPC!")
#Mwin("It's a very nice day today!")
#Wait(a$)

* Type it in exactly as you see it, otherwise it won't work.  

* This will do is tell the computer to put two lines of text into the Message Window (they are: Man: Hello, I am your very first NPC! / It's a very nice day today!).  The last command, #Wait(a$), just tells the computer to wait for the user to press a key before doing anything else.

* You could put any text in the #Mwin commands, just as long as they are enclosed in quotation marks ("like this").

* Save this program as npc1.prg.

* Now it's time to put the old man you drew on one of your boards.  Go into the board editor and load one of your two boards.  Now we can place our newly created program on the board...

* Click on the RPGCode menu, and select Set Program.  Now, you will be asked to click on some tile.  The next tile you click on will be the tile where the NPC will be placed.  So, click on some tile (preferably one that is set to Normal, not Solid).  This will pop up a new window.

* This window looks a lot more complicated than it is.  First of all, we must tell it which program to use for the NPC.  Click the Program File Name button, and select the program you just made (npc1.prg).  Also, we must set the graphic of the NPC.  At the bottom of the window, click on the Program Graphic button, and select the tileset into which the old man graphics was saved.  Select the old man's graphic, and finally, hit the Set Program' button at the bottom of the window.

* Save your board.

* Now the program is set, but you won't be able to see it on your screen. Instead, test run your game, and you should see the old man where you placed him.  Go and step on him, and the RPGCode program we wrote will run.
