Main      Site Guide    
Smash Tutorial

Sample Adventure: The Trainer

The "dragon.sma" File


This file handles the location at the top of the cliff, with the dragon and the key. Two basic situations must be accounted for: one, the dragon is alive and about to attack you; two, the dragon is dead, and we can find and take the key. Almost everything about these two situations is different. They require different area description texts and different sets of options.

But let's start with the one thing that's common between the two situations, which we can, therefore, code outside of any conditionals:

^ d Climb down the cliff. g rock

Whether the dragon is alive or not, we want the player to be able to climb down the cliff safely, so this takes care of it.

Hereafter, everything is contained inside a big if/else block. If the dragon is alive, do this set of things; otherwise, do another set of things. Here is the code used when the dragon is still alive:

c !dragon_dead . There is a fiery dragon here. She spies you and is not at all pleased that you are intruding in her domain. She rears her serpentine head and prepares to strike. c a:sword * 1 Kill the dragon with your sword. p The dragon lunges at you. You strike with your sword, but the weapon isn't heavy enough to do any damage. Then the dragon's head catches you in the chest and shoves you over the cliff.... l c a:axe * 2 Kill the dragon with your axe. p The dragon lunges at you. You strike with your battle axe. Its weight crushes into her head, causing her to recoil in shock. You take advantage of the opportunity and throw the axe at her underbelly. The dragon screeches in pain, hisses angrily, and flies away. s dragon_dead = 1 * 3 Say "Now, now, let's be reasonable." p The dragon doesn't share your sentiment. She breathes fire and toasts you to a crisp. Oh dear. l

In a nutshell, we have this variable "dragon_dead" that is initially 0, signifying that the dragon is still alive. When the player selects the "Kill the dragon with your axe" option, available only if the player actually has the axe at the time, "dragon_dead" gets set to 1, in which case none of the above code gets executed. Instead, the following C block gets executed instead:

C . You are on the top of a cliff. The earth is scorched where a dragon used to be resting. c d:key , You see a small key on the ground. * 4 Take the key. p Ok. a key * 5 Be weird. p You stuff leaves down your shirt and make choo-choo noises at uninterested worms.