-------------------------------------------------------------------- -- -- O P T I O N S -- -------------------------------------------------------------------- -- Start with the options section. Here we define certain preferences -- concerning the overall game. -------------------------------------------------------------------- OPTIONS language english. -------------------------------------------------------------------- -- -- D E F A U L T A T T R I B U T E S -- -------------------------------------------------------------------- -- The defaults section defines attributes that every object or -- location should have. This is necessary to be able to refer to -- such attribute in general verb definitions. Here we have defined -- that the default behaviour of an object is to be 'takable'. Then -- we can say particulary for those that isn't that they are -- 'NOT takable' - things like doors and trees. -------------------------------------------------------------------- LOCATION ATTRIBUTES NOT in_forest. OBJECT ATTRIBUTES NOT openable. closed. takable. --------------------------------------------------------------------- -- -- S Y N O N Y M S -- --------------------------------------------------------------------- -- Synonyms is words that is meant to be completely interchangable -- from the players point of view. The word on the right hand side -- has to be defined elsewhere and the word (or words) on the left -- hand side is the synonym. -- Notice that words like 'look' and 'quit' has to be quoted when -- they refer to user input, since they also is reserved words in -- the ALAN language. --------------------------------------------------------------------- SYNONYMS north = n. south = s. west = w. east = e. down = d. up = u. l = 'look'. q = 'quit'. i = 'inventory'. pile = leaves. lunch = sandwich. lamp = lantern. magazine, report, newspaper, paper = issue. get = take. --------------------------------------------------------------------- -- -- S Y N T A X -- --------------------------------------------------------------------- -- The default syntax of a verb you have defined is VERB OBJECT, where -- verb is just one word. If you want the behaviour to be anything else -- you have to define the syntax you want. When you write bigger games -- it is good programming style to define the syntax for all your verbs. -- Here we have defined three verbs that don't take any object ("look", -- "quit" and "inventory"), two that should be able to handle multiple -- objects ("take" and "drop" - indicated by the *) and two verbs where -- the verb itself consists of two word ("turn on" and "turn off"). --------------------------------------------------------------------- SYNTAX 'look' = 'look'. 'quit' = 'quit'. take_inventory = 'inventory'. take = Take (obj) *. drop = Drop (obj) *. turn_on = Turn On (obj). light = Light (obj). turn_off = Turn Off (obj). open = Open (obj). close = Close (obj). --------------------------------------------------------------------- -- -- G L O B A L V E R B S -- --------------------------------------------------------------------- -- Here we have some global verb definitions, i.e. verb that should -- apply to most objects, or verb that doesn't need any object. --------------------------------------------------------------------- VERB 'look' DOES LOOK. END VERB. VERB 'quit' DOES QUIT. END VERB. VERB take_inventory DOES LIST inventory. END VERB. -- By using the attribute 'takable' we can define which objects can be -- taken and which are just meant to stay where they are. -- An attribute used in this way MUST be a default attribute to ensure -- that every object has it. VERB take CHECK obj IS takable ELSE "You can't take that!" AND obj NOT IN inventory ELSE "You've already got it." DOES LOCATE obj IN inventory. "Taken!" END VERB. VERB drop CHECK obj IN inventory ELSE "You havn't got it." DOES LOCATE obj HERE. "Dropped!" END VERB. -- Open works with two default attributes, 'openable' which defines if -- open should work with each object and 'closed' which is a default -- attribute that makes it possible to define a general meaning of -- the verb. VERB open CHECK obj IS openable ELSE "You can't open that!" AND obj IS closed ELSE "It is already open." DOES MAKE obj NOT closed. "The $o is now open." END VERB. VERB close CHECK obj IS openable ELSE "You can't close that!" AND obj IS NOT closed ELSE "It is not open." DOES MAKE obj closed. "The $o is now closed." END VERB. -- A default action for the verb Examine. $o refers to the print name -- of the object VERB examine DOES "I see nothing special about the $o." END VERB. ---------------------------------------------------------------------- -- -- E V E N T -- --------------------------------------------------------------------- -- This is an event used to make the impression of a bird chirping -- somewhere in the forest. The event itself is scheduled to execute -- where the hero is every fifth move. Every location has the attribute -- 'in_forest'. For most it is false, but for those locations considered -- to be in the forest 'in_forest' is true and the text will be printed -- (the bird will chirp). -- Notice that the event is first scheduled in the start section -- and then resceduled by itself every time it executes. --------------------------------------------------------------------- EVENT bird_chirp IF LOCATION IS in_forest THEN "You hear in the distance the chirping of a song bird." END IF. SCHEDULE bird_chirp AT hero AFTER 5. END EVENT. ---------------------------------------------------------------------- -- -- T H E W O R L D ( LOCATIONS AND OBJECTS ) -- ---------------------------------------------------------------------- -- Here starts the main part of the game - the map (i.e. the locations -- and their connections) and all the objects (scattered all over the -- world). ---------------------------------------------------------------------- ------------------- LOCATION w_of_house ------------------- NAME 'West of House' DESCRIPTION "Welcome to Dungeon (ALAN Demo). This version created 29-FEB-92. $pYou are in an open field west of a big white house with a boarded front door." EXIT n TO n_of_house. EXIT s TO s_of_house. -- An exit with a check without condition is a way to get an own -- message when the user tries that way (instead of the usual -- "You can't go that way.") It's a way to create the impression -- that it WOULD be possible to go that way, if only... -- Where the exit leads is irrelevant, since there is really no exit. EXIT e TO inside_house CHECK "The door is locked, and there is evidently no key." END EXIT. EXIT w TO forest3. END LOCATION. OBJECT mail_box NAME Small mailbox AT w_of_house CONTAINER IS openable. DESCRIPTION "There is a small mailbox here." IF mail_box IS NOT closed THEN LIST mail_box. END IF. VERB open DOES LIST mail_box. END VERB. END OBJECT. OBJECT leaflet IN mail_box VERB read DOES "'I hope you have noticed that this isn't your usual Dungeon but rather an ALAN implementation brought to you by $n$iThoNi & GorFo Adventure Factories $pHappy Adventuring!'" END VERB. END OBJECT. ------------------- LOCATION n_of_house ------------------- NAME 'North of House' DESCRIPTION "You are facing the north side of a white house. There is no door here, and all the windows are barred." EXIT n TO dimly_lit_forest. EXIT s TO inside_house CHECK "The windows are all barred." END EXIT. EXIT e TO behind_house. EXIT w TO w_of_house. END LOCATION. ------------------------- LOCATION dimly_lit_forest ------------------------- NAME Forest IS in_forest. DESCRIPTION "You are in a dimly lit forest, with large trees all around." EXIT n TO dimly_lit_forest2. EXIT e, s TO clearing. EXIT w TO n_of_house. EXIT u TO tree_top. END LOCATION. OBJECT tree AT dimly_lit_forest -- Since the global definition of Take checks if on object is 'takable' -- we can make the tree stay where we put it by defining it to be -- 'NOT takable'. IS NOT takable. DESCRIPTION "One particularly large tree with some low branches stands here." VERB climb DOES LOCATE HERO AT tree_top. END VERB. END OBJECT. ----------------- LOCATION tree_top ----------------- NAME 'Up a Tree' IS in_forest. DESCRIPTION "You are about ten feet above the ground nestled among some large branches. The nearest branch above you is beyond your reach." EXIT d TO dimly_lit_forest. END LOCATION. OBJECT birds_nest NAME Small birds nest AT tree_top CONTAINER DESCRIPTION IF birds_nest AT tree_top THEN "On the branch is a small birds nest." ELSE "There is a small birds nest here." END IF. LIST birds_nest. END OBJECT. OBJECT jewel_egg NAME Jewel encrusted egg IN birds_nest END OBJECT. -------------------------- LOCATION dimly_lit_forest2 -------------------------- NAME Forest IS in_forest. DESCRIPTION "You are in a dimly lit forest, with large trees all around. To the east, there appears to be sunlight." EXIT n TO s_of_house. EXIT s TO forest1. EXIT w TO forest3. EXIT e TO clearing. END LOCATION. ------------------- LOCATION s_of_house ------------------- NAME 'South of House' DESCRIPTION "You are facing the south side of a white house. There is no door here, and all the windows are barred." EXIT n TO inside_house CHECK "The windows are all barred." END EXIT. EXIT e TO behind_house. EXIT w TO w_of_house. EXIT s TO dimly_lit_forest2. END LOCATION. --------------------- LOCATION behind_house --------------------- NAME 'Behind House' DESCRIPTION "You are behind the white house." EXIT e TO clearing. EXIT n TO n_of_house. EXIT s TO s_of_house. -- Since 'in' is a reserved word we have to quote it to use it as a -- user name for the exit. EXIT w, 'in' TO kitchen CHECK outside_window IS NOT closed ELSE "The window is closed." END EXIT. END LOCATION. OBJECT outside_window NAME window AT behind_house IS NOT takable. IS openable. DESCRIPTION -- It is possible to make descriptions that depends on different -- attributes. You can use any kind of statement in a description. -- Note that the "xxx" form is not just a simple string - it is -- really a print statement. "In one corner of the house there is a window which is" IF outside_window IS NOT closed THEN "open." ELSE "slightly ajar." END IF. -- Since an object can only be at one place one way to implement such -- a thing as a window that can be reached both from 'outside' and -- 'inside' is to use two windows with the same name, and then be -- careful to operate both windows at the same time. VERB open DOES ONLY MAKE inside_window NOT closed. MAKE outside_window NOT closed. "With great effort, you open the window far enough to allow passage." END VERB. VERB close DOES ONLY MAKE inside_window closed. MAKE outside_window closed. "The window closes (more easily than it opened)." END VERB. END OBJECT. ----------------- LOCATION clearing ----------------- IS in_forest. DESCRIPTION "You are in a clearing, with a forest surrounding you on the west and south." EXIT e, n TO clearing. EXIT w TO dimly_lit_forest. EXIT s TO dimly_lit_forest2. END LOCATION. OBJECT leaves AT clearing DESCRIPTION IF leaves IN inventory THEN "You are carrying a pile of leaves." ELSE "There is a pile of leaves on the ground." END IF. -- The leaves initially covers the grating. If they are removed -- the grating should be presented for the player. But this should -- only happen if the grating is where the leaves are. OK, the -- grating can't be moved, but the leaves could be put in another -- place and THEN picked up. VERB take DOES IF grating HERE THEN "A grating appears on the ground." END IF. END VERB. END OBJECT. OBJECT grating AT clearing IS NOT takable. IS openable. IS NOT unlocked. DESCRIPTION -- If the pile of leaves is on the ground the grating can't be seen. -- I.e. they shoul'd be here but not carried. The way to make the -- grating invisible is ta make an empty description. This doesn't -- mean that the player can't refer to the grating. If we wanted -- that to happen we shouldn't put the grating there until the player -- removes the leaves. IF leaves HERE AND leaves NOT IN inventory THEN "" ELSE "There is a grating securely fastened into the ground." END IF. VERB open CHECK grating IS unlocked ELSE "The grating is locked." END VERB. END OBJECT. ---------------- LOCATION forest1 ---------------- NAME Forest IS in_forest. DESCRIPTION "You are in a large forest, with trees obstructing all views except to the east, where a small clearing may be seen." EXIT s TO forest1. EXIT n TO forest2. EXIT e TO canyon_view. EXIT w TO dimly_lit_forest2. END LOCATION. ---------------- LOCATION forest2 ---------------- NAME Forest IS in_forest. DESCRIPTION "You are in a forest, with trees in all directions around you." EXIT s TO forest1. EXIT n TO forest2. EXIT w TO dimly_lit_forest2. END LOCATION. ---------------- LOCATION forest3 ---------------- NAME Forest IS in_forest. DESCRIPTION "You are in a forest, with trees in all directions around you." EXIT n, w TO forest3. EXIT e TO dimly_lit_forest. EXIT s TO dimly_lit_forest2. END LOCATION. -------------------- LOCATION canyon_view -------------------- NAME 'Canyon View' DESCRIPTION "You are at the top of the great canyon on its south wall. From here there is a marvelous view of the canyon and parts of the Frigid River upstream. Across the canyon, the walls of the white cliffs still appear to loom far above. Following the canyon upstream (north and northwest), Aragain Falls may be seen, complete with rainbow. Fortunately, my vision is better than average, and I can discern the top of flood control dam #3 far to the distant north. To the west and south can be seen an immense forest, stretching for miles around. It is possible to climb down into the canyon from here." EXIT s, w TO forest1. EXIT d TO ledge. END LOCATION. -------------- LOCATION ledge -------------- DESCRIPTION "You are on a ledge about halfway up the wall of the river canyon. You can see from here that the main flow from Aragain Falls twists along a passage which it is impossible to enter. Below you is the canyon bottom. Above you is more cliff, which still appears climbable." EXIT d TO canyon_bottom. EXIT u TO canyon_view. END LOCATION. ---------------------- LOCATION canyon_bottom ---------------------- NAME 'Canyon Bottom' DESCRIPTION "You are beneath the walls of the river canyon, which may be climbable here. There is a small stream here, which is the lesser part of the runoff of Aragain Falls. To the north is a narrow path." EXIT u TO ledge. EXIT n TO beach. END LOCATION. -------------- LOCATION beach -------------- DESCRIPTION "You are on a small beach on the continuation of the Frigid River past the falls. The beach is narrow due to the presence of the white cliffs. The river canyon opens here, and sunlight shines in from above. A rainbow crosses over the falls to the west, and a narrow path continues to the southeast." EXIT se TO canyon_bottom. END LOCATION. ---------------- LOCATION kitchen ---------------- DESCRIPTION "You are in the kitchen of the white house." -- The describe statement makes it possible to force the description -- of e.g. an object. An object at this location that has been described -- in this way will not be printed among the other objects after the -- locations description. This is a way to make objects more smoothly -- be presented in the text. DESCRIBE table. "A passage leads to the west, and a dark staircase can be seen leading upward." DESCRIBE inside_window. EXIT e, out TO behind_house CHECK inside_window IS NOT closed ELSE "The window is closed." END EXIT. EXIT u TO upstairs. EXIT w TO inside_house. END LOCATION. OBJECT table AT kitchen CONTAINER -- A container can also be used as supporter. We only changes the header -- to give the impression we want. HEADER "On the table you can see" IS NOT takable. DESCRIPTION "A table seems to have been used recently for the preparation of food." LIST table. END OBJECT. OBJECT sack NAME elongated brown sack IN table CONTAINER IS openable. ARTICLE "an" MENTIONED "elongated brown sack, smelling of hot peppers" VERB open DOES EMPTY sack_content IN sack. LIST sack. END VERB. VERB close DOES EMPTY sack IN sack_content. END VERB. END OBJECT. -- A way to make object in a container non-accessible when the container -- is closed is to empty the container in another container (not here) -- when it is closed and to move the objects the other way when it's open. OBJECT sack_content CONTAINER END OBJECT. OBJECT lunch NAME hot pepper sandwich IN sack_content -- 'Mentioned' is the string that is printed e.g. when the contents -- of a container is listed. MENTIONED "a lunch" END OBJECT. OBJECT garlic NAME clove 'of' garlic IN sack_content END OBJECT. OBJECT bottle NAME clear glass bottle IN table CONTAINER IS openable. DESCRIPTION "There is a clear glass bottle here." LIST bottle. END OBJECT. -- To use 'of' in this way is a little cheating. It will define -- 'of' as an adjective and it will be possible to refer to the -- water as "of water" as well as "quantity water". OBJECT water NAME quantity 'of' water IN bottle VERB take CHECK bottle IS NOT closed ELSE "I can't reach the quantity of water." -- The qualifier 'only' means that ONLY this definition (and not the -- global one) should be used. It means that the water won't be put in -- the inventory when taken - the only thing that will happen is that -- this text will be printed. DOES ONLY "The water slips through your fingers." END VERB. VERB drink CHECK bottle IS NOT closed ELSE "I can't reach the quantity of water." DOES "Thank you very much. I was rather thirsty, probably from all this talking." LOCATE water AT nowhere. END VERB. END OBJECT. OBJECT inside_window NAME window AT kitchen IS NOT takable. IS openable. DESCRIPTION "To the east is a small window which is" IF inside_window IS NOT closed THEN "open." ELSE "closed." END IF. VERB open DOES ONLY MAKE inside_window NOT closed. MAKE outside_window NOT closed. "With great effort, you open the window far enough to allow passage." END VERB. VERB close DOES ONLY MAKE inside_window closed. MAKE outside_window closed. "The window closes (more easily than it opened)." END VERB. END OBJECT. --------------------- LOCATION inside_house --------------------- NAME 'Living room' DESCRIPTION "You are in the living room. There is a door to the east." DESCRIBE wooden_door. DESCRIBE trophy_case. EXIT e TO kitchen. EXIT w TO w_of_house CHECK "The door is nailed shut." END EXIT. EXIT d TO magnificient_view CHECK trap_door HERE ELSE "You can't go that way." AND trap_door IS NOT closed ELSE "The door is closed." END EXIT. END LOCATION. OBJECT wooden_door NAME wooden door AT inside_house IS openable. IS NOT takable. DESCRIPTION "To the west is a wooden door with strange gothic lettering, which appears to be nailed shut." VERB read DOES "The engravings translate to, 'This space intentionally left blank'." END VERB. VERB open DOES ONLY "The door cannot be opened." END VERB. END OBJECT. OBJECT trophy_case NAME trophy case AT inside_house IS NOT takable. IS openable. END OBJECT. OBJECT rug AT inside_house DESCRIPTION "In the center of the room is a large oriental rug." VERB take DOES ONLY "The rug is extremely heavy and cannot be carried." END VERB. VERB move DOES "With a great effort, the rug is moved to one side of the room." LOCATE trap_door HERE. DESCRIBE trap_door. END VERB. END OBJECT. OBJECT trap_door NAME trap door IS NOT takable. IS openable. DESCRIPTION "With the rug moved, the dusty cover of a closed trap door appears." VERB open DOES ONLY "The door reluctantly opens to reveal a rickety staircase descending into darkness." MAKE trap_door NOT closed. END VERB. END OBJECT. OBJECT sword NAME elvish sword AT inside_house IS NOT taken. DESCRIPTION -- This sword can't be put back on the mantlepiece. By using an -- attribute that will be marked as true first time you take it -- you will forever change its description. As you can see, it's -- not really on any mantlepiece - it just looks that way. IF sword IS NOT taken THEN "On hooks above the mantlepiece hangs an elvish sword of great antiquity." ELSE "There is an antique elvish sword here." END IF. VERB take DOES MAKE sword taken. END VERB. END OBJECT. OBJECT lantern NAME battery brass lantern AT inside_house IS NOT lit. IS NOT taken. DESCRIPTION IF lantern IS NOT taken THEN "A battery-powered brass lantern is on the trophy case." ELSE "A battery-powered brass lantern is here." END IF. VERB take DOES MAKE lantern taken. END VERB. VERB light, turn_on DOES MAKE lantern lit. "The lamp is now on." END VERB. VERB turn_off DOES MAKE lantern NOT lit. "The lamp is now off." END VERB. END OBJECT. OBJECT issue AT inside_house DESCRIPTION "There is an issue of US NEWS & DUNGEON REPORT dated 29-FEB-92 here." VERB read DOES "$tUS NEWS & DUNGEON REPORT $n29-FEB-92.........................Late Dungeon Edition $n$t--- LATE NEWS FLASH!! --- $n$nThe Dungeon prelude is now available as an ALAN implementation. $nThe Dungeon game was selected as an example that everybody interested in adventure gaming should recognize." END VERB. END OBJECT. ----------------- LOCATION upstairs ----------------- DESCRIPTION "You are in the attic. The only exit is stairs that lead down." EXIT d TO kitchen. END LOCATION. OBJECT rope AT upstairs DESCRIPTION "A large coil of rope is lying in the corner." END OBJECT. OBJECT brick NAME square clay brick AT upstairs DESCRIPTION "There is a square brick here which feels like clay." END OBJECT. OBJECT nasty_knife NAME nasty knife AT upstairs DESCRIPTION "A nasty-looking knife is lying here." END OBJECT. -------------------------- LOCATION magnificient_view -------------------------- NAME 'Breath-Taking View' DESCRIPTION "And here we have a very special guest, straight from Colossal Cave - the Breath-Taking View!" "$p" "You are on the edge of a breath-taking view. Far below you is an active volcano, from which great gouts of molten lava come surging out, cascading back down into the depths. The glowing rock fills the farthest reaches of the cavern with a blood-red glare, giving everything an eerie, macabre appearance. The air is filled with flickering sparks of ash and a heavy smell of brimstone. The walls are hot to the touch, and the thundering of the volcano drowns out all other sounds. Embedded in the jagged roof far overhead are myriad twisted formations composed of pure white alabaster, which scatter the murky light into sinister apparitions upon the walls. To one side is a deep gorge, filled with a bizarre chaos of tortured rock which seems to have been crafted by the devil himself. An immense river of fire crashes out from the depths of the volcano, burns its way through the gorge, and plummets into a bottomless pit far off to your left. Across the gorge, the entrance to a valley is dimly visible. To the right, an immense geyser of blistering steam erupts continuously from a barren island in the center of a sulfurous lake, which bubbles ominously. The far right wall is aflame with an incandescence of its own, which lends an additional infernal splendor to the already hellish scene. A dark, foreboding passage exits to the south." "$p" "You have now reached the end of this ALAN demo, but it sure shouldn't be the end of of adventuring. It is now up to You, the adventure writer to ensure the continuation of the era of the adventure games. So just don't sit there. Get your plots ready and get down to serious adventure writing." DOES QUIT. END LOCATION. ---------------- LOCATION nowhere ---------------- -- This is a location with no connections to the world. It's only -- reason for existens is to get a place to dump objects that no -- longer should take part in the game (like the water in the bottle). -- This is because there is no way to REALLY remove an object from -- the game. END LOCATION. --------------------------------------------------------------------- -- -- S T A R T S E C T I O N -- --------------------------------------------------------------------- -- Here we define where the player should be in the beginning of the -- game and here can we also put code for initializing and maybe write -- an introduction. 'Visits 3' means that the locations -- should only be fully described every 4th time the player visits -- them (3 visits in between). --------------------------------------------------------------------- START AT w_of_house. VISITS 3. SCHEDULE bird_chirp AT hero AFTER 3.