Main      Site Guide    
Smash Tutorial

Sample Adventure: The Trainer

The "kobold.sma" File


This file handles the kobold and the entrance to the cave. There are two ways to interact with the kobold: first, the player can bribe the kobold by giving it the coin in exchange for passage into the cave. Later, he can use the sword to scare the kobold off. When the kobold runs away, he drops his battle axe, and the player may pick it up.

c kobold = 0 . You are standing on the shores of a placid lake. Waves lap the sand at regular intervals. A spooky cave, guarded by a nasty looking kobold, lies to the north. An east-west path travels by it. What next? C kobold = 1 . You are standing on the shores of a placid lake. A spooky cave lies to the north. An east-west path travels by it. The kobold's battle axe is lying here. C . You are standing on the shores of a placid lake. A spooky cave lies to the north. An east-west path travels by it.

This first block of code sets the area description. We use a variable called "kobold" to keep track of the situation at the time. When it's 0, the kobold is present and guarding the cave entrance. When it's 1, the kobold has run away, but the player hasn't picked up the battle axe yet. When it's 2, the kobold has run away, and the player has picked up the battle axe.

Each of these three cases requires a different area description text. We could have been more efficient at setting this by first setting the first line, common across all three texts, and then appending pieces with the , command as appropriate. This technique is used in some of the other location files, but this way works, too.

^ n Enter the cave. c kobold g cave C p The kobold stops you and lowers his battle axe menacingly. "Trespassing is strictly forbidden!" he growls. ^ e Go east. g rock ^ w Go west. g coin

The above options allow the player to travel to other locations. The only tricky one is entering the cave, which is only allowed if the "kobold" variable is not 0. When "kobold" is 0, we have designated that to mean that the kobold is still present, guarding the cave.

c !kobold * k Attack the kobold. c a:sword p You swing your sword at the kobold, but the monster blocks it with his battle axe. You swing again, this time grazing his forehead. The battle rages on. Finally the kobold gives up and flees. s kobold = 1 C p Without a weapon?? * ste Steal the kobold's battle axe. p Nice try, but the kobold catches you in the act. "Watch it, scum," he grunts. c a:coin * giv Give the kobold a coin. p "Tryin' to bribe me, eh?" the kobold sneers. "It worked. Get on in." You enter the cave. d coin g cave

The above block of code provides -- when the kobold is present -- some options for trying to deal with the kobold. The player can try to attack the kobold, but unless he has the sword, the game will prevent him from going through with it. If the player has the sword, the kobold runs away, leaving the battle axe behind. We set the "kobold" variable to 1 to reflect that.

C kobold = 1 * tak Take the battle axe. p Ok. a axe s kobold = 2

This C command connects up with the c !kobold block from earlier. When "kobold" is 1, the kobold has run away, leaving his battle axe behind. In this event, we want to provide the player with the option to pick up the axe. When he does so, the "kobold" variable becomes 2, to reflect that.

Finally, we supply one additional option in this location. It doesn't do anything useful, but it adds some flavor to the game:

* go Go swimming. p Yay! Splash! Splash! Happy! You like swimming.

It is important that options like this support the particular flavor of the game you are writing. If your game is comic and frivolous, options like the above and "Be weird" fit just fine. But if your game is more serious in tone -- a hard-boiled detective story, or a gothic horror tale, for example -- you should obviously refrain from goofy things like this and flesh out your game with something more fitting.