!---------------------------------------------------------------------------
! 
!        HUGO ZORK
!        A Hugo Port of Infocom's Zork I
!        Zork I is copyright by Activision and is used without permission
!        Source code written by John Menichelli
!
! Modified for Hugo v2.4, v2.5
! by K. Tessman
!---------------------------------------------------------------------------

#version 2.5			! KT

! #set DEBUG                              ! include HugoFix library and grammar
#set VERBSTUBS                          ! include verb stub routines
#set USE_VEHICLES                       ! from OBJLIB.H
#set USE_ATTACHABLES                    !
#set NO_AUX_MATH                        ! don't need advanced math routines

#switches -ls                           ! print statistics to HZ.LST

!----------------------------------------------------------------------------
!       NEW ACTION VERBS
!----------------------------------------------------------------------------

verb "board"
        * (magic_boat)                                  DoEnter

verb "launch"
        *                                               DoLaunch

verb "land"
        *                                               DoLand

verb "count"
        *                                               DoVague
        * object                                        DoCount

verb "fly"
        *                                               DoVague
        * object                                        DoFly

verb "ulysses", "odysseus"
        *                                               DoSailor

verb "lift"
        *                                               DoVague
        * object                                        DoLift

verb "jump"
        *                                               DoJump

verb "turn" "flip"
        *                                               DoVague
        * object                                        DoTurn
        * object "with" xobject                         DoTurn

verb "find"
        *                                               DoVague
        * object                                        DoFind

verb "raise", "lift"
        *                                               DoVague
        * object                                        DoRaise

verb "lower"
        *                                               DoVague
        * object                                        DoLower

verb "ring"
        *                                               DoVague
        * held                                          DoRing

verb "burn", "light", "incinerate"
        *                                               DoVague
        * object                                        DoBurn
        * object "with" xobject                         DoBurn
        * object "with" held                            DoBurn

verb "extinguish" "douse"
        *                                               DoVague
        * object                                        DoExtinguish

verb "push", "shove"
        *                                               DoVague
        * object "with" xobject                         DoPushWith
        * "on" object                                   DoPush
        * object                                        DoPush

verb "pump" "inflate"
        *                                               DoVague
        * "up" object "with" xobject                    DoPump
        * object "with" xobject                         DoPump
        * "up" object                                   DoPump
        * object                                        DoPump

verb "deflate"
        *                                               DoVague
        * object                                        DoDeflate

verb "poke" "puncture"
        *                                               DoVague
        * object "with" xobject                         DoPoke
        * object                                        DoPoke

verb "patch" "repair" "glue"
        *                                               DoVague
        * object "with" xobject                         DoPatch
        * object                                        DoPatch

verb "wind"
        * "up"                                          DoVague
        *                                               DoVague
        * "up" object                                   DoWind
        * object                                        DoWind

verb "dig", "burrow"
        *                                               DoVague
        * "in"/"into" object                            DoDig
        * object                                        DoDig
        * "in"/"into" object "with" xobject             DoDig
        * object "with" xobject                         DoDig

verb "throw", "hurl", "toss"
        * held "in"/"into" xobject                      DoThrowIn
        *                                               DoVague
        * held                                          DoThrowAt
        * held "at" xobject                             DoThrowAt

verb "go", "walk"
        * "around"                                      DoWalkAround
        * "around" object                               DoWalkAround
        * "on" object                                   DoWalkOn
        * "to"/"in"/"into"/"inside"/"through" object    DoEnter
        * "out" object                                  DoGo
        * "out"/"outside"                               DoExit
        * object                                        DoGo
        
verb "cross"
        *                                               DoVague
        * object                                        DoWalkOn

verb "kill", "murder", "fight"
        *                                               DoVague
        * object                                        DoHit
        * object "with" held                            DoHit

verb "diagnose"
        *                                               DoDiagnose

verb "read" "skim" "peruse"
        *                                               DoVague
        * "from" readable                               DoRead
        * readable                                      DoRead

verb "squeeze"
       *                                                DoVague
       * object                                         DoSqueeze

verb "echo"
        *                                               DoEcho

verb "treasure"
        *                                               DoTreasure

verb "temple"
        *                                               DoTemple

verb "pray"
        *                                               DoPray

verb "zork"
        *                                               DoZork

verb "xyzzy", "plugh"
        *                                               DoFool

verb "chomp", "barf"
        *                                               DoChomp

verb "win"
        *                                               DoWin

verb "repent"
        *                                               DoRepent

verb "bug"
        *                                               DoBug

verb "mumble", "sigh"
        *                                               DoMumble

verb "damn" "fuck" "shit"
        *                                               DoCurse
        * object                                        DoCurse

verb "frobozz"
        *                                               DoFrobozz

verb "smell", "sniff", "inhale", "breathe"
        *                                               DoVague
        * object                                        DoSmell

verb "molest" "rape"
        *                                               DoVague
        * object                                        DoMolest

verb "fill"
        *                                               DoVague
        * object                                        DoFill

verb "pour" "spill"
        *                                               DoVague
        * object                                        DoPour
        * object "on" xobject                           DoPour

verb "touch", "feel", "rub"
        *                                               DoVague
        * object                                        DoTouch

verb "shake"
        *                                               DoVague
        * object                                        DoShake

verb "what"
        * "is" object                                   DoLook

verb "oil" "grease" "lubricate"
        *                                               DoVague
        * object                                        DoOil
        * object "with" xobject                         DoOil

!----------------------------------------------------------------------------
!       NEW NON-ACTION VERB
!----------------------------------------------------------------------------

xverb "help"     
        *                                               DoHelp
        * "me"                                          DoHelp

#include "verblib.g"	! KT				! normal game grammar

!----------------------------------------------------------------------------
#ifset PRECOMPILED_LIBRARY
#link "hugolib.hlb"
#endif
#ifclear PRECOMPILED_LIBRARY
#include "hugolib.h"                    ! standard library routines
#endif
!----------------------------------------------------------------------------

!----------------------------------------------------------------------------
!       NEW GLOBALS, PROPERTIES AND ATTRIBUTES
!----------------------------------------------------------------------------

global reservoir_status
global reservoir_level
global maint_room_level
global rank
global match_count
global ceremony_1 
global ceremony_2
global candle_life
global hole_depth
global wound_level
global turns_to_heal
global current_hit_points
global max_hit_points
global lives_used
global current_threat_level
global old_threat_level
global dark_warning
global combat_result
global damage
global old_thief_location

property no_weapon
property knocked_out
property take_damage
property hit_points
property take_points       ! for picking up treasure
property deposit_points    ! for putting the treasure into the trophy case
property room_points       ! for entering certain rooms
property threat_level      ! 0 = Sword not glowing
                           ! 1 = Sword is glowing faintly
                           ! 2 = Sword is glowing brightly

attribute unconscious
attribute stunned
attribute disarmed
attribute burnable
attribute found
attribute deposited
attribute valuable
attribute room_scored
attribute heat_source
attribute broken
attribute thief_free
attribute water_location
attribute ghost
attribute hostile
attribute weapon
attribute sharp


!----------------------------------------------------------------------------
!       INIT
!----------------------------------------------------------------------------

routine init
{
        MAX_SCORE = 350
        ranking[0] = "Beginner"
        ranking[1] = "Amateur Adventurer"
        ranking[2] = "Novice Adventurer"
        ranking[3] = "Junior Adventurer"
        ranking[4] = "Adventurer"
        ranking[5] = "Master"
        ranking[6] = "Wizard"
        ranking[7] = "Master Adventurer"

	counter = -1                    ! 1 turn before turn 0

	STATUSTYPE = 1                  ! score/turns
        TEXTCOLOR = WHITE
        BGCOLOR = BLUE
        SL_TEXTCOLOR = BLUE
        SL_BGCOLOR = WHITE
        FORMAT = NOINDENT_F + LIST_F
        AFTER_PERIOD = " "
        
DEFAULT_FONT = PROP_ON			! KT
Font(DEFAULT_FONT)

	prompt = ">"
	color TEXTCOLOR, BGCOLOR

	cls

        "HUGO ZORK: The Great Underground Empire"
        "A Port of Infocom's Zork I to Hugo"
        "Beta Release 1"
        "Hugo Zork written by John Menichelli"
        "\"Zork I\" is copyright by Activision and is used without permission"
	print BANNER

	Font(BOLD_ON)
        "(New players should type \"help\")"
	Font(BOLD_OFF)

	player = you
        location = west_of_house
	old_location = location

	move player to location         ! initialize player location
	FindLight(location)             ! whether the player can see
	DescribePlace(location)         ! the appropriate description
	location is visited
	CalculateHolding(player)        ! total size of player contents
        Activate(ChirpingBird)          ! Displays "chirping bird" messages
        Activate(HealPlayer)            ! Heals player if injured
        Activate(ThiefDaemon)           ! Moves the thief around
        reservoir_status = 1            ! 1 = reservoir full
                                        ! 2 = reservoir drained
                                        ! 3 = reservoir draining
                                        ! 4 = reservoir filling
        reservoir_level = 9             ! reservoir is full
        maint_room_level = 0            ! level of water in maintenance room
        match_count = 5                 ! For the matches in the Dam Lobby
        score = 0
        candle_life = 75                ! For the candles in the Altar Room
        hole_depth = 0                  ! At Sandy Cave
        wound_level = 0                 ! How wounded the character is
        turns_to_heal = 0               ! How long it takes for the player
                                        ! to completely heal
        current_hit_points = 2
        max_hit_points = 2
        lives_used = 0                  ! Out of three
        current_threat_level = 0        ! For the "glowing sword" messages
        old_threat_level = 0
        rank = 0                        ! For scoring
        dark_warning = 0                ! For the DarkWarning routine
}

#ifset PRECOMPILED_LIBRARY
replace main
{
#endif
#ifclear PRECOMPILED_LIBRARY
routine main
{
#endif
        counter++
        PrintStatusLine
	run location.each_turn
	runevents
	RunScripts
	if speaking not in location     ! in case the character being spoken
		speaking = 0            ! to leaves
}

player_character you "you"
{
	long_desc
        {
                "That's difficult unless your eyes are prehensile."
        }
        before
        {
                actor
                {
                    if not FindLight(location)
                    {
                        if (verbroutine = &DoGet or
                            verbroutine = &DoTouch) and
                           not Contains(player, object)
                        {
                                "It's too dark to see!"
                                return true
                        }
                    }

                    if player is not ghost
                    {
                            return false
                    }
                    elseif verbroutine = &DoScore
                    {
                            "You're dead! How can you think of your
                            score?"
                            return true
                    }
                    elseif verbroutine = &DoEat, &DoDrink, &DoOpen,
                            &DoClose, &DoTurn, &DoBurn, &DoTouch,
                            &DoExtinguish
                    {
                            "Even such an action is beyond your
                            capabilities."
                            return true
                    }
                    elseif verbroutine = &DoPump, &DoDeflate, &DoTie,
                           &DoUntie, &DoMove, &DoPull
                    {
                            "Even such an action is beyond your
                            capabilities."
                            return true
                    }
                    elseif verbroutine = &DoSwitchOn
                    {
                            "You need no light to guide you."
                            return true
                    }
                    elseif verbroutine = &DoInventory
                    {
                            "You have no possessions."
                            return true
                    }
                    elseif verbroutine = &DoDiagnose
                    {
                            "You are dead."
                            return true
                    }
                    elseif verbroutine = &DoLookAround, &DoLookIn,
                           &DoLookThrough, &DoLookUnder
                    {
                            if location is not light
                            {
                                   "Although there is no light, the room
                                   seems dimly illuminated."
                                   return false
                            }
                            else
                            {
                                    "The room looks strange and unearthly";
                                    if children(location) > 1
                                    {
                                            " and objects appear
                                            indistinct."
                                    }
                                    else
                                    {
                                            "."
                                    }
                                    return false
                            }
                    }
                    elseif verbroutine = &DoPray
                    {
                            if location = altar_room
                            {
                                "From the distance the sound of a
                                lone trumpet is heard. The room
                                becomes very bright and you feel
                                disembodied. In a moment, the brightness
                                fades and you find yourself rising as if
                                from a long sleep, deep in the woods. In
                                the distance you can faintly hear a
                                songbird and the sounds of the forest."

                                player is not ghost
                                player is not light
                                trap_door is special
                                Activate(ThiefDaemon)
                                MovePlayer(forest1)
                            }
                            else
                            {
                                    "Your prayers are not heard."
                                    return true
                            }
                    }
                    elseif verbroutine = &DoHit
                    {
                            "All such attacks are vain in your
                            condition."
                            return true
                    }
                    elseif verbroutine = &DoGet, &DoPush
                    {
                            "Your hand passes through the object."
                            return true
                    }
                    elseif verbroutine = &DoEnter
                    {
                            "You cannot enter in your condition."
                            return true
                    }
                    elseif verbroutine = &DoWait
                    {
                            "Might as well. You've got an eternity."
                            return true
                    }
                    else
                    {
                            return false
                    }
                }
                object DoFind
                {
                        "You're around here somewhere..."
                }
                object DoGet
                {
                        "How romantic!"
                }
                object DoEat
                {
                        "Auto-cannibalism is not the answer."
                }
                object DoHit
                {
                        "If you insist.... Poof, you're dead!"
                        NotDeadYet
                }
        }
}

!----------------------------------------------------------------------------
!       NEW ROOM TYPES
!----------------------------------------------------------------------------

room DarkRoom
{
        is not light, not thief_free
        room_points 0
        threat_level 0
        after
        {
                AnyVerb(location)
                {
                        old_threat_level = current_threat_level
                        current_threat_level = self.threat_level

                        if current_threat_level ~= old_threat_level and
                           Contains(player, sword)
                        {
                                "Your sword ";
                                select current_threat_level
                                case 0
                                {
                                        "is no longer glowing."
                                }
                                case 1
                                {
                                        "is glowing with a faint blue glow."
                                }
                                case 2
                                {
                                        "has begun to glow very brightly."
                                }
                        }

                        if self is not room_scored
                        {
                                score += self.room_points
                                self is room_scored
                        }
                        return false
                }
        }
}

room LightRoom
{
        is light, not thief_free
        room_points 0
        threat_level 0
        after
        {
                AnyVerb(location)
                {
                        old_threat_level = current_threat_level
                        current_threat_level = self.threat_level

                        if current_threat_level ~= old_threat_level and
                           Contains(player, sword)
                        {
                                "Your sword ";
                                select current_threat_level
                                case 0
                                {
                                        "is no longer glowing."
                                }
                                case 1
                                {
                                        "is glowing with a faint blue glow."
                                }
                                case 2
                                {
                                        "has begun to glow very brightly."
                                }
                        }

                        if self is not room_scored
                        {
                                score += self.room_points
                                self is room_scored
                        }
                        return false
                }
        }
}

room MazeRoom
{
        is not light, not thief_free
        threat_level 0
	long_desc
        {
                "This is part of a maze of twisty little passages,
		all alike."
        }
        after
        {
                AnyVerb(location)
                {
                        old_threat_level = current_threat_level
                        current_threat_level = self.threat_level

                        if current_threat_level ~= old_threat_level and
                           Contains(player, sword)
                        {
                                "Your sword ";
                                select current_threat_level
                                case 0
                                {
                                        "is no longer glowing."
                                }
                                case 1
                                {
                                        "is glowing with a faint blue glow."
                                }
                                case 2
                                {
                                        "has begun to glow very brightly."
                                }
                        }
                        return false
                }
        }
}

room Dead_End_Room
{
        is not light, not thief_free
	long_desc
        {
                "You have come to a dead end in the maze."
        }
}

room CoalRoom
{
        is not light, thief_free
        long_desc
        {
                "This is a non-descript part of a coal mine."
        }
}

!----------------------------------------------------------------------------
!    NEW CLASSES
!----------------------------------------------------------------------------

class treasure
{
        take_points 10       ! points awarded when item is picked up

        deposit_points 10    ! points awarded when item is put into
                             ! trophy case
        before
	{
		object DoGet
		{
                        if self is not found
                        {
                                score += self.take_points
                                self is found
                        }
                        return false
		}
	}
        is valuable
}

class boat
{
        type vehicle
        prep "in", "out"
        vehicle_move true
        is enterable, container, open, not static, burnable
}

class creature
{
	type character
	pronouns "he", "him", "his", "himself"
	capacity 50
	holding 0
        is living, transparent, static, unfriendly
}


!----------------------------------------------------------------------------
!    FUSES AND DAEMONS
!----------------------------------------------------------------------------

daemon LampDaemon
{}

event LampDaemon
{
	local t

        self = lamp
	
        self.misc--
	t = self.misc

	if t <= 0
        {
                self.misc = 0
		t = 0
		self is not switchedon
                self is not light
        }
	
	if FindObject(self, location)
	{
                select t
                case 195
                {
                        event_flag = true
                        "The lamp appears a bit dimmer."
                }
                case 95
                {
                        event_flag = true
                        "The lamp is definitely dimmer now."
                }
                case 25
                {
                        event_flag = true
                        "The lamp is nearly out."
                }
                case 0
                {
                        event_flag = true
                        "You'd better have more light than from the brass
                        lantern."
                        Deactivate(LampDaemon)
                        self is not switchedon
                }
	}
}

daemon ChirpingBird
{}

event ChirpingBird
{
        if location = forest_path or
            location = forest1 or
            location = forest2 or
            location = forest3 or
            location = forest4 or
            location = up_a_tree
        {
                if random(10) <= 2
                {
                        event_flag = true
                        "You hear in the distance the chirping of a
                        song bird."
                }
        }
}

daemon FillDam
{}

event FillDam
{
        reservoir_level++
        if reservoir_level < 9
        {
                reservoir_status = 4 ! reservoir is filling
                loud_room is special ! It's quiet
                if location = reservoir and
                   parent(player) ~= magic_boat
                {
                        event_flag = true
                        "You notice that the water level here is rising
                        rapidly. The currents are also becoming stronger.
                        Staying here seems quite perilous!"
                }
        }
        elseif reservoir_level = 9
        {
                reservoir_status = 1 ! reservoir is full
                Deactivate(FillDam)
                remove trunk_of_jewels
                reservoir is water_location
                loud_room is not special
                if location = reservoir_south
                {
                        event_flag = true
                        "You notice that the water level has risen to the
                        point that it is impossible to cross."
                }
                elseif location = loud_room
                {
                        event_flag = true
                        "All of a sudden, an alarmingly loud roaring sound
                        fills the room. Filled with fear, you scramble
                        away."

                        DoTooLoud
                }
                elseif location = deep_canyon
                {
                        event_flag = true
                        "A sound, like that of flowing water, starts to come
                        from below."
                }
                elseif location = reservoir and
                   parent(player) = magic_boat
                {
                        event_flag = true
                        "The boat lifts gently out of the mud and is now
                        floating on the reservoir."
                }
                elseif location = reservoir
                {
                        event_flag = true
                        "You are lifted up by the rising river! You try to
                        swim, but the currents are too strong. You come
                        closer, closer to the awesome structure of Flood
                        Control Dam #3. The dam beckons to you. The roar of
                        the water nearly deafens you, but you remain
                        conscious as you tumble over the dam toward your
                        certain doom among the rocks at its base."

                        NotDeadYet
                }
        }
}

daemon EmptyDam
{}

event EmptyDam
{
        reservoir_level--
        if reservoir_level > 0
        {
                reservoir_status = 3 ! reservoir is draining
                loud_room is not special ! It's loud
        }
        elseif reservoir_level = 0
        {
                reservoir_status = 2 ! reservoir is drained
                reservoir is not water_location
                Deactivate(EmptyDam)
                move trunk_of_jewels to reservoir
                if location = reservoir_south
                {
                        event_flag = true
                        "The water level is now quite low here and you could
                        easily cross over to the other side."
                }
                elseif location = deep_canyon
                {
                        event_flag = true
                        "The roar of rushing water is quieter now."
                }
                elseif location = reservoir and
                   parent(player) = magic_boat
                {
                        event_flag = true
                        "The water level has dropped to the point at which
                        the boat can no longer stay afloat. It sinks into
                        the mud."
                }
        }
}

daemon FillMaintRoom
{}

event FillMaintRoom
{

        maint_room_level++

        if location = maintenance_room and
           maint_room_level < 14
        {
                event_flag = true
                "The water level here is now up to your ";
                select maint_room_level
                case 0, 1
                        "ankles."
                case 2, 3
                        "shin."
                case 4, 5
                        "knees."
                case 6, 7
                        "hips."
                case 8, 9
                        "waist."
                case 10, 11
                        "chest."
                case 12, 13
                        "neck."
        }
        if maint_room_level = 14
        {
                 Deactivate(FillMaintRoom)
        }
        if location = maintenance_room and
            maint_room_level = 14
        {
                event_flag = true
                "I'm afraid you have done drowned yourself."
                 NotDeadYet
        }
}

fuse HotBell ! When the brass bell is rung, it takes 20 turns for it
{}           ! to cool down.

event HotBell
{
        if not self.tick
        {
                remove red_hot_bell
                move brass_bell to entrance_to_hades
                if red_hot_bell in location
                {
                        event_flag = true
                        "The bell appears to have cooled down."
                }
        }
}

fuse Match
{}

event Match
{
        if not self.tick
        {
                event_flag = true
                "The match has gone out."
                matchbook is not light
                matchbook is not heat_source
        }
}

fuse Ceremony
{}

event Ceremony
{
        if not self.tick
        {
                if player in entrance_to_hades
                {
                        event_flag = true
                        "\nThe tension of this ceremony is broken, and the
                        wraiths, amused but shaken at your clumsy attempt,
                        resume their hideous jeering."
                }
                ceremony_1 = 0 ! resets the ceremony
                ceremony_2 = 0
        }
}

daemon Candle
{}

event Candle
{
        ! This only reduces candle life if the player is carrying
        ! lit candles or the lit candles are in the player's location

        if Contains(player, candles) or
           Contains(location, candles)
        {
                candle_life--

                select candle_life
                case 35
                {
                        event_flag = true
                        "The candles grow shorter."
                }
                case 15
                {
                        event_flag = true
                        "The candles are becoming quite short."
                }
                case 5
                {
                        event_flag = true
                        "The candles won't last long now."
                }
                case 0
                {
                        event_flag = true

                        "You'd better have more light than from the
                        pair of candles."

                        candles is not light
                        candles is not heat_source
                        Deactivate(Candle)
                        FindLight(location)
                }
        }
}

fuse RiverCurrent
{}

event RiverCurrent
{
        if not self.tick
        {
                event_flag = true
                "The flow of the river carries you downstream."

                select location
                case river1
                {
                        move magic_boat to river2
                        location = river2
                        DescribePlace(location, 1)
                        Deactivate(RiverCurrent)
                        Activate(RiverCurrent, 4)
                        Break
                }
                case river2
                {
                        move magic_boat to river3
                        location = river3
                        DescribePlace(location, 1)
                        Deactivate(RiverCurrent)
                        Activate(RiverCurrent, 3)
                        Break
                }
                case river3
                {
                        move magic_boat to river4
                        location = river4
                        DescribePlace(location, 1)
                        Deactivate(RiverCurrent)
                        Activate(RiverCurrent, 2)
                        Break
                }
                case river4
                {
                        move magic_boat to river5
                        location = river5
                        DescribePlace(location, 1)
                        Deactivate(RiverCurrent)
                        Activate(RiverCurrent, 1)
                        Break
                }
                case river5
                {
                        "\nUnfortunately, the magic boat doesn't provide
                        protection from the rocks and boulders one meets
                        at the bottom of waterfalls. Including this one."
                        Deactivate(RiverCurrent)
                        NotDeadYet
                }
        }
}

daemon HealPlayer
{}

event HealPlayer
{
        if player is stunned
        {
                player is not stunned
        }

        CalculateRank
        max_hit_points = (rank/2) + 2

        if max_hit_points > current_hit_points and
           turns_to_heal = 0
        {
                current_hit_points = max_hit_points
        }

        if turns_to_heal > 0
        {
                turns_to_heal--
                select turns_to_heal
                case 0
                {
                        wound_level = 0
                        current_hit_points = max_hit_points
                }
                case 30
                {
                        wound_level = 1
                        current_hit_points++
                }
                case 60
                {
                        wound_level = 2
                        current_hit_points++
                }
                case 90
                {
                        wound_level = 3
                        current_hit_points++
                }
                case 120
                {
                        wound_level = 4
                        current_hit_points++
                }
        }
}

! This daemon moves the thief around the dungeon. It doesn't move the
! thief on a fixed track, since that would allow the player to catch up
! to him.

daemon ThiefDaemon
{}

event ThiefDaemon
{
        local a, b, c, d, i, j, dest, diff

        self = thief

        if self in location and
           self is hostile
        {
                if contains(player, sword)
                {
                        "Your sword has begun to glow very brightly."
                }
                event_flag = true
                Jump ThiefAttacks
        }
        
        ! If the thief is hostile, skip this part

        ! The longer the game goes on, the more likely the thief will come
        ! to visit
        a = 350 - counter
        if a < 10
                a = 10
        b = random(a)

        if b = 1 and
           location is not thief_free
        {
                move self to location
                old_thief_location = location
        }
        else
        {
                do
                {
                        a = random(45)
                        select a
                        case 1
                                dest = maze1
                        case 2
                                dest = maze2
                        case 3
                                dest = maze3
                        case 4
                                dest = maze4
                        case 5
                                dest = maze5
                        case 6
                                dest = maze6
                        case 7
                                dest = maze7
                        case 8
                                dest = maze8
                        case 9
                                dest = maze9
                        case 10
                                dest = maze10
                        case 11
                                dest = maze11
                        case 12
                                dest = maze12
                        case 13
                                dest = maze13
                        case 14
                                dest = maze14
                        case 15
                                dest = maze15
                        case 16
                                dest = dead_end1
                        case 17
                                dest = dead_end2
                        case 18
                                dest = dead_end3
                        case 19
                                dest = dead_end4
                        case 20
                                dest = east_west_passage
                        case 21
                                dest = round_room
                        case 22
                                dest = narrow_passage
                        case 23
                                dest = mirror_south
                        case 24
                                dest = winding_passage
                        case 25
                                dest = cave
                        case 26
                                dest = engravings_cave
                        case 27
                                dest = damp_cave
                        case 28
                                dest = north_south_passage
                        case 29
                                dest = chasm
                        case 30
                                dest = deep_canyon
                        case 31
                                dest = reservoir_south
                        case 32
                                dest = stream_view
                        case 33
                                dest = reservoir_north
                        case 34
                                dest = atlantis_room
                        case 35
                                dest = cave2
                        case 36
                                dest = twisting_passage
                        case 37
                                dest = mirror_north
                        case 38
                                dest = cold_passage
                        case 39
                                dest = slide_room
                        case 40
                                dest = mine_entrance
                        case 41
                                dest = squeaky_room
                        case 42
                                dest = coal_mine1
                        case 43
                                dest = coal_mine2
                        case 44
                                dest = coal_mine3
                        case 45
                                dest = coal_mine4
                }
                while old_thief_location = dest

                move self to dest
                old_thief_location = dest
        }

        if self not in location
        {
                for i in old_thief_location
                {
                        if i is moved
                        {
                                c++
                        }
                }
                if c > 0
                {
                        while c > 0
                        {
                                for i in old_thief_location
                                {
                                    if i is moved
                                    {
                                        j = i
                                    }
                                }
                                move j to thiefs_bag
                                c--
                        }
                }
        }

        elseif self in location and
           self is not hostile
        {
                ! Several options: take everything from the room, or from
                ! the player, both, take a light source, or take nothing.
                ! First, determine is the player and/or the room have 
                ! anything in them

                for i in location
                {
                        if i is valuable and
                           i not in player
                        {
                                b++
                        }
                }

                for i in player
                {
                        if i is valuable
                        {
                                c++
                        }
                }

                for i in player
                {
                        if i is light
                        {
                                d++
                        }
                }

                ! Now choose the thief's action

                a = random(5)
                select a
                case 1
                {
                        Jump RobRoom
                }
                case 2
                {
                        Jump RobPlayer
                }
                case 3
                {
                        Jump RobBoth
                }
                case 4
                {
                        Jump RobLight
                }
                case 5
                {
                        Jump RobNothing
                }

:RobRoom
                if b > 0 and ! Valuable item(s) in room (only)
                   c = 0
                {
                        while b > 0
                        {
                                for i in location
                                {
                                    if i is not living and
                                       i is valuable
                                    {
                                        j = i
                                    }
                                }
                                move j to thiefs_bag
                                b--
                        }
                        "The thief just left, still carrying his large
                        bag. You may not have noticed that he
                        appropriated the valuables in the room."
                        Jump ThiefEnd
                }
                else
                {
                        Jump RobNothing
                }
:RobPlayer
                if c > 0 and ! Valuable item(s) in player (only)
                   b = 0
                {
                        while c > 0
                        {
                                for i in player
                                {
                                    if i is valuable
                                    {
                                        j = i
                                    }
                                }
                                move j to thiefs_bag
                                c--
                        }
                        "The thief just left, still carrying his large
                        bag. You may not have noticed that he robbed you
                        blind first."
                        Jump ThiefEnd
                }
                else
                {
                        Jump RobNothing
                }
:RobBoth
                if c > 0 and ! Valuable item(s) in player and location
                   b > 0
                {
                        c += b
                        while c > 0
                        {
                                for i in player
                                {
                                        if i is valuable
                                        {
                                                j = i
                                        }
                                }
                                for i in location
                                {
                                        if i is not living and
                                           i is valuable
                                        {
                                                j = i
                                        }
                                }
                                move j to thiefs_bag
                                c--
                        }
                        "A seedy-looking individual with a large bag
                        just wandered through the room. On the way
                        through, he quietly abstracted some valuables
                        from the room and from your possession,
                        mumbling something about \"Doing unto others
                        before...\""
                        Jump ThiefEnd
                }
                else
                {
                        Jump RobNothing
                }
:RobLight
                if d > 0
                {
                        while d > 0
                        {
                                for i in player
                                {
                                        if i is light
                                        {
                                                j = i
                                                if j = lamp
                                                {
                                                        Deactivate(LampDaemon)
                                                        lamp is not switchedon
                                                        lamp is not light
                                                }
                                        }
                                }
                                move j to thiefs_bag
                                d--
                        } 
                        "The thief seems to have left you in the dark."
                        Jump ThiefEnd
                }
                else
                {
                        Jump RobNothing
                }
:RobNothing
                a = random(2)
                select a
                case 1
                {
                        "The thief, finding nothing of value, left disgusted."
                }
                case 2
                {
                        "Someone carrying a large bag is casually leaning
                        against one of the walls here. He does not speak,
                        but it is clear from his aspect that the bag will
                        be taken only over his dead body."
                }

:ThiefEnd
                return true
        }
        else
        {
:ThiefAttacks
                if self is living and
                   self is hostile and
                   self in location and
                   self is not unconscious and
                   self is not stunned and
                   self is not disarmed
                {
                        CalculateRank
                        diff = 6 - rank
                        ResolveAttack(diff)

                        select combat_result
                        case 0
                        {
                                a = random(4)
                                select a
                                case 1
                                {
                                        "The thief stabs nonchalantly with
                                        his stiletto and misses."
                                }
                                case 2
                                {
                                        "You dodge as the thief comes in low."
                                }
                                case 3
                                {
                                        "You parry a lightning thrust, and
                                        the thief salutes you with a grim nod."
                                }
                                case 4
                                {
                                        "The thief tries to sneak past your
                                        guard, but you twist away."
                                }
                                return true
                        }
                        case 1
                        {
:Instead3
                                player is stunned
                                a = random(3)
                                select a
                                case 1
                                {
                                        "The butt of his stiletto cracks you
                                        on the skull, and you stagger back."
                                }
                                case 2
                                {
                                        "The thief rams the haft of his blade
                                        into your stomach, leaving you out of
                                        breath."
                                }
                                case 3
                                {
                                        "The thief attacks, and you fall back
                                        desperately."
                                }
                                return true
                        }
                        case 2
                        {
                                if xobject and
                                   xobject is weapon and
                                   xobject in player
                                {
                                        a = random(3)
                                        select a
                                        case 1
                                        {
                                                "A long, theatrical slash.
                                                You catch it on your ";
                                                print xobject.name;
                                                ", but the thief twists his
                                                knife, and the ";
                                                print xobject.name;
                                                " goes flying."
                                        }
                                        case 2
                                        {
                                                "The thief neatly flips your ";
                                                print xobject.name;
                                                " out of your hands, and it
                                                drops to the floor."
                                        }
                                        case 3
                                        {
                                                "You parry a low thrust, and
                                                your ";
                                                print xobject.name;
                                                " slips out of your hand."
                                        }
                                        move xobject to location
                                }
                                elseif object and
                                   object is weapon and
                                   object in player
                                {
                                        a = random(3)
                                        select a
                                        case 1
                                        {
                                                "A long, theatrical slash.
                                                You catch it on your ";
                                                print object.name;
                                                ", but the thief twists his
                                                knife, and the ";
                                                print object.name;
                                                " goes flying."
                                        }
                                        case 2
                                        {
                                                "The thief neatly flips your ";
                                                print object.name;
                                                " out of your hands, and it
                                                drops to the floor."
                                        }
                                        case 3
                                        {
                                                "You parry a low thrust, and
                                                your ";
                                                print object.name;
                                                " slips out of your hand."
                                        }
                                        move object to location
                                }
                                else
                                {
                                        Jump Instead3
                                }
                        }
                        case 3
                        {
                                a = random(2)
                                select a
                                case 1
                                {
                                        "Shifting in the midst of a thrust,
                                        the thief knocks you unconscious
                                        with the haft of his stiletto."
                                }
                                case 2
                                {
                                        "The thief knocks you out."
                                }

                                a = random(2)
                                select a
                                case 1
                                {
                                        "The thief, forgetting his
                                        essentially genteel upbringing, cuts
                                        your throat."
                                }
                                case 2
                                {
                                        "The thief, a pragmatist, dispatches
                                        you as a threat to his livelihood."
                                }
                                NotDeadYet
                        }
                        case 4
                        {
                                current_hit_points--
                                turns_to_heal += 30
                                if current_hit_points <= 0
                                {
                                        Jump PlayerDead3
                                }
                                else
                                {
                                        a = random(4)
                                        select a
                                        case 1
                                        {
                                                "A quick thrust pinks your
                                                left arm, and blood starts
                                                to trickle down."
                                        }
                                        case 2
                                        {
                                                "The thief draws blood,
                                                raking his stiletto across
                                                your arm."
                                        }
                                        case 3
                                        {
                                                "The stiletto flashes faster
                                                than you can follow, and
                                                blood wells from your leg."
                                        }
                                        case 4
                                        {
                                                "The thief slowly approaches,
                                                strikes like a snake, and
                                                leaves you wounded."
                                        }
                                        return true
                                }
                        }
                        case 5
                        {
                                current_hit_points -= 2
                                turns_to_heal += 60
                                if current_hit_points <= 0
                                {
                                        Jump PlayerDead3
                                }
                                else
                                {
                                        a = random(4)
                                        select a
                                        case 1
                                        {
                                                "The thief strikes like a snake!
                                                The resulting wound is serious."
                                        }
                                        case 2
                                        {
                                                "The thief stabs a deep cut
                                                in your upper arm."
                                        }
                                        case 3
                                        {
                                                "The stiletto touches your
                                                forehead, and the blood
                                                obscures your vision."
                                        }
                                        case 4
                                        {
                                                "The thief strikes at your
                                                wrist, and suddenly your grip
                                                is slippery with blood."
                                        }
                                        return true
                                }
                        }
                        case 6
                        {
:PlayerDead3
                                a = random(3)

                                select a
                                case 1
                                {
                                        "Finishing you off, the thief inserts
                                        his blade into your heart."
                                }
                                case 2
                                {
                                        "The thief comes in from the side,
                                        feints, and inserts the blade into
                                        your ribs."
                                }
                                case 3
                                {
                                        "The thief bows formally, raises
                                        his stiletto, and with a wry grin,
                                        ends the battle and your life."
                                }
                                NotDeadYet
                        }
                }
                elseif self is living and
                       self is stunned
                {
                        self is not stunned

                        "The thief, a man of superior breeding, pauses for a
                        moment to consider the propriety of finishing you off."

                        return true
                }
                elseif self is living and
                       self is not unconscious and
                       self is disarmed
                {
                        if FindObject(stiletto, location) and
                           random(10) < 6
                        {
                                "The robber, somewhat surprised at this turn
                                of events, nimbly retrieves his stiletto."
                                move stiletto to self
                                stiletto is hidden
                                self is not disarmed
                                return true
                        }
                        else
                        {
                                "Your opponent, determining discretion to be
                                the better part of valor, decides to
                                terminate this little contretemps. With a
                                rueful nod of his head, he steps backward
                                into the gloom and disappears."

                                RemoveThief(0)

                        }
                }
        }
        return true
}

!----------------------------------------------------------------------------
!
!       EVENTS
!
!----------------------------------------------------------------------------

event troll
{
        local a, b

        self = troll

        ! 10% chance to spontaneously attack.

        if self is not hostile and
           random(10) = 1
        {
                self is hostile
        }

        if self is hostile and
           self is living and
           self is not unconscious and
           self is not stunned and
           self is not disarmed
        {
                ResolveAttack(-1)

                combat_result--
                if combat_result < 0
                {
                        combat_result = 0
                }

                select combat_result
                case 0
                {
                        a = random(4)
                        select a
                        case 1
                        {
                                "The troll swings his axe, but it misses."
                        }
                        case 2
                        {
                                "The troll's axe barely misses your ear."
                        }
                        case 3
                        {
                                "The axe sweeps past as you jump aside."
                        }
                        case 4
                        {
                                "The axe crashes against the rock, throwing sparks!"
                        }
                        return true
                }
                case 1
                {
:Instead1
                        player is stunned
                        a = random(4)
                        select a
                        case 1
                        {
                                "The troll hits you with a glancing blow,
                                and you are momentarily stunned."
                        }
                        case 2
                        {
                                "The troll swings; the blade turns on your
                                armor but crashes broadside into your head."
                        }
                        case 3
                        {
                                "You stagger back under a hail of axe
                                strokes."
                        }
                        case 4
                        {
                                "The troll's mighty blow drops you to your
                                knees."
                        }
                        return true
                }
                case 2
                {
                        if xobject and
                           xobject is weapon and
                           xobject in player
                        {
                                a = random(3)
                                select a
                                case 1
                                {
                                        "The axe hits your ";
                                        print xobject.name;
                                        " and knocks it spinning."
                                }
                                case 2
                                {
                                        "The troll swings, you parry, but
                                        the force of his blow knocks your ";
                                        print xobject.name;
                                        " away."
                                }
                                case 3
                                {
                                        "The axe knocks your ";
                                        print xobject.name;
                                        " out of your hand. It falls to the
                                        floor."
                                }
                                move xobject to location
                        }
                        elseif object and
                           object is weapon and
                           object in player
                        {
                                a = random(3)
                                select a
                                case 1
                                {
                                        "The axe hits your ";
                                        print xobject.name;
                                        " and knocks it spinning."
                                }
                                case 2
                                {
                                        "The troll swings, you parry, but
                                        the force of his blow knocks your ";
                                        print xobject.name;
                                        " away."
                                }
                                case 3
                                {
                                        "The axe knocks your ";
                                        print xobject.name;
                                        " out of your hand. It falls to the
                                        floor."
                                }
                                move object to location
                        }
                        else
                        {
                                Jump Instead1
                        }
                }
                case 3
                {
                        "The flat of the troll's axe hits you delicately on
                        the head, knocking you out."
                        "Conquering his fears, the troll puts you to death."

                        NotDeadYet
                }
                case 4
                {
                        current_hit_points--
                        turns_to_heal += 30
                        if current_hit_points <= 0
                        {
                                Jump PlayerDead1
                        }
                        else
                        {
                                a = random(5)
                                select a
                                case 1
                                {
                                        "The axe gets you right in the side.
                                        Ouch!"
                                }
                                case 2
                                {
                                        "The flat of the troll's axe skins
                                        across your forearm."
                                }
                                case 3
                                {
                                        "The troll's swing almost knocks you
                                        over as you barely parry in time."
                                }
                                case 4
                                {
                                        "The troll swings his axe, and it
                                        nicks your arm as you dodge."
                                }
                                case 5
                                {
                                        "The troll charges, and his axe
                                        slashes you on your ";
                                        b = random(2)
                                        select b
                                        case 1
                                        {
                                                "left";
                                        }
                                        case 2
                                        {
                                                "right";
                                        }
                                        " arm."
                                }
                                return true
                        }
                }
                case 5
                {
                        current_hit_points -= 2
                        turns_to_heal += 60
                        if current_hit_points <= 0
                        {
                                Jump PlayerDead1
                        }
                        else
                        {
                                a = random(2)
                                select a
                                case 1
                                {
                                        "An axe stroke makes a deep wound in
                                        your leg."
                                }
                                case 2
                                {
                                        "The troll's axe swings down, gashing
                                        your shoulder."
                                }
                                return true
                        }
                }
                case 6
                {
:PlayerDead1
                        a = random(3)

                        select a
                        case 1
                        {
                                "The troll neatly removes your head."
                        }
                        case 2
                        {
                                "The troll's axe stroke cleaves you
                                from the nave to the chops."
                        }
                        case 3
                        {
                                "The troll's axe removes your head."
                        }
                        NotDeadYet
                }
        }
        elseif self is living and
           self is stunned
        {
                self is not stunned
                if axe is hidden ! hidden = troll is carrying the axe
                {
                        "The troll hesitates, fingering his axe."
                }
                else
                {
                        "The troll scratches his head ruminatively:
                        Might you be magically protected, he
                        wonders?"
                }
                return true
        }
        elseif self is living and
           self is not unconscious and
           self is disarmed
        {
                if FindObject(axe, location) and
                   random(10) < 6
                {
                        "The troll, angered and humiliated, recovers his
                        weapon. He appears to have an axe to grind with you."
                        move axe to self
                        axe is hidden
                        self is not disarmed
                        return true
                }
                else
                {
                        "The troll, disarmed, cowers in terror, pleading for
                        his life in the guttural tongue of the trolls."
                        return true
                }
        }
}

event cyclops
{
        local a, diff

        self = cyclops

        if self is hostile and
           self is living and
           self is not unconscious and
           self is not stunned
        {
                CalculateRank

                diff = 6 - rank
                ResolveAttack(diff)

                select combat_result
                case 0
                {
                        a = random(2)
                        select a
                        case 1
                        {
                                "The Cyclops misses, but the backwash almost
                                knocks you over."
                        }
                        case 2
                        {
                                "The Cyclops rushes you, but runs into the
                                wall."
                        }
                        return true
                }
                case 1
                {
:Instead2
                        "The Cyclops lands a punch that knocks the wind out
                        of you."
                        player is stunned
                        return true
                }
                case 2
                {
                        if xobject and
                           xobject is weapon and
                           xobject in player
                        {
                                a = random(2)
                                select a
                                case 1
                                {
                                        "The Cyclops grabs your ";
                                        print xobject.name;
                                        ", tastes it, and throws it to the
                                        ground in disgust."
                                }
                                case 2
                                {
                                        "The monster grabs you on the wrist,
                                        squeezes, and you drop your ";
                                        print xobject.name;
                                        " in pain."
                                }
                                move xobject to location
                        }
                        elseif object and
                           object is weapon and
                           object in player
                        {
                                a = random(2)
                                select a
                                case 1
                                {
                                        "The Cyclops grabs your ";
                                        print object.name;
                                        ", tastes it, and throws it to the
                                        ground in disgust."
                                }
                                case 2
                                {
                                        "The monster grabs you on the wrist,
                                        squeezes, and you drop your ";
                                        print object.name;
                                        " in pain."
                                }
                                move object to location
                        }
                        else
                        {
                                Jump Instead2
                        }
                }
                case 3
                {
                        "The Cyclops sends you crashing to the floor,
                        unconscious."
                        "The Cyclops, no sportsman, dispatches his
                        unconscious victim."

                        NotDeadYet
                }
                case 4
                {
                        current_hit_points--
                        turns_to_heal += 30
                        if current_hit_points <= 0
                        {
                                Jump PlayerDead2
                        }
                        else
                        {
                                a = random(2)
                                select a
                                case 1
                                {
                                        "A quick punch, but it was only a
                                        glancing blow."
                                }
                                case 2
                                {
                                        "A glancing blow from the Cyclops'
                                        fist."
                                }
                                return true
                        }
                }
                case 5
                {
                        current_hit_points -= 2
                        turns_to_heal += 60
                        if current_hit_points <= 0
                        {
                                Jump PlayerDead2
                        }
                        else
                        {
                                a = random(2)
                                select a
                                case 1
                                {
                                        "The monster smashes his huge fist
                                        into your chest, breaking several
                                        ribs."
                                }
                                case 2
                                {
                                        "Heedless of your weapons, the
                                        Cyclops tosses you against the rock
                                        wall of the room."
                                }
                                return true
                        }
                }
                case 6
                {
:PlayerDead2
                        "The Cyclops breaks your neck with a massive smash."

                        NotDeadYet
                }
        }
        elseif self is living and
           self is stunned
        {
                self is not stunned
                "The Cyclops seems unable to decide whether to broil
                or stew his dinner."
                return true
        }
}

!----------------------------------------------------------------------------
!
! Scenery Items - These items are always in the player's location
!
!----------------------------------------------------------------------------

scenery grue "lurking grue"
{
        noun "grue"
        adjective "lurking"
        article "a"
        found_in {return location}
        long_desc
        {
                "The grue is a sinister, lurking presence in the dark places
                of the earth. Its favorite diet is adventurers, but its
                insatiable appetite is tempered by its fear of light. No grue
                has ever been seen by the light of day, and few have survived
                its fearsome jaws to tell the tale."
        }
        before
        {
                object DoFind
                {
                        "There is no grue here, but I'm sure there is at
                        least one lurking in the darkness nearby. I wouldn't
                        let my light go out if I were you!"
                }
                object DoListen
                {
                        "It makes no sound but is always lurking in the
                        darkness nearby."
                }
        }
}

scenery zorkmid "zorkmid"
{
        noun "zorkmid"
        article "a"
        found_in {return location}
        long_desc
        {
                "The zorkmid is the unit of currency of the Great Underground
                Empire."
        }
        before
        {
                object DoFind
                {
                        "The best way to find zorkmids is to go out and
                        look for them."
                }
        }
}

scenery teeth "set of teeth"
{
        noun "teeth"
        adjective "set"
        article "a"
        found_in {return location}
        before
        {
                object DoFind
                {
                        "You find it."
                }
        }
}

scenery hands "pair of hands"
{
        noun "hands"
        adjectives "pair" "bare"
        article "the"
        found_in {return location}
        before
        {
                object DoFind
                {
                        "Within six feet of your head, assuming you haven't
                        left that somewhere."
                }
        }
}

scenery sailor "sailor"
{
        noun "sailor"
        article "the"
        found_in {return location}
}

scenery blessings "blessings"
{
        noun "blessings"
        article "my"
        found_in {return location}
        before
        {
                object DoCount
                {
                        "Well, for one, you are playing Hugo Zork..."
                }
        }
}

scenery way "way"
{
        nouns "way" "path"
        article "the"
        found_in {return location}
}

scenery ground "ground"
{
        nouns "ground" "dirt" "sand"
        article "the"
        found_in {return location}
        before
        {
                object DoDig
                {
                        if xobject = shovel or
                           xobject = hands
                        {
                                "The ground is too hard for digging here."
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

scenery surrounding_wall "surrounding wall"
{
        noun "wall"
        adjective "surrounding"
        article "the"
        found_in {return location}
}

scenery air "blast of air"
{
        noun "air"
        adjective "blast"
        article "a"
        found_in {return location}
}

!----------------------------------------------------------------------------
!    CHARACTERS
!----------------------------------------------------------------------------

creature troll "troll"
{
        noun "troll"
        adjective "nasty"
        article "a"
        in troll_room
        room_points 5 ! OK, so he's not a room...
        hit_points 2
        short_desc
        {
                if self is not unconscious and
                   self is not disarmed
                {
                        "A nasty-looking troll, brandishing a bloody axe,
                        blocks all passages out of the room."
                }
                elseif self is unconscious
                {
                        "An unconscious troll is sprawled on the floor. All
                        passages out of the room are open."
                }
                else
                {
                        "A pathetically babbling troll is here."
                }
        }
        long_desc
        {
                if self is not unconscious and
                   self is not disarmed
                {
                        "A nasty-looking troll, brandishing a bloody axe,
                        blocks all passages out of the room."
                }
                elseif self is unconscious
                {
                        "An unconscious troll is sprawled on the floor. All
                        passages out of the room are open."
                }
                else
                {
                        "A pathetically babbling troll is here."
                }
        }
        knocked_out
        {
                self is unconscious
                if troll is not room_scored
                {
                        score += troll.room_points
                        troll is room_scored
                }
                troll_room.threat_level = 0
                cellar.threat_level = 0
                move axe to location
                axe is not hidden
                self is disarmed
                KnockOutMessage(troll)
        }
        no_weapon
        {
                self is disarmed
                move axe to location
                axe is not hidden
                DisarmedMessage(troll)
        }
        take_damage
        {
                self.hit_points -= damage

                if self is unconscious or
                   self is disarmed
                {
                        Jump TrollDead
                }
                elseif self.hit_points <= 0
                {
                        DeadMessage(troll)

:TrollDead
                        "Almost as soon as ";
                        print The(self);
                        " breathes his last breath, a cloud
                        of sinister black fog envelops him,
                        and when the fog lifts, the carcass
                        has disappeared."

                        remove self
                        self is not living
                        if self is not room_scored
                        {
                                score += self.room_points
                                self is room_scored
                        }
                        troll_room.threat_level = 0
                        cellar.threat_level = 0
                        axe is not hidden
                        move axe to location
                }
                else
                {
                        MinorWoundMessage(troll)
                }
        }
        before
        {
                object DoWakeCharacter
                {
                        if self is not unconscious
                        {
                                Already_done
                        }
                        else
                        {
                                self is not unconscious
                                troll_room.threat_level = 2
                                cellar.threat_level = 1
                                if FindObject(axe, location)
                                {
                                        move axe to self
                                        axe is hidden
                                        self is not disarmed
                                        "The troll stirs, quickly resuming a
                                        fighting stance."
                                        return true
                                }
                                else
                                {
                                        "The troll, disarmed, cowers in
                                        terror, pleading for his life in the
                                        guttural tongue of the trolls."
                                        return true
                                }
                        }
                }
                object DoListen
                {
                        if self is not unconscious and
                           self is not disarmed
                        {
                                "Every so often the troll says something,
                                probably uncomplimentary, in his guttural
                                tongue."
                                return true
                        }
                        elseif self is not unconscious and
                           self is disarmed
                        {
                                "The troll, disarmed, cowers in
                                terror, pleading for his life in the
                                guttural tongue of the trolls."
                                return true
                        }
                        else
                        {
                                return false
                        }
                }
                object DoAsk, DoTell, DoAskQuestion, DoTalk, DoHello
                {
                        if self is not unconscious
                        {
                                "The troll isn't much of a
                                conversationalist."
                                return true
                        }
                        else
                        {
                                "Unfortunately, the troll can't hear you."
                        }
                }
                object DoGet
                {
                        if self is not unconscious
                        {
                                "The troll spits in your face, saying
                                \"Better luck next time\"."
                        }
                        else
                        {
                                return false
                        }
                }
                xobject DoGive, DoThrowAt
                {
                        if object = axe
                        {
                                "The troll scratches his head in confusion,
                                then takes the axe."
                                axe is hidden
                                self is not disarmed
                                return true
                        }

                        if verbroutine = &DoGive
                        {
                                "The troll, who is not overly proud,
                                graciously accepts the gift";
                        }
                        else
                        {
                                "The troll, who is remarkably coordinated,
                                catches ";
                                print The(object);
                        }

                        if object = sword
                        {
                                " and eats it hungrily. Poor troll, he dies
                                from an internal hemorrhage and his carcass
                                disappears in a sinister black fog."
                                remove troll
                                troll is not living
                                axe is not hidden
                                remove sword
                                if self is not room_scored
                                {
                                        score += self.room_points
                                        self is room_scored
                                }
                                troll_room.threat_level = 0
                                cellar.threat_level = 0
                        }
                        elseif object = nasty_knife
                        {
                                " and, being for the moment sated, throws it
                                back. Fortunately, the troll has poor control,
                                and the knife falls to the floor. He does
                                not look pleased."
                                self is hostile
                                move nasty_knife to location
                        }
                        else
                        {
                                " and not having the most discriminating
                                tastes, gleefully eats it."
                                remove object
                                FindLight(location) ! Just in case the player
                                                    ! fed him the lamp
                        }
                }
        }
}

object axe "bloody axe"
{
        noun "axe"
        adjective "bloody"
        article "a"
        in troll
        is hidden, weapon, sharp
        before
        {
                object DoGet
                {
                        if self in troll
                        {
                                "The troll swings it out of your reach."
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

creature cyclops "cyclops"
{
        noun "cyclops"
        adjective "hungry"
        article "a"
        in cyclops_room
        hit_points 4
        initial_desc
        {
                if self is not unconscious
                {
                        "A cyclops, who looks prepared to eat horses (much
                        less mere adventurers), blocks the staircase. From
                        his state of health, and the bloodstains on the
                        walls, you gather that he is not very friendly,
                        though he likes people."
                }
                else
                {
                        "The cyclops is sleeping like a baby, albeit a very
                        ugly one."
                }
        }
        long_desc
        {
                "A hungry cyclops is standing at the foot of the stairs."
        }
        knocked_out
        {
                self is unconscious
                cyclops_room.threat_level = 0
                maze15.threat_level = 0
                KnockOutMessage(cyclops)
        }
        no_weapon
        {
                DazeMessage(cyclops) ! The cyclops doesn't need a weapon
        }
        take_damage
        {
                self.hit_points -= damage

                if self is unconscious
                {
                        Jump CyclopsDead
                }
                elseif self.hit_points <= 0
                {
                        DeadMessage(cyclops)

:CyclopsDead
                        "Almost as soon as ";
                        print The(self);
                        " breathes his last breath, a cloud
                        of sinister black fog envelops him,
                        and when the fog lifts, the carcass
                        has disappeared."

                        remove self
                        self is not living
                        cyclops_room.threat_level = 0
                        maze15.threat_level = 0
                }
                elseif damage = 1
                {
                        MinorWoundMessage(cyclops)
                }
                else
                {
                        SeriousWoundMessage(cyclops)
                }
        }
        before
        {
                xobject DoGive
                {
                        if self is unconscious
                        {
                                "The cyclops is sleeping like a baby, albeit
                                a very ugly one."
                        }
                        elseif object = lunch
                        {
                                "The cyclops says \"Mmm Mmm. I love hot
                                peppers! But oh, could I use a drink. Perhaps
                                I could drink the blood of that thing.\"
                                From the gleam in his eye, it could be
                                surmised that you are \"that thing\"."
                        }
                        elseif object = water or object = bottle
                        {
                                if bottle is open
                                {
                                        "The cyclops takes the bottle, checks
                                        that it's open, and drinks the water.
                                        A moment later, he lets out a yawn
                                        that nearly blows you over, and then
                                        falls fast asleep (what did you put
                                        in that drink, anyway?)."
                                        self is unconscious
                                }
                                else
                                {
                                        "The cyclops apparently is not
                                        thirsty and refuses your generous
                                        offer."
                                }
                        }
                        elseif object is sharp or
                           object is weapon
                        {
                                "The cyclops is not so stupid as to eat
                                THAT!"
                        }
                        else
                        {
                                "The cyclops may be hungry, but there is a
                                limit."
                        }
                }
                xobject DoThrowAt
                {
                        if self is not unconscious
                        {
                                "\"Do you think I'm as stupid as my father
                                was?\", he says, dodging."
                        }
                        else
                        {
                                return false
                        }
                }
                xobject DoTie
                {
                        "You cannot tie the cyclops, though he is fit to be
                        tied."
                }
                object DoListen
                {
                        "You can hear his stomach rumbling."
                }
                object DoAsk, DoTell, DoAskQuestion, DoTalk, DoHello
                {
                        if self is not unconscious
                        {
                                "The cyclops prefers eating to making
                                conversation."
                        }
                        else
                        {
                                "No use talking to him. He's fast asleep."
                        }
                }
                object DoWake
                {
                        if self is unconscious
                        {
                                "The cyclops yawns and stares at the thing
                                that woke him up."
                                self is not unconscious
                                cyclops_room.threat_level = 2
                                maze15.threat_level = 1
                        }
                        else
                        {
                                return false
                        }
                }
                object DoGet
                {
                        if self is not unconscious
                        {
                                "The cyclops shrugs but otherwise ignores
                                your pitiful attempt."
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

creature thief "thief"
{
        nouns "thief" "robber" "man" "character" "eyes"
        adjectives "slippery"
        article "the"
        in nothing
        hit_points 4
        long_desc
        {
                "The thief is a slippery character with beady eyes that
                flit back and forth. He carries, along with an unmistakable
                arrogance, a large bag over his shoulder and a vicious
                stiletto, whose blade is aimed menacingly in your direction.
                I'd watch out if I were you."
        }
        knocked_out
        {
                self is unconscious
                treasure_room.threat_level = 0
                move stiletto to location
                stiletto is not hidden
                self is disarmed
                KnockOutMessage(thief)
        }
        no_weapon
        {
                self is disarmed
                move stiletto to location
                stiletto is not hidden
                DisarmedMessage(thief)
        }
        take_damage
        {
                self.hit_points -= damage

                if self is unconscious or
                   self is disarmed
                {
                        Jump ThiefDead
                }
                elseif self.hit_points <= 0
                {
                        DeadMessage(thief)

:ThiefDead
                        "Almost as soon as ";
                        print The(self);
                        " breathes his last breath, a cloud
                        of sinister black fog envelops him,
                        and when the fog lifts, the carcass
                        has disappeared."

                        RemoveThief(1)
                }
                elseif damage = 1
                {
                        MinorWoundMessage(thief)
                }
                else
                {
                        SeriousWoundMessage(thief)
                }
        }
        before
        {
                object DoGet
                {
                        "Once you got him, what would you do with him?"
                }
                object DoListen
                {
                        "The thief is a strong, silent type."
                }
                object DoAsk, DoTell, DoAskQuestion, DoTalk, DoHello
                {
                        if self is not unconscious
                        {
                                "The thief says nothing, as you have not
                                been formally introduced."
                        }
                        else
                        {
                                "The thief, being temporarily incapacitated,
                                is unable to acknowledge your greeting with
                                his usual graciousness."
                        }
                }
                object DoWake
                {
                        if self is unconscious
                        {
                                "Your proposed victim suddenly recovers
                                consciousness."
                        }
                        else
                        {
                                return false
                        }
                }
                xobject DoThrowAt
                {
                        if self is unconscious
                        {
                                return false
                        }
                        elseif object = nasty_knife
                        {
                                "You missed. The thief makes no attempt to
                                take the knife, though it would be a fine
                                addition to the collection in his bag. He
                                does seem angered by your attempt."
                                move nasty_knife to location
                                thief is hostile
                        }
                        else
                        {
                                "You missed."
                                thief is hostile
                        }
                }
                xobject DoGive
                {
                        if self is unconscious
                        {
                                return false
                        }
                        elseif object is valuable
                        {
                                "The thief is taken aback by your unexpected
                                generosity, but accepts ";
                                print The(object);
                                " and stops to admire its beauty."
                                thief is not hostile
                                move object to thiefs_bag
                        }
                        else
                        {
                                "The thief places ";
                                print The(object);
                                " in his bag and thanks you politely."
                                thief is not hostile
                                move object to thiefs_bag
                        }
                }
        }
}

object stiletto "stiletto"
{
        noun "stiletto"
        adjectives "sharp" "viscious"
        article "a"
        is weapon, sharp, hidden
        in thief
        size 10
}

object thiefs_bag "thief's bag"
{
        nouns "bag" "sack"
        adjective "large"
        article "the"
        is container, hidden
        capacity 500
        in thief
        before
        {
                object DoGet
                {
                        if thief is unconscious
                        {
                                "Sadly for you, the robber collapsed on top
                                of the bag. Trying to take it would wake
                                him."
                        }
                        else
                        {
                                "The bag will be taken over his dead body."
                        }
                }
                object DoLookIn
                {
                        if thief is unconscious
                        {
                                "The bag is underneath the thief, so one
                                can't say what, if anything, is inside."
                        }
                        else
                        {
                                "Getting close enough would be a good trick."
                        }
                }
        }
}

object canvas "useless piece of canvas"
{
        noun "canvas"
        adjective "useless" "piece"
        article "a"
        in nothing
}

!----------------------------------------------------------------------------
!    ABOVE GROUND AREAS
!----------------------------------------------------------------------------

LightRoom west_of_house "West of House"
{
	long_desc
        {
                "You are standing in an open field west of a white
                house, with a boarded front door.";
                if ancient_map in nothing
                {
                        ""
                }
                else
                {
                        " A secret path leads southwest into the forest."
                }
        }
        is thief_free
        sw_to
        {
                if ancient_map in nothing
                {
                        return false
                }
                else
                {
                        return stone_barrow
                }
        }
        n_to north_of_house
        s_to south_of_house
        w_to forest1
        e_to
        {
                "The door is boarded and you can't remove the boards."
        }
}

scenery house "house"
{
        nouns "house" "home"
        adjectives "colonial" "beautiful" "white"
	article "the"
	long_desc
        {
                "The house is a beautiful colonial house which is
                painted white. It is clear that the owners must have
                been extremely wealthy."
        }
        found_in west_of_house, north_of_house, behind_house, south_of_house
        before
        {
                object DoFind
                {
                        "It's right here! Are you blind or something?"
                }
                object DoEnter
                {
                        if location = behind_house and
                           kitchen_window is not open
                        {
                                "The window is closed."
                        }
                        elseif location = behind_house and
                           kitchen_window is open
                        {
                                MovePlayer(kitchen)
                        }
                        else
                        {
                                "I can't see how to get in from here."
                        }
                }
        }
}

scenery boards "boards"
{
        nouns "board" "boards"
        adjectives "wood" "wooden" "white"
        article "the"
        in house
        before
        {
                object DoGet, DoLook
                {
                        "The boards are securely fastened."
                }
        }
}

scenery house1 "house"
{
        nouns "house" "home"
        adjectives "colonial" "beautiful" "white"
	article "the"
	long_desc
        {
                "You're not at the house."
        }
        found_in forest1, forest2, forest3, forest4, forest_path, up_a_tree \
                 clearing, clearing1
        before
        {
                object DoFind
                {
                        if location = clearing
                        {
                                "It seems to be to the west."
                        }
                        else
                        {
                                "It was here just a minute ago...."
                        }
                }
                object DoEnter
                {
                        "You're not at the house."
                }
        }
}

object mailbox "small mailbox"
{
        in west_of_house
        nouns "mailbox" "box"
        adjective "small"
        article "a"
        is static, container, openable, not open
        capacity 5
        long_desc
        {
                "The small mailbox is ";
                if self is not open
                        "closed."
                else
                {
                         "open."
                          WhatsIn(object)
                 }
         }
         after
         {
                object DoOpen
                {
                          WhatsIn(object)
                }
         }
}

object leaflet "leaflet"
{
        in mailbox
        noun "leaflet"
        article "a"
        is burnable
        long_desc
        {
                "\"WELCOME TO HUGO ZORK!\n\n

                HUGO ZORK is a game of adventure, danger, and low cunning.
                In it you will explore some of the most amazing territory
                ever seen by mortals. No computer should be without one!\""
        }
        is readable
}

LightRoom stone_barrow "Stone Barrow"
{
        long_desc
        {
                "You are standing in front of a massive barrow of stone.
                In the east face is a huge stone door which is open. You
                cannot see into the dark of the tomb."
        }
        is thief_free
        w_to inside_the_barrow
        ne_to west_of_house
}

LightRoom inside_the_barrow "Inside The Barrow"
{
        long_desc
        {
                "As you enter the barrow, the door closes inexorably
                behind you. Around you it is dark, but ahead is an
                enormous cavern, brightly lit. Through its center runs
                a wide stream. Spanning the stream is a small wooden
                footbridge, and beyond a path leads into a dark tunnel.
                Above the bridge, floating in the air, is a large sign.
                It reads:  All ye who stand before this bridge have
                completed a great and perilous adventure which has tested
                your wit and courage. You have mastered the first part of
                the (Hugo) ZORK trilogy. Those who pass over this bridge must
                be prepared to undertake an even greater adventure that will
                severely test your skill and bravery!"

                "\nThe ZORK trilogy continues with \"ZORK II: The Wizard of
                Frobozz\" and is completed in \"ZORK III: The Dungeon
                Master.\""

                "\nAuthor's note: I'm not making any promises, but maybe
                someday I'll port Zork II and Zork III over to Hugo."

                endflag = 3
        }
        is thief_free
}


LightRoom north_of_house "North of House"
{
	long_desc
        {
                "You are facing the north side of a white house. There is
                no door here, and all the windows are boarded up. To the
                north a narrow path winds through the trees."
        }
        is thief_free
        n_to forest_path
        s_to
        {
                "The windows are all boarded."
        }
        w_to west_of_house
        e_to behind_house
}

LightRoom south_of_house "South of House"
{
	long_desc
        {
                "You are facing the south side of a white house. There is
                no door here and all the windows are boarded."
        }
        is thief_free
        n_to
        {
                "The windows are all boarded."
        }
        w_to west_of_house
        e_to behind_house
        s_to forest3
}        

LightRoom behind_house "Behind House"
{
	long_desc
        {
                "You are behind the white house. A path leads into the
                forest to the east. In one corner of the house is a small
                window which is ";
                if kitchen_window is open
                        "open."
                else
                        "slightly ajar."
        }
        is thief_free
        n_to north_of_house
        s_to south_of_house
        e_to clearing
        w_to
        {
                if kitchen_window is not open
                {
                        print CThe(kitchen_window); " is closed."
                }
                else
                {
                        return kitchen_window.door_to
                }
        }
        in_to
        {
                if kitchen_window is not open
                {
                        print CThe(kitchen_window); " is closed."
                }
                else
                {
                        return kitchen_window.door_to
                }
        }
}

door kitchen_window "window"
{
        noun "window"
        adjective "small"
	article "the"
        between kitchen, behind_house
        is static, transparent, not open
        long_desc
        {
                "The window is ";
                if self is not open
                {
                        "slightly ajar, but not enough to allow entry."
                }
                else
                {
                         "open, but I can't tell what's beyond it."
                }
         }
         before
         {
                object DoOpen
                {
                        if self is open
                        {
                                Already_done
                        }
                        else
                        {
                                return false
                        }
                }
                object DoClose
                {
                        if self is not open
                        {
                                Already_done
                        }
                        else
                        {
                                return false
                        }
                }
                object DoLookThrough
                {
                        if location = behind_house
                        {
                                "You can see what appears to be a kitchen."
                        }
                        else
                        {
                                "You can see a clear area leading towards
                                a forest."
                        }
                }
         }
         after
         {
                object DoOpen
                {
                        "With great effort, you open the window far
                        enough to allow entry."
                }
                object DoClose
                {
                        "The window closes (more easily than it opened)."
                }
         }
}

LightRoom clearing "Clearing"
{
        long_desc
        {
                "You are in a small clearing in a well marked forest path
                that extends to the east and west."
         }
        is thief_free
         w_to behind_house
         e_to canyon_view
         n_to forest2
         s_to forest3
}

LightRoom canyon_view "Canyon View"
{
        long_desc
        {
                "You are at the top of the Great Canyon on its west 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 join the mighty ramparts of the Flathead
                Mountains to the east. Following the Canyon upstream to the
                north, Aragain Falls may be seen, complete with rainbow. The
                mighty Frigid River flows out from a great dark cavern. To the
                west and south can be seen an immense forest, stretching for
                miles around. A path leads northwest. It is possible to climb down
                into the canyon from here."
        }
        is thief_free
        nw_to clearing
        d_to rocky_ledge
        before
        {
                location DoJump
                {
                        "Nice view, lousy place to jump."
                        NotDeadYet
                }
        }
}

LightRoom rocky_ledge "Rocky Ledge"
{
        long_desc
        {
                "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 for you
                to enter. Below you is the canyon bottom. Above you is more
                cliff, which appears climbable."
        }
        is thief_free
        u_to canyon_view
        d_to canyon_bottom
}

LightRoom canyon_bottom "Canyon Bottom"
{
        long_desc
        {
                "You are beneath the walls of the river canyon which may be
                climbable here. The lesser part of the runoff of Aragain
                Falls flows by below. To the north is a narrow path."
        }
        is thief_free
        u_to rocky_ledge
        n_to end_of_rainbow
}

LightRoom end_of_rainbow "End of Rainbow"
{
        long_desc
        {
                "You are on a small, rocky 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 east and a narrow path continues to the
                southwest."
        }
        is thief_free
        sw_to canyon_bottom
        e_to
        {
                if rainbow is special
                {
                        MovePlayer(on_the_rainbow)
                }
                else
                {
                        "You can't go that way."
                }
        }
        u_to
        {
                if rainbow is special
                {
                        MovePlayer(on_the_rainbow)
                }
                else
                {
                        "You can't go that way."
                }
        }
}

scenery rainbow "rainbow"
{
        noun "rainbow"
        adjective "dazzling"
        article "a"
        found_in end_of_rainbow, on_the_rainbow, aragain_falls
        before
        {
                object DoLookUnder
                {
                        "The Frigid River flows under the rainbow."
                }
                object DoWalkOn
                {
                        if rainbow is not special
                        {
                                "Can you walk on water vapor?"
                        }
                        elseif location = on_the_rainbow
                        {
                                "You'll have to say which way..."
                        }
                        elseif location = end_of_rainbow
                        {
                                MovePlayer(aragain_falls)
                        }
                        else
                        {
                                MovePlayer(end_of_rainbow)
                        }
                }
                object DoClimb
                {
                        if (location = end_of_rainbow or
                            location = aragain_falls)
                        {
                                if rainbow is special
                                {
                                        MovePlayer(on_the_rainbow)
                                }
                                else
                                {
                                        "You can't go that way."
                                }
                        }
                        else
                        {
                                "You can't do that."
                        }
                }
        }
}

treasure pot_of_gold "pot of gold"
{
        noun "gold"
        adjective "pot"
        article "a"
        take_points 10
        deposit_points 10
        in nothing
        initial_desc
        {
                "At the end of the rainbow is a pot of gold."
        }
}

LightRoom forest_path "Forest Path"
{
        long_desc
        {
                "This is a path winding through a dimly lit forest. The path
                heads north-south here. One particularly large tree with
                some low branches stands at the edge of the path."
        }
        is thief_free
        n_to clearing1
        s_to north_of_house
        e_to forest2
        w_to forest1
        u_to up_a_tree
}

scenery tree "tree"
{
        noun "tree"
        adjective "large"
        article "a"
        found_in forest_path, up_a_tree
        before
        {
                object DoClimb
                {
                        if location = forest_path
                        {
                                MovePlayer(up_a_tree)
                        }
                        else
                        {
                                "You cannot climb any higher."
                        }
                }
        }
}

LightRoom up_a_tree "Up a Tree"
{
        long_desc
        {
                "You are about 10 feet above the ground nestled among
                some large branches. The nearest branch above you is above
                your reach."
        }
        is thief_free
        d_to forest_path
        u_to {
                "You cannot climb any higher."
             }
        before
        {
                object DoClimb
                {
                        "You cannot climb any higher."
                }
        }
}

object birdnest "bird's nest"
{
        noun "nest"
        adjective "bird's"
        article "a"
        is burnable
        initial_desc
        {
                "Beside you on the branch is a small bird's nest."
        }
        contains_desc
        {
                "In the bird's nest is";
        }
        is container
        capacity 10
        in up_a_tree
        before
        {
                object DoGet
                {
                        if child(birdnest) = egg
                        {
                                egg is moved
                        }
                        return false
                }
                object DoDrop
                {
                        if location = up_a_tree and
                           child(birdnest) = egg and
                           egg is not open
                        {
                                "The nest falls to the ground, and the egg
                                spills out of it, seriously damaged."
                                DoBreakEgg
                                move birdnest to forest_path
                                move broken_canary to egg
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

treasure egg "jewel-encrusted egg"
{
        noun "egg"
        adjectives "jewel-encrusted", 0, 0
        article "a"
        take_points 5
        deposit_points 5
        capacity 5
        in birdnest
        is container, openable, not open, lockable, locked
        long_desc
        {
                if self is not broken
                {
                        "This is a large egg encrusted with precious jewels,
                        apparently scavenged by a childless songbird. The egg
                        is covered with fine gold inlay, and ornamented in
                        lapis lazuli and mother-of-pearl. Unlike most eggs,
                        this one is hinged and closed with a delicate looking
                        clasp. The egg appears extremely fragile."
                }
                else
                {
                        return false
                }
        }
        short_desc
        {
                if self is not broken
                {
                        "There is a jewel-encrusted egg here."
                }
                else
                {
                        "There is a somewhat ruined egg here."
                }
        }
        contains_desc
        {
                "Inside the egg is";
        }
        before
        {
                object DoDrop
                {
                        if location = up_a_tree
                        {
                                "The egg falls to the ground and springs
                                open, seriously damaged. There is a golden
                                clockwork canary nestled in the egg. It
                                seems to have recently had a bad experience.
                                The mountings for its jewel-like eyes are
                                empty, and its silver beak is crumpled.
                                Through a cracked crystal window below its
                                left wing you can see the remains of
                                intricate machinery. It is not clear what
                                result winding it would have, as the
                                mainspring seems sprung."

                                DoBreakEgg
                                move egg to forest_path
                                move broken_canary to egg
                        }
                        else
                        {
                                return false
                        }
                }
                object DoOpen
                {
                        if self is not broken and
                           self is locked
                        {
                                "You have neither the tools nor
                                the expertise."
                        }
                        else
                        {
                                return false
                        }
                }
                object DoHit
                {
                        if not xobject or
                           xobject = hands
                        {
                                "I doubt you could do that without damaging
                                it."
                        }
                        elseif object is sharp
                        {
                                "The egg is now open, but the clumsiness
                                of your attempt has seriously compromised
                                its esthetic appeal."
                                DoBreakEgg
                                move broken_canary to egg
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

treasure canary "golden clockwork canary"
{
        noun "canary"
        adjectives "clockwork" "golden"
        article "a"
        take_points 6
        deposit_points 4
        size 5
        in nothing
        before
        {
                object DoWind
                {
                        if self is not special and
                          (location = forest_path or
                           location = up_a_tree)
                        {
                                "The canary chirps, slightly off-key, an
                                aria from a forgotten opera. From out of
                                the greenery flies a lovely songbird. It
                                perches on a limb just over your head and
                                opens its beak to sing. As it does so a
                                beautiful brass bauble drops from its mouth,
                                bounces off the top of your head, and lands
                                glimmering in the grass. As the canary winds
                                down, the songbird flies away."

                                self is special
                                move bauble to forest_path
                        }
                        else
                        {
                                "The canary chirps blithely, if somewhat
                                tinnily, for a short time."
                        }
                }
        }
}

object broken_canary "broken clockwork canary"
{
        noun "canary"
        adjectives "clockwork" "broken"
        article "a"
        in nothing
        size 5
        initial_desc
        {
                "There is a golden clockwork canary nestled in the egg. It
                seems to have recently had a bad experience. The mountings
                for its jewel-like eyes are empty, and its silver beak is
                crumpled. Through a cracked crystal window below its left
                wing you can see the remains of intricate machinery. It is
                not clear what result winding it would have, as the
                mainspring seems sprung."
        }
        before
        {
                object DoWind
                {
                        "There is an unpleasant grinding noise from
                        inside the canary."
                }
        }
}

treasure bauble "brass bauble"
{
        noun "bauble"
        adjective "brass"
        article "a"
        in nothing
        take_points 1
        deposit_points 1
}

LightRoom clearing1 "Clearing"
{
        long_desc
        {
                "You are in a clearing, with a forest surrounding you on
                all sides. A path leads south."
                if grating is open
                {
                        "There is an open grating, descending into
                        darkness."
                }
                elseif grating is not open and
                       pile_of_leaves is moved
                {
                        "There is a grating securely fastened into the
                        ground."
                }
        }
        is thief_free
        d_to
        {
           if grating is not open and
              pile_of_leaves is not moved
           {
                "You can't go that way."
           }
           else
           {
                 return grating.door_to
           }
        }
        s_to forest_path
        n_to
        {
                "The forest becomes impenetrable to the north."
        }
        w_to forest1
        e_to forest2
}

object pile_of_leaves "pile of leaves"
{
        noun "leaves"
        adjectives "pile" "of"
        article "a"
        in clearing1
        is burnable, plural
        size 10
        short_desc
        {
                "On the ground is a pile of leaves."
        }
        before
        {
                object DoCount
                {
                        "There are 69,105 leaves here."
                        return true
                }
                object DoMove, DoPull
                {
                        "Done."
                        "In disturbing the pile of leaves, a grating is
                        revealed."
                        pile_of_leaves is moved
                        return true
                }
                object DoLookUnder
                {
                        "Underneath the pile of leaves is a grating. As you
                        release the leaves, the grating is once again
                        concealed from view."
                }
        }
        after
        {
                object DoGet
                {
                        "In disturbing the pile of leaves, a grating is
                        revealed."
                        return false
                 }
        }
}

door grating "grating"
{
        noun "grating" "grate"
        article "a"
        between clearing1, grating_room
        is static, not transparent, not open, lockable, locked
        key_object skeleton_key
        long_desc
        {
                if location = clearing1 and 
                   pile_of_leaves is not moved
                {
                        "You haven't seen anything like that."
                }
                else
                {
                        "The grating is ";
                        if self is open
                        {
                                "open, but I can't tell what's beyond it."
                        }
                        else
                                "closed."
                }
        }
        before
        {
                object DoLookThrough
                {
                        if location = clearing1 and 
                           pile_of_leaves is not moved
                        {
                                "You haven't seen anything like that."
                        }
                        elseif grating is open
                        {
                                "The grating is open, but I can't tell
                                what's beyond it."
                        }
                        else
                        {
                                return false
                        }
                }
                object DoOpen
                {
                        if pile_of_leaves is not moved and
                           location = clearing1
                        {
                                "You can't see any grating here!"
                                object = pile_of_leaves
                                return true
                        }
                        return false
                }
        }
        after
        {
                object DoOpen
                {
                        trap_door is special

                        if location = grating_room
                        {
                                "The grating opens to reveal trees above
                                you."
                        }
                        else
                        {
                                "The grating opens."
                        }
                        if pile_of_leaves is not moved and
                           location = grating_room
                        {
                                "A pile of leaves falls onto your head
                                and to the ground."
                                move pile_of_leaves to grating_room
                                pile_of_leaves is moved
                        }
                }
        }
}

LightRoom forest1 "Forest"
{
        long_desc
        {
                "This is a forest, with trees in all directions. To the
                east, there appears to be sunlight."
        }
        is thief_free
        s_to forest3
        n_to clearing1
        e_to forest_path
        w_to
        {
                "You would need a machete to go further west."
        }
}

LightRoom forest2 "Forest"
{
        long_desc
        {
                "This is a dimly lit forest, with large trees all around."
        }
        is thief_free
        e_to forest4
        w_to forest_path
        s_to clearing
}

LightRoom forest3 "Forest"
{
        long_desc
        {
                "This is a dimly lit forest, with large trees all around."
        }
        is thief_free
        n_to clearing
        s_to
        {
                "Storm-tossed trees block your way."
        }
        e_to
        {
                "The rank undergrowth prevents eastward movement."
        }
        w_to forest1
        nw_to south_of_house
}

LightRoom forest4 "Forest"
{
        long_desc
        {
                "The forest thins out, revealing impassable mountains."
        }
        is thief_free
        e_to
        {
                "The mountains are impassable."
        }
        w_to forest2
        n_to forest2
        s_to forest2
}

scenery forest "forest"
{
        nouns "forest" "trees" "pines" "hemlocks"
        article "a"
        found_in forest1, forest2, forest3, forest4, forest_path, up_a_tree \
                 clearing, clearing1
        long_desc
        {
                "You cannot see the forest for the trees."
        }
        before
        {
                object DoListen
                {
                        "The pines and the hemlocks seem to be murmuring."
                }
        }
}

!----------------------------------------------------------------------------
!    AREAS INSIDE HOUSE
!----------------------------------------------------------------------------

LightRoom kitchen "Kitchen"
{
	long_desc
        {       "You are in the kitchen of the white house. A table
                seems to have been used recently for the preparation
                of food. A passage leads to the west and a dark
                staircase can be seen leading upward. A dark chimney
                leads down and to the east is a small window which is ";

                if kitchen_window is not open
                        "slightly ajar."
                else
                {
                         "open."
                }
        }
        is thief_free
        room_points 10
        w_to living_room
        u_to attic
        d_to
        {
                "Only Santa Claus climbs down chimneys."
        }
        e_to
        {
           if kitchen_window is not open
           {
                "The kitchen window is closed."
           }
           else
           {
                 return kitchen_window.door_to
           }
        }
        out_to
        {
                if kitchen_window is not open
                {
                        "The kitchen window is closed."
                }
                else
                {
                        return kitchen_window.door_to
                }
        }
}

scenery table "table"
{
        noun "table"
        adjective "kitchen"
        article "the"
        in kitchen
        is platform
        capacity 50
        contains_desc
        {
                "On the kitchen table you can see";
        }
}

object sack "sack"
{
        nouns "sack" "bag"
        adjectives "elongated" "brown"
        article "a"
        in kitchen
        is container, openable, not open, burnable
        capacity 10
        initial_desc
        {
                "On the table is an elongated brown sack, smelling of
                hot peppers."
        }
        long_desc
        {
                "The sack is ";
                if self is open
                {
                        "open."
                }
                else
                {
                        "closed."
                }
         }
         before
         {
                object DoSmell
                {
                        "It smells of hot peppers."
                }
          }
}

object lunch "lunch"
{
        nouns "lunch" "sandwich"
        adjectives "hot" "pepper"
        article "a"
        in sack
        size 5
        before
        {
                object DoEat
                {
                        "Thank you very much. It really hit the spot."
                        remove lunch
                }
         }
         after
         {
                object DoGet
                {
                        lunch.name = "hot pepper sandwich"
                        return false
                }
        }
}

object garlic "clove of garlic"
{
        noun "garlic"
        adjective "clove"
        article "a"
        in sack
        size 5
        before
        {
                object DoEat
                {
                        "What the heck! You won't make friends this way, but
                        nobody around here is too friendly anyhow. Gulp!"
                        remove garlic
                }
         }

}

object bottle "bottle"
{
        noun "bottle"
        adjective "glass"
        article "a"
        in kitchen
        is container, transparent, openable, not open
        capacity 5
        initial_desc
        {
                "A bottle is sitting on the table."
        }
        long_desc
        {
                if child(self) > 0
                {
                        "The bottle contains a quantity of water."
                }
                else
                {
                        "The bottle is empty."
                }
         }
         before
         {
                object DoFill
                {
                        if self is not open
                        {
                                "The bottle is closed."
                        }
                        else
                        {
                                if child(bottle) ~= 0
                                {
                                        "The bottle is full already."
                                }
                                elseif FindObject(river, location) or
                                       FindObject(lake, location) or
                                       FindObject(water_in_stream, location)
				{
                                        move water to bottle
                                        "The bottle is now full of water."
                                }
                                else
                                {
                                        "There is nothing here with which to
                                        fill the bottle."
                                }
                        }
                }
                object DoOpen
                {
                        "The bottle is now open."
                        self is open
                        return true
                }
                object DoPour
                {
                        if self is not open
                        {
                                "The bottle is closed."
                        }
                        else
                        {
                                Perform(&DoPour, water)
                        }
                }
         }
}

object water "water"
{
        noun "water"
        article "a quantity of"
        in bottle
        size 5
	long_desc
        {
                "It looks like ordinary water to me."
        }
	before
	{
                object DoGet
                {
                        if bottle is not open
                        {
                                "It's in the bottle. Perhaps you should
                                take that instead."
                        }
                        else
                        {
                                "The water slips through your fingers."
                        }
                }
		object DoDrink
		{
                        if bottle is not open
                        {
                                "You'll have to open the bottle first."
                        }
                        else
                        {
                                "Thank you very much. I was rather thirsty
                                (from all this talking, probably)."
                                remove water
                        }
		}
                object DoPour
                {
                        if bottle is not open
                        {
                                "The bottle is closed."
                        }
                        elseif not xobject or
                           xobject = ground
                        {
                                "The water spills to the floor and evaporates
                                immediately."
                                remove water
                        }
                        elseif xobject = candles and
                           candles is light
                        {
                                remove water
                                Perform(&DoExtinguish, candles)
                        }
                        elseif xobject = red_hot_bell
                        {
                                "The water cools the bell and is evaporated."
                                remove water
                                remove red_hot_bell
                                move brass_bell to entrance_to_hades
                                Deactivate(HotBell)
                        }
                        elseif xobject = ivory_torch
                        {
                                "The water evaporates before it gets close."
                                remove water
                        }
                        elseif xobject = surrounding_wall or
                               xobject = granite_wall
                        {
                                "The water splashes on the walls and
                                evaporates immediately."
                                remove water
                        }
                        else
                        {
                                "The water spills over ";
                                print The(xobject);
                                ", to the floor, and evaporates."
                                remove water
                        }
                }
	}
}

LightRoom living_room "Living Room"
{
        long_desc
        {
                "You are in the living room. There is a doorway to the
                east";

                if wooden_door is special
                {
                        ". To the west is a cyclops-shaped opening in an old
                        wooden door, above which is some strange gothic
                        lettering, ";
                }
                else
                {
                        ", a wooden door with strange gothic lettering to the
                        west, which appears to be nailed shut, ";
                }

                "a trophy case, ";

                if rug is not moved
                {
                        "and a large oriental rug in the center of the room."
                }
                elseif rug is moved and
                       trap_door is not open
                {
                        "and a closed trap door at your feet."
                }
                else
                {
                        "and a rug lying beside an open trap door."
                }
        }
        is thief_free
        w_to
        {
                if wooden_door is not special
                {
                        "The door is nailed shut."
                }
                else
                {
                        return strange_passage
                }
        }
        e_to kitchen
        d_to
        {
                if rug is not moved
                {
                        "You can't go that way."
                }
                elseif trap_door is not open
                {
                        "The trap door is closed."
                }
                else
                {
                        if trap_door is not special
                        {
                                "The trap door crashes shut, and you hear
                                someone barring it."
                                trap_door is not open
                        }
                        return cellar
                }
        }
}

scenery wooden_door "wooden door"
{
        nouns "door" "lettering" "words"
        adjectives "wooden" "strange" "gothic"
        article "a"
        in living_room
        is openable, not open, readable
        long_desc
        {
                "The engravings translate to \"This space intentionally
                left blank.\""
        }
        before
        {
                object DoOpen
                {
                        "The door cannot be opened."
                }
        }
}

scenery nails "nails"
{
        nouns "nail" "nails"
        article "the"
        in living_room
}

scenery trophy_case "trophy case"
{
        noun "case"
        adjective "trophy"
        article "the"
        in living_room
        is container, transparent, openable, not open
        capacity 1000
        contains_desc
        {
                "Your collection of treasures consists of";
        }
        before
        {
                object DoGet
                {
                        "The trophy case is securely fastened to the wall."
                        return true
                }
                object DoLook, DoLookIn
                {
                        if children(self) = 0
                        {
                                "The trophy case is empty."
                                return true
                        }
                        return false
                }
                xobject DoPutIn
                {
                        if object is valuable and
                           object is not deposited and
                           self is open
                        {
                                score += object.deposit_points
                                object is deposited
                        }
                        return false
                }
        }
        after
        {
                xobject DoPutIn
                {
                        local c, i
                        for i in trophy_case
                        {
                                if i is valuable
                                {
                                        c++
                                }
                        }
                        if c = 19 and
                           ancient_map in nothing
                        {
                            "An almost inaudible voice whispers in
                            your ear, \"Look to your treasures for the
                            final secret.\""
                            move ancient_map to trophy_case
                            return true
                        }
                        return false
                }
        }
}

object ancient_map "ancient map"
{
        noun "map" "parchment"
        adjective "ancient"
        article "an"
        in nothing
        is readable
        initial_desc
        {
                "In the trophy case is an ancient parchment which appears
                to be a map."
        }
        long_desc
        {
                "The map shows a forest with three clearings. The largest
                clearing contains a house. Three paths leave the large
                clearing. One of these paths, leading southwest, is marked
                \"To Stone Barrow\"."
        }
}

scenery rug "rug"
{
        nouns "carpet" "rug"
        adjectives "large" "oriental"
        article "a"
        in living_room
        before
        {
                object DoLift
                {
                        if self is moved
                        {
                                "The rug is extremely heavy and cannot be
                                carried."
                        }
                        else
                        {
                                "The rug is extremely heavy and cannot be
                                carried, but in trying to take it you have
                                noticed an irregularity beneath it."
                        }
                }
                object DoGet
                {
                        "The rug is extremely heavy and cannot be carried."
                }
                object DoEnter
                {
                        "As you sit, you notice an irregularity underneath
                        it. Rather than be uncomfortable, you stand up again."
                }
                object DoMove, DoPull
                {
                        if self is moved
                        {
                                "Having moved the carpet previously, you find
                                it impossible to move it again."
                        }
                        else
                        {
                                "With a great effort, the rug is moved to one
                                side of the room, revealing the dusty cover
                                of a closed trap door."
                                self is moved
                                trap_door.between #1 = living_room
                                trap_door.between #2 = cellar
                        }
                }
                object DoFly
                {
                        "I suppose you think it's a magic carpet?"
                }
                object DoLookUnder
                {
                        if self is moved
                        {
                                return false
                        }
                        else
                        {
                                "Underneath the rug is a closed trap door. As
                                you drop the corner of the rug, the trap door
                                is once again concealed from view."
                        }
                }
        }
}

door trap_door "trap door"
{
        noun "door"
        adjectives "dusty" "trap"
        article "a"
        between 0, 0
        is static, not open
        long_desc
        {
                "The trap door is ";
                if self is open
                {
                        "open."
                }
                else
                {
                        "closed."
                }
         }
         after
         {
                object DoOpen
                {
                        "The door reluctantly opens to reveal a
                        rickety staircase descending into darkness."
                }
                object DoClose
                {
                        "The door swings shut and closes."
                }
        }
}

object sword "sword"
{
        noun "sword"
        adjectives "elvish"
        article "a"
        is weapon, sharp
        in living_room
        size 10
        initial_desc
        {
                "Above the trophy case hangs an elvish sword of great
                antiquity."
	}
        long_desc
        {
                select current_threat_level
                case 0
                {
                        return false
                }
                case 1
                {
                        "Your sword is glowing with a faint blue glow."
                }
                case 2
                {
                        "Your sword is glowing very brightly."
                }
        }
}

object lamp "brass lantern"
{
        nouns "lamp" "lantern" "light"
        adjectives "battery-powered" "brass"
        article "a"
        is switchable
        in living_room
        misc 395
        size 10
        initial_desc
        {
                "A battery-powered brass lantern is on the trophy case."
	}
	long_desc
	{
                "The lamp ";
                if self.misc = 0
                {
                        "has burned out."
                }
                elseif self is switchedon
                {
                        "is on."
                }
		else
                {
                        "is off."
                }
	}
        before
        {
                object DoThrowAt
                {
                        "The lamp has smashes into the floor, and the
                        light goes out."
                        remove lamp
                        move broken_lantern to location
                }
                object DoSwitchOn
                {
                        if self.misc = 0
                        {
                                "You can't turn that on."
                                return true
                        }
                        return false
                }
                object DoSwitchOff
                {
                        if self.misc = 0
                        {
                                "You can't turn that off."
                                return true
                        }
                        return false
                }
        }
        after
	{
		object DoSwitchOn
		{
                        self is light
                        Activate(LampDaemon)
                        
                        if self in player or
                           self in location
                        {
                                "The brass lantern is now on. "
                                FindLight(location)
                                if location is not visited
                                {
                                        DescribePlace(location)
                                        location is visited
                                }
                        }
		}
		object DoSwitchOff
		{
                        self is not light
                        Deactivate(LampDaemon)

                        if self in player or
                           self in location
                        {
                                "The brass lantern is now off. "
                                if not FindLight(location)
                                {
                                        "It is now pitch dark."
                                }
                        }
		}
	}
}

object broken_lantern "broken lantern"
{
        nouns "lamp" "lantern"
        adjectives "broken" "brass"
        article "a"
        in nothing
        size 10
}

DarkRoom attic "Attic"
{
        long_desc
        {
                "This is the attic. The only exit is a stairway
                leading down."
        }
        is thief_free
        d_to kitchen
}

scenery table1 "table"
{
        noun "table"
        article "a"
        in attic
        is platform
        capacity 50
        contains_desc
        {
                "On the table you can see";
        }
}

attachable rope "rope"
{
        noun "rope"
        article "a"
        in attic
        initial_desc
        {
                "A large coil of rope is lying in the corner."
        }
        long_desc
        {
                if railing is special
                {
                        "The rope is tied to the wooden railing."
                }
                else
                {
                        return false
                }
        }
        attach_verbs "tie", "attach"
        detach_verbs "untie", "detach"
        attached_to 0
        attachable_to railing
        attach_drop is true
        before
        {
                object DoClimb
                {
                        if railing is special
                        {
                                MovePlayer(torch_room)
                        }
                        else
                        {
                                return false
                        }
                }
                object DoDrop
                {
                        if location = dome_room
                        {
                                "The rope drops gently to the floor below."
                                move rope to torch_room
                        }
                        else
                        {
                                return false
                        }
                }
                object DoTie
                {
                        if xobject = railing and
                           railing is not special
                        {
                                "The rope drops over the side and comes
                                within ten feet of the floor."
                                railing is special
                                rope is hidden
                        }
                        return false
                }
        }
        after
        {
                object DoUntie, DoGet
                {
                        if railing is special
                        {
                                railing is not special
                                rope is not hidden
                        }
                        return false
                }
        }
}

object nasty_knife "nasty knife"
{
        noun "knife"
        adjective "nasty"
        article "a"
        is weapon, sharp
        in attic
        initial_desc
        {
                "On a table is a nasty-looking knife."
	}
        after
        {
                object DoGet
                {
                        table1 is not hidden
                        return false
                }
        }
}

!---------------------------------------------------------------------------
!    UNDERGROUND LOCATIONS
!---------------------------------------------------------------------------

DarkRoom cellar "Cellar"
{
        long_desc
        {
                "You are in a dark and damp cellar with a narrow
                passageway leading north, and a crawlway to the south.
                On the west is the bottom of a steep metal ramp which
                is unclimbable."
        }
        is thief_free
        room_points 25
        threat_level 1
        u_to
        {
                if trap_door is not open
                {
                        "The trap door is closed."
                }
                else
                {
                        return trap_door.door_to
                }
        }
        s_to east_of_chasm
        n_to troll_room
        w_to
        {
                "You try to ascend the ramp, but it is impossible, and
                you slide back down."
        }
}

DarkRoom east_of_chasm "East of Chasm"
{
        long_desc
        {
                "You are on the east edge of a chasm, the bottom of which
                cannot be seen. A narrow passage goes north, and the path
                you are on continues to the east."
        }
        before
        {
                location DoJump
                {
                        "This was not a very safe place to try jumping."
                        JumpMessage
                        NotDeadYet
                }
        }
        is thief_free
        n_to cellar
        e_to gallery
}

scenery chasm_item "chasm"
{
        noun "chasm"
        article "the"
        is container, open
        found_in east_of_chasm, chasm
        capacity 100
        before
        {
                xobject DoThrowIn
                {
                        print CThe(object);
                        " drops out of sight into the chasm."
                        remove object
                }
        }
}

DarkRoom gallery "Gallery"
{
        long_desc
        {
                "This is an art gallery. Most of the paintings have been
                stolen by vandals with exceptional taste. The vandals left
                through either the north or west exits."
        }
        is thief_free
        n_to studio
        w_to east_of_chasm
}

treasure painting "beautiful painting"
{
        nouns "painting" "picture"
        adjective "beautiful"
        article "a"
        in gallery
        is burnable
        take_points 4
        deposit_points 6
        initial_desc
        {
                "Fortunately, there is still one chance for you to be a
                vandal, for on the far wall is a painting of unparalleled
                beauty."
        }
        short_desc
        {
                "A painting by a neglected genius is here."
        }
        before
        {
                object DoCut
                {
                        if xobject is weapon
                        {
                                "Congratulations! Unlike the other vandals,
                                who merely stole the artist's masterpieces,
                                you have destroyed one."
                                remove painting
                        }
                        else
                        {
                                return false
                        }
                }
                object DoBurn
                {
                        if xobject is heat_source
                        {
                                "Congratulations! Unlike the other vandals,
                                who merely stole the artist's masterpieces,
                                you have destroyed one."
                                remove painting
                        }
                        else
                        {
                                return false
                        }
                }
        }
}


DarkRoom studio "Studio"
{
        long_desc
        {
                "This appears to have been an artist's studio. The walls and
                floors are splattered with paints of 69 different colors.
                Strangely enough, nothing of value is hanging here. At the
                south end of the room is an open door (also covered with
                paint). A dark and narrow chimney leads up from a fireplace;
                although you might be able to get up it, it seems unlikely
                you could get back down."
        }
        is thief_free
        u_to
        {
                local x
                x = children(player)

                if x = 0
                {
                        "Going up empty-handed is a bad idea."
                }
                elseif x > 2 or
                      (x <= 2 and not ObjectisLight(player))
                {
                        "You can't get up there with what you're carrying."
                }
                elseif ObjectisLight(player) and
                       x <= 2
                {
                        MovePlayer(kitchen)
                }
        }
        s_to gallery
}

object piece_of_paper "ZORK owner's manual"
{
        nouns "paper" "zork" "manual"
        adjectives "owner's" "piece"
        article "a"
        is readable, burnable
        in studio
        initial_desc
        {
                "Loosely attached to a wall is a small piece of paper."
        }
        long_desc
        {
                "Congratulations!\n"

                "You are the privileged owner of HUGO ZORK I: The Great
                Underground Empire, a self-contained and self-maintaining
                universe. If used and maintained in accordance with normal
                operating practices for small universes, HUGO ZORK will
                provide many months of trouble-free operation."
        }
}

DarkRoom troll_room "Troll Room"
{
        long_desc
        {
                "This is a small room with passages to the east and south
                and a forbidding hole leading west. Bloodstains and deep
                scratches (perhaps made by an axe) mar the walls."
        }
        is thief_free
        threat_level 2
        s_to cellar
        w_to
        {
                if troll is not unconscious and
                   troll in location
                {
                        "The troll fends you off with a menacing gesture."
                }
                else
                {
                        return maze1
                }
        }
        e_to
        {
                if troll is not unconscious and
                   troll in location
                {
                        "The troll fends you off with a menacing gesture."
                }
                else
                {
                        return east_west_passage
                }
        }
}

DarkRoom grating_room "Grating Room"
{
        long_desc
        {
                "You are in a small room near the maze. There are twisty
                passages in the immediate vicinity."

                if grating is not open
                {
                        "Above you is a grating with a skull and
                        crossbones lock."
                }
                else
                {
                        "Above you is an open grating with sunlight pouring
                        in."
                }
        }
        u_to grating
        sw_to maze11
}

!---------------------------------------------------------------------------
!        The Maze (Oh, The Horror!)
!---------------------------------------------------------------------------

MazeRoom maze1 "Maze"
{
        n_to maze1
        s_to maze2
        e_to troll_room
        w_to maze4
}

MazeRoom maze2 "Maze"
{
        s_to maze1
        e_to maze3
        d_to {
                "You won't be able to get back up to the tunnel you are
                going through when it gets to the next room."
                MovePlayer(maze4)
             }
}

MazeRoom maze3 "Maze"
{
        n_to maze4
        w_to maze2
        u_to maze5
}

MazeRoom maze4 "Maze"
{
        n_to maze1
        e_to dead_end1
        w_to maze3
}

MazeRoom maze5 "Maze"
{
        long_desc
        {
                "This is part of a maze of twisty little passages, all
                alike. A skeleton, probably the remains of a luckless
                adventurer, lies here."
        }
        n_to maze3
        sw_to maze6
        e_to dead_end3
}

object skeleton "skeleton"
{
        nouns "skeleton" "remains" "adventurer"
        adjective "luckless"
        article "a"
        is hidden
        in maze5
        before
        {
                object DoGet
                {
                        ! This section of code was borrowed from
                        ! colossal.hug

                        local c, i, j

                        "A ghost appears in the room and is appalled at your
                        desecration of the remains of a fellow adventurer. He
                        casts a curse on your valuables and banishes them to
                        the Land of the Living Dead. The ghost leaves,
                        muttering obscenities."

                        for i in player
                        {
                                if i is valuable
                                {
                                        c++
                                }
                        }
                        for i in location
                        {
                                if i is valuable
                                {
                                        c++
                                }
                        }

                        if c = 0
                        {
                                return true
                        }
                        else
                        {
                                while c > 0
                                {
                                    for i in player
                                    {
                                            if i is valuable
                                            {
                                                    j = i
                                            }
                                    }
                                    for i in location
                                    {
                                            if i is valuable
                                            {
                                                    j = i
                                            }
                                    }
                                    move j to land_of_the_dead
                                    c--
                                }
                        }
                }
	}
}

object rusty_knife "rusty knife"
{
        noun "knife"
        adjective "rusty"
        article "a"
        is weapon, sharp
        in maze5
        initial_desc
        {
                "Beside the skeleton is a rusty knife."
        }
        before
        {
                object DoGet
                {
                        if Contains(player, sword)
                        {
                                "As you touch the rusty knife, your sword
                                gives a single pulse of blinding blue light."
                                return false
                        }
                        else
                        {
                                return false
                        }
                }
                xobject DoHit
                {
                        if object is living
                        {
                                "As the knife approaches its victim, your
                                mind is submerged by an overmastering will.
                                Slowly, your hand turns, until the rusty
                                blade is an inch from your neck. The knife
                                seems to sing as it savagely slits your
                                throat."
                                NotDeadYet
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

object burned_out_lantern "burned-out lantern"
{
        nouns "lamp" "lantern"
        adjective "burned-out"
        article "a"
        in maze5
        is switchable
        size 10
        initial_desc
        {
                "The deceased adventurer's useless lantern is here."
        }
        before
        {
                object DoSwitchOn
                {
                        "A burned-out lamp won't light."
                }
                object DoSwitchOff
                {
                        "The lamp has already burned out."
                }
        }
}

object skeleton_key "skeleton key"
{
        noun "key"
        article "a"
        size 10
        in maze5
}

treasure coins "bag of coins"
{
        nouns "coins" "bag"
        article "a"
        is container, not openable, not open
        in maze5
        take_points 10
        deposit_points 5
        initial_desc
        {
                "An old leather bag, bulging with coins, is here."
        }
        long_desc
        {
                "There are lots of coins in there."
        }
        before
        {
                object DoOpen
                {
                        "The coins are safely inside; there's no need to
                        do that."
                }
        }
}

MazeRoom maze6 "Maze"
{
        e_to maze7
        w_to maze6
        u_to maze9
        d_to maze5
}

MazeRoom maze7 "Maze"
{
        d_to {  "You won't be able to get back up to the tunnel you are
                going through when it gets to the next room."
                MovePlayer(dead_end1)
             }
        s_to maze15
        e_to maze8
        w_to maze6
        u_to maze14
}

MazeRoom maze8 "Maze"
{
        ne_to maze7
        se_to dead_end4
        w_to maze8
}

MazeRoom maze9 "Maze"
{
        n_to maze6
        nw_to maze9
        w_to maze12
        s_to maze13
        e_to maze10
        d_to maze11
}

MazeRoom maze10 "Maze"
{
        e_to maze9
        w_to maze13
        u_to maze11
}

MazeRoom maze11 "Maze"
{
        d_to maze10
        sw_to maze12
        nw_to maze13
        ne_to grating_room
}

MazeRoom maze12 "Maze"
{
        d_to
        {
                "You won't be able to get back up to the tunnel you are
                going through when it gets to the next room."

                MovePlayer(maze5)
        }
        u_to maze9
        e_to maze13
        n_to dead_end2
        sw_to maze11
}

MazeRoom maze13 "Maze"
{
        s_to maze10
        w_to maze11
        e_to maze9
        d_to maze12
}

MazeRoom maze14 "Maze"
{
        nw_to maze14
        w_to maze15
        s_to maze7
        ne_to maze7
}

MazeRoom maze15 "Maze"
{
        threat_level 1
        w_to maze14
        s_to maze7
        se_to cyclops_room
}

Dead_End_Room dead_end1 "Dead End"
{
        s_to maze4
}

Dead_End_Room dead_end2 "Dead End"
{
        s_to maze12
}

Dead_End_Room dead_end3 "Dead End"
{
        w_to maze5
}

Dead_End_Room dead_end4 "Dead End"
{
        n_to maze8
}

!---------------------------------------------------------------------------
!        Cyclops Room and Immediate Area
!---------------------------------------------------------------------------

DarkRoom cyclops_room "Cyclops Room"
{
        long_desc
        {
                "This room has an exit on the northwest, and a staircase
                leading up."
        }
        is thief_free
        threat_level 2
        nw_to maze15
        u_to
        {
                if cyclops in location and
                   cyclops is not unconscious
                {
                        "The cyclops doesn't look like he'll let you past."
                }
                elseif player is not ghost and
                   thief is living
                {
                        "You hear a scream of anguish as you violate the
                        robber's hideaway. Using passages unknown to you,
                        he rushes to its defense."
                        "The thief gestures mysteriously, and the treasures
                        in the room suddenly vanish."

                        move silver_chalice to thiefs_bag
                        move thief to treasure_room
                        thief is hostile
                        return treasure_room
                }
                else
                {
                        return treasure_room
                }
        }
        e_to
        {
                if cyclops in location and
                   cyclops is not unconscious
                {
                        "The cyclops doesn't look like he'll let you past."
                }
                else
                {
                        return strange_passage
                }
        }
}

DarkRoom treasure_room "Treasure Room"
{
        long_desc
        {
                "This is a large room, whose east wall is solid granite. A
                number of discarded bags, which crumble at your touch, are
                scattered about on the floor. There is an exit down a
                staircase."
        }
        room_points 25
        d_to cyclops_room
        e_to
        {
                "The east wall is solid granite here."
        }
}

treasure silver_chalice "silver chalice"
{
        noun "chalice"
        adjective "chalice"
        article "a"
        in treasure_room
        take_points 10
        deposit_points 5
        initial_desc
        {
                "There is a silver chalice, intricately engraved, here."
        }
        before
        {
                object DoGet
                {
                        if thief is not unconscious
                        {
                                "You'd be stabbed in the back first."
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

DarkRoom strange_passage "Strange Passage"
{
        long_desc
        {
                "This is a long passage. To the west is one entrance. On
                the east there is an old wooden door, with a large opening
                in it (about cyclops sized)."
        }
        is thief_free
        w_to cyclops_room
        e_to living_room
}

DarkRoom east_west_passage "East-West Passage"
{
        long_desc
        {
                "This is a narrow east-west passageway. There is a narrow
                stairway leading down at the north end of the room."
        }
        w_to troll_room
        e_to round_room
        n_to chasm
        d_to chasm
}

DarkRoom round_room "Round Room"
{
        long_desc
        {
                "This is a circular stone room with passages in all
                directions. Several of them have unfortunately been blocked
                by cave-ins."
        }
        w_to east_west_passage
        e_to loud_room
        n_to north_south_passage
        s_to narrow_passage
        se_to engravings_cave
}

DarkRoom loud_room "Loud Room"
{
        long_desc
        {
                "This is a large room with a ceiling which cannot be
                detected from the ground. There is a narrow passage from
                east to west and a stone stairway leading upward. ";
                if self is special
                {
                        "The room is eerie in its quietness."
                }
                else
                {
                        "The room is deafeningly loud with an undetermined
                        rushing sound. The sound seems to reverberate from
                        all of the walls, making it difficult even to think."
                }
        }
        is thief_free ! Keeps the thief from stealing the platinum bar
        before
        {
                location DoEcho
                {
                        if self is not special
                        {
                                "The acoustics of the room change subtly."
                                self is special
                                DescribePlace(loud_room, 1)
                        }
                        else
                        {
                                return false
                        }
                }
                location
                {
                        if (word[1] = "go" or
                            word[1] = "walk") and 
                            word[2] ~= ""
                        {
                                word[1] = word[2]
                        }

                        if self is special or
                                   word[1] = "e" or
                                   word[1] = "east" or
                                   word[1] = "w" or
                                   word[1] = "west" or
                                   word[1] = "u" or
                                   word[1] = "up" or
                                   verbroutine = &DoSave or
                                   verbroutine = &DoRestore or
                                   verbroutine = &DoQuit
                        {
                                return false
                        }
                        else
                        {
                                if word[1] = "bug"
                                {
                                        "That's only your opinion."
                                }
                                else
                                {
                                        print word[words];
                                        " ";
                                        print word[words];
                                        " ..."
                                        words = 0
                                        word[1] = ""
                                }
                        }
                }
        }
        after
        {
                location
                {
                        if reservoir_status = 3
                        {
                                "It is unbearably loud here, with an
                                ear-splitting roar seeming to come from all
                                around you. There is a pounding in your head
                                which won't stop. With a tremendous effort,
                                you scramble out of the room."

                                DoTooLoud
                        }
                        return false
                }
        }
        w_to round_room
        e_to damp_cave
        u_to deep_canyon
}

treasure platinum_bar "platinum bar"
{
        noun "bar"
        adjectives "large" "platinum"
        article "a"
        in loud_room
        take_points 10
        deposit_points 5
        initial_desc
        {
                "On the ground is a large platinum bar."
        }
}

DarkRoom damp_cave "Damp Cave"
{
        long_desc
        {
                "This cave has exits to the west and east, and narrows to a
                crack toward the south. The earth is particularly damp here."
        }
        w_to loud_room
        e_to beach_north
}

DarkRoom beach_north "White Cliffs Beach"
{
        long_desc
        {
                "You are on a narrow strip of beach which runs along the
                base of the White Cliffs. There is a narrow path heading
                south along the Cliffs and a tight passage leading west
                into the cliffs themselves."
        }
        is thief_free
        w_to damp_cave
        s_to
        {
                if Contains(player, magic_boat)
                {
                        "The path is too narrow."
                }
                else
                {
                        return beach_south
                }
        }
}

DarkRoom beach_south "White Cliffs Beach"
{
        long_desc
        {
                "You are on a rocky, narrow strip of beach beside the Cliffs.
                A narrow path leads north along the shore."
        }
        is thief_free
        n_to
        {
                if Contains(player, magic_boat)
                {
                        "The path is too narrow."
                }
                else
                {
                        return beach_north
                }
        }
}

DarkRoom river1 "Frigid River"
{
        long_desc
        {
                "You are on the Frigid River in the vicinity of the Dam.
                The river flows quietly here. There is a landing on the
                west shore."
        }
        is water_location, thief_free
        w_to dam_base
}

DarkRoom river2 "Frigid River"
{
        long_desc
        {
                "The river turns a corner here making it impossible to see
                the Dam. The White Cliffs loom on the east bank and large
                rocks prevent landing on the west."
        }
        is water_location, thief_free
}


DarkRoom river3 "Frigid River"
{
        long_desc
        {
                "The river descends here into a valley. There is a narrow
                beach on the west shore below the cliffs. In the distance
                a faint rumbling can be heard."
        }
        is water_location, thief_free
        w_to beach_north
}

DarkRoom river4 "Frigid River"
{
        long_desc
        {
                "The river is running faster here and the sound ahead
                appears to be that of rushing water. On the east shore
                is a sandy beach. A small area of beach can also be seen
                below the cliffs on the west shore."
        }
        is water_location, thief_free
        w_to beach_south
        e_to sandy_beach
}

object red_buoy "red buoy"
{
        noun "buoy"
        adjectives "red" "warning"
        article "a"
        in river4
        is container, openable, not open
        capacity 10
        initial_desc
        {
                "There is a red buoy here (probably a warning)."
        }
        before
        {
                object DoTouch
                {
                        "You notice something funny about the feel of
                        the buoy."
                }
        }
}

treasure large_emerald "large emerald"
{
        noun "emerald"
        adjective "large"
        article "a"
        take_points 5
        deposit_points 10
        in red_buoy
}

DarkRoom river5 "Frigid River"
{
        long_desc
        {
                "The sound of rushing water is nearly unbearable here.
                On the east shore is a large landing area."
        }
        is water_location, thief_free
        e_to shore
}

scenery river "river"
{
        noun "river"
        adjective "frigid"
        article "the"
        is container, open
        found_in dam_base, river1, river2, river3, river4, river5 \
                 sandy_beach, shore, beach_north, beach_south
        capacity 100
        before
        {
                xobject DoThrowIn
                {
                        print CThe(object);
                        " floats for a moment, then sinks."
                        remove object
                }
        }
}

DarkRoom sandy_cave "Sandy Cave"
{
        long_desc
        {
                "This is a sand-filled cave whose exit is to the
                southwest."
        }
        is thief_free
        sw_to sandy_beach
        before
        {
                location DoDig
                {
                        if object = ground and
                           xobject = shovel
                        {
                                hole_depth++
                                select hole_depth
                                case 1
                                {
                                        "You seem to be digging a hole here."
                                }
                                case 2
                                {
                                        "The hole is getting deeper, but
                                        that's about it."
                                }
                                case 3
                                {
                                        "You are surrounded by a wall of
                                        sand on all sides."
                                }
                                case 4
                                {
                                        "You can see a scarab here in the
                                        sand."
                                        move scarab to location
                                }
                                case 5
                                {
                                        "The hole collapses, smothering you."
                                        NotDeadYet
                                }
                        }
                        elseif object = ground and
                           xobject = hands
                        {
                                "Digging with the pair of hands is slow
                                and tedious."
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

treasure scarab "beautiful jeweled scarab"
{
        noun "scarab"
        adjectives "beautiful" "jeweled"
        article "a"
        in nothing
        take_points 5
        deposit_points 5
        initial_desc
        {
                "You can see a scarab here in the sand."
        }
}

DarkRoom sandy_beach "Sandy Beach"
{
        long_desc
        {
                "You are on a large sandy beach on the east shore of the
                river, which is flowing quickly by. A path runs beside the
                river to the south here, and a passage is partially buried
                in sand to the northeast."
        }
        is thief_free
        ne_to sandy_cave
        s_to shore
}

object shovel "shovel"
{
        noun "shovel"
        article "a"
        in sandy_beach
}

DarkRoom shore "Shore"
{
        long_desc
        {
                "You are on the east shore of the river. The water here
                seems somewhat treacherous. A path travels from north to
                south here, the south end quickly turning around a sharp
                corner."
        }
        is thief_free
        n_to sandy_beach
        s_to aragain_falls
}

DarkRoom aragain_falls "Aragain Falls"
{
        long_desc
        {
                "You are at the top of Aragain Falls, an enormous
                waterfall with a drop of about 450 feet. The only
                path here is on the north end."
                if rainbow is special
                {
                        "A solid rainbow spans the falls."
                }
                else
                {
                        "A beautiful rainbow can be seen over the
                        falls and to the west."
                }
        }
        is thief_free
        n_to shore
        w_to
        {
                if rainbow is special
                {
                        MovePlayer(on_the_rainbow)
                }
                else
                {
                        "You can't go that way."
                }
        }
        u_to
        {
                if rainbow is special
                {
                        MovePlayer(on_the_rainbow)
                }
                else
                {
                        "You can't go that way."
                }
        }
        before
        {
                object DoClimb
                {
                        if rainbow is special
                        {
                                MovePlayer(on_the_rainbow)
                        }
                        else
                        {
                                "You can't go that way."
                        }
                }
        }
}

LightRoom on_the_rainbow "On The Rainbow"
{
        long_desc
        {
                "You are on top of a rainbow (I bet you never thought you
                would walk on a rainbow), with a magnificent view of the
                Falls. The rainbow travels east-west here."
        }
        is thief_free
        e_to aragain_falls
        w_to end_of_rainbow
}

DarkRoom narrow_passage "Narrow Passage"
{
        long_desc
        {
                "This is a long and narrow corridor where a long north-south
                passageway briefly narrows even further."
        }
        n_to round_room
        s_to mirror_south
}

DarkRoom mirror_south "Mirror Room"
{
        long_desc
        {
                "You are in a large square room with tall ceilings. On
                the south wall is an enormous mirror which fills the entire
                wall. There are exits on the other three sides of the room."
                if mirror is special
                {
                        "Unfortunately, the mirror has been destroyed by your
                        recklessness."
                }
        }
        n_to narrow_passage
        w_to winding_passage
        e_to cave
}

scenery mirror "mirror"
{
        noun "mirror"
        adjectives "enormous" "large"
        article "a"
        found_in mirror_south, mirror_north
        before
        {
                object DoGet
                {
                        "The mirror is many times your size. Give up."
                }
                object DoLook
                {
                        if self is not special
                        {
                                "There is an ugly person staring back at you."
                        }
                        else
                        {
                                "The mirror is broken into many pieces."
                        }
                }
                object DoTouch
                {
                        if self is not special
                        {
                                "There is a rumble from deep within the earth
                                and the room shakes."
                                if location = mirror_south
                                {
                                        MovePlayer(mirror_north)
                                }
                                else
                                {
                                        MovePlayer(mirror_south)
                                }
                        }
                        else
                        {
                                return false
                        }
                }
                object DoHit
                {
                        if self is not special
                        {
                                "You have broken the mirror. I hope you have
                                a seven years' supply of good luck handy."
                                self is special
                        }
                        else
                        {
                                "Haven't you done enough damage already?"
                        }
                }
        }
}

DarkRoom winding_passage "Winding Passage"
{
        long_desc
        {
                "This is a winding passage. It seems that there are only
                exits on the east and north."
        }
        n_to mirror_south
        e_to cave
}

DarkRoom cave "Cave"
{
        long_desc
        {
                "This is a tiny cave with entrances west and north, and a
                dark, forbidding staircase leading down."
        }
        after
        {
                location
                {
                        if Contains(player, candles) and
                           candles is light
                        {
                                "A gust of wind blows out your candles!"
                                candles is not light
                                candles is not heat_source
                                Deactivate(Candle)
                                FindLight(location)
                        }
                }
        }
        n_to mirror_south
        w_to winding_passage
        d_to entrance_to_hades
}

DarkRoom entrance_to_hades "Entrance to Hades"
{
        long_desc
        {
                "You are outside a large gateway, on which is inscribed\n"

                "\_ Abandon every hope all ye who enter here!\n"

                "The gate is open; through it you can see a desolation, with
                a pile of mangled bodies in one corner. Thousands of voices,
                lamenting some hideous fate, can be heard."
                if black_book is not special
                {
                        "The way through the gate is barred by evil spirits,
                        who jeer at your attempts to pass."
                }
        }
        u_to cave
        s_to
        {
                if black_book is not special
                {
                        "Some invisible force prevents you from passing
                        through the gate."
                }
                else
                {
                        return land_of_the_dead
                }
        }
}

DarkRoom land_of_the_dead "Land of the Dead"
{
        long_desc
        {
                "You have entered the Land of the Living Dead. Thousands of
                lost souls can be heard weeping and moaning. In the corner
                are stacked the remains of dozens of previous adventurers
                less fortunate than yourself. A passage exits to the north."
        }
        n_to entrance_to_hades
}

treasure skull "crystal skull"
{
        noun "skull"
        adjective "crystal" "carved"
        article "a"
        in land_of_the_dead
        take_points 10
        deposit_points 10
        initial_desc
        {
                "Lying in one corner of the room is a beautifully carved
                crystal skull. It appears to be grinning at you rather
                nastily."
        }
}

scenery pile_of_bodies "pile of bodies"
{
        nouns "bodies" "remains"
        adjective "pile"
        article "a"
        is plural
        in land_of_the_dead
}
 
DarkRoom engravings_cave "Engravings Cave"
{
        long_desc
        {
                "You have entered a low cave with passages leading northwest
                and east."
        }
        nw_to round_room
        e_to
        {
                if player is ghost
                {
                        "As you enter the dome you feel a strong pull as if
                        from a wind drawing you over the railing and down."

                        return torch_room
                }
                else
                {
                        return dome_room
                }
        }
}

object engravings "engravings"
{
        noun "engravings"
        adjective "old"
        article "the"
        is plural, static, readable
        in engravings_cave
        initial_desc
        {
                "There are old engravings on the walls here."
        }
        long_desc
        {
                "The engravings were incised in the living rock of the cave
                wall by an unknown hand. They depict, in symbolic form, the
                beliefs of the ancient Zorkers. Skillfully interwoven with
                the bas reliefs are excerpts illustrating the major religious
                tenets of that time. Unfortunately, a later age seems to have
                considered them blasphemous and just as skillfully excised
                them."
        }
}

DarkRoom dome_room "Dome Room"
{
        long_desc
        {
                "You are at the periphery of a large dome, which forms
                the ceiling of another room below. Protecting you from a
                precipitous drop is a wooden railing which circles the dome."
                if railing is special
                {
                        "Hanging down from the railing is a rope which ends
                        about ten feet from the floor below."
                }
        }
        is thief_free
        w_to engravings_cave
        d_to
        {
                if railing is not special
                {
                        "You cannot go down without fracturing many bones."
                }
                else
                {
                        MovePlayer(torch_room)
                }
        }
}

scenery railing "wooden railing"
{
        noun "railing"
        adjectives "wood" "wooden"
        article "a"
        in dome_room
}

DarkRoom torch_room "Torch Room"
{
        long_desc
        {
                "This is a large room with a prominent doorway leading
                to a down staircase. Above you is a large dome. Up around
                the edge of the dome (20 feet up) is a wooden railing. In
                the center of the room sits a white marble pedestal."
                if railing is special
                {
                        "A piece of rope descends from the railing above,
                        ending some five feet above your head."
                }
        }
        is thief_free
        s_to temple
        d_to temple
        u_to
        {
                if railing is special
                {
                        "You cannot reach the rope."
                }
                else
                {
                        "You can't go that way."
                }
        }
}

scenery pedestal "pedestal"
{
        noun "pedestal"
        adjectives "white" "marble"
        article "a"
        is platform
}

treasure ivory_torch "ivory torch"
{
        noun "torch"
        adjective "ivory"
        article "an"
        take_points 14
        deposit_points 6
        is light, heat_source
        in torch_room
        initial_desc
        {
                "Sitting on the pedestal is a flaming torch, made of ivory."
        }
        before
        {
                object DoExtinguish
                {
                        "You nearly burn your hand trying to extinguish the
                        flame."
                }
        }
}

DarkRoom temple "Temple"
{
        long_desc
        {
                "This is the north end of a large temple. On the east wall
                is an ancient inscription, probably a prayer in a
                long-forgotten language. Below the prayer is a staircase
                leading down. The west wall is solid granite. The exit to the
                north end of the room is through huge marble pillars."
        }
        is thief_free
        n_to torch_room
        u_to torch_room
        s_to altar_room
        w_to
        {
                "The west wall is solid granite here."
        }
        e_to egyptian_room
        d_to egyptian_room
}

scenery granite_wall "granite wall"
{
        noun "wall"
        adjective "granite"
        article "the"
        found_in treasure_room, temple
}

scenery inscriptions "inscriptions"
{
        noun "inscriptions" "prayer" "language"
        adjective "long-forgotten"
        article "the"
        is readable
        long_desc
        {
                "The prayer is inscribed in an ancient script, rarely used
                today. It seems to be a philippic against small insects,
                absent-mindedness, and the picking up and dropping of small
                objects. The final verse consigns trespassers to the land of
                the dead. All evidence indicates that the beliefs of the
                ancient Zorkers were obscure."
        }
}

object brass_bell "brass bell"
{
        noun "bell"
        adjective "brass"
        article "a"
        in temple
        before
        {
                object DoRing
                {
                        if location = entrance_to_hades and
                           Contains(player, brass_bell)
                        {
                                "The bell suddenly becomes red hot and falls
                                to the ground. The wraiths, as if paralyzed,
                                stop their jeering and slowly turn to face
                                you. On their ashen faces, the expression of
                                a long-forgotten terror takes shape."
                                remove brass_bell
                                move red_hot_bell to location
                                ceremony_1 = 1
                                Activate(HotBell, 20)
                                Activate(Ceremony, 5)
                                if Contains(player, candles)
                                {
                                        "In your confusion, the candles drop
                                        to the ground (and they are out)."
                                        move candles to location
                                        candles is not light
                                        candles is not heat_source
                                        Deactivate(Candle)
                                        FindLight(location)
                                }
                        }
                        else
                        {
                                "Ding, dong."
                        }
                }
        }
}

object red_hot_bell "red hot brass bell"
{
        noun "bell"
        adjectives "brass" "red" "hot"
        article "a"
        in nothing
        long_desc
        {
                "On the ground is a red hot bell."
        }
        before
        {
                object DoGet
                {
                        "The bell is very hot and cannot be taken."
                }
                object DoTouch
                {
                        "The bell is too hot to touch."
                }
                object DoRing
                {
                        "The bell is too hot to reach."
                }
        }
}

DarkRoom altar_room "Altar"
{
        long_desc
        {
                "This is the south end of a large temple. In front of you is
                what appears to be an altar. In one corner is a small hole in
                the floor which leads into darkness. You probably could not
                get back up it."
        }
        is thief_free
        n_to temple
        d_to
        {
                if Contains(player, coffin)
                {
                        "You haven't a prayer of getting the coffin down
                        there."
                }
                else
                {
                        MovePlayer(cave)
                }
        }
        before
        {
                location
                {
                        ! Starts the candle burn-down timer when the
                        ! player first enter the room

                        if self is not special
                        {
                                Activate(Candle) 
                                self is special
                        }
                        return false
                }
        }
}

scenery altar "altar"
{
        noun "altar"
        article "an"
        is platform
        capacity 10
        in altar_room
}

object black_book "black book"
{
        nouns "book" "prayer"
        adjectives "large" "black" "page" "pages" "569"
        article "a"
        is readable, container, openable, open
        size 10
        in altar_room
        initial_desc
        {
                "On the altar is a large black book, open to page 569."
        }
        long_desc
        {
                if Ceremony_1 and
                   Ceremony_2
                {
                        "Each word of the prayer reverberates through the
                        hall in a deafening confusion. As the last word
                        fades, a voice, loud and commanding, speaks:
                        \"Begone, fiends!\" A heart-stopping scream fills the
                        cavern, and the spirits, sensing a greater power,
                        flee through the walls."
                        Deactivate(Ceremony)
                        self is special
                }
                else
                {
                        "Commandment #12592\n"

                        "Oh ye who go about saying unto each:  \"Hello sailor\":"
                        "Dost thou know the magnitude of thy sin before the gods?"
                        "Yea, verily, thou shalt be ground between two stones."
                        "Shall the angry gods cast thy body into the whirlpool?"
                        "Surely, thy eye shall be put out with a sharp stick!"
                        "Even unto the ends of the earth shalt thou wander and"
                        "Unto the land of the dead shalt thou be sent at last."
                        "Surely thou shalt repent of thy cunning."
                }
        }
        before
        {
                object DoClose
                {
                        "As hard as you try, the book cannot be closed."
                }
                object DoOpen
                {
                        "The book is already open to page 569."
                }
                object DoTurn
                {
                        "Beside page 569, there is only one other page with
                        any legible printing on it. Most of it is unreadable,
                        but the subject seems to be the banishment of evil.
                        Apparently, certain noises, lights, and prayers are
                        efficacious in this regard."
                }
                object DoBurn
                {
                        if xobject is heat_source
                        {
                                "A booming voice says \"Wrong, cretin!\" and
                                you notice that you have turned into a pile
                                of dust. How, I can't imagine."
                                NotDeadYet
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

object candles "pair of candles"
{
        nouns "candles" "candle"
        adjectives "pair"
        article "a"
        is plural, light, heat_source
        in altar_room
        initial_desc
        {
                if candles is light
                {
                        "On the two ends of the altar are burning candles."
                }
                else
                {
                        "On the two ends of the altar are a pair of
                        candles."
                }
        }
        long_desc
        {
                "The candles are ";
                if self is light
                {
                        "burning."
                }
                else
                {
                        "out."
                }
        }
        before
        {
                object DoExtinguish
                {
                        "The flame is extinguished."
                        candles is not light
                        candles is not heat_source
                        Deactivate(Candle)
                        FindLight(location)
                }
                object DoCount
                {
                        "Let's see, how many objects in a pair? Don't
                        tell me, I'll get it."
                }
                object DoBurn
                {
                        if xobject = ivory_torch and
                           candles is not light
                        {
                                "The heat from the torch is so intense that
                                the candles are vaporized."
                                remove candles
                        }
                        elseif xobject = ivory_torch and
                           candles is light
                        {
                                "You realize, just in time, that the candles
                                are already lighted."
                        }
                        elseif xobject = matchbook and
                           matchbook is light and
                           candles is not light and
                           location = entrance_to_hades and
                           Ceremony_1 = 1 and
                           Contains(player, candles) and
                           candle_life > 0
                        {
                                "The flames flicker wildly and appear
                                to dance. The earth beneath your feet
                                trembles, and your legs nearly buckle
                                beneath you. The spirits cower at your
                                unearthly power."
                                candles is light
                                candles is heat_source
                                Activate(Candle)
                                Ceremony_2 = 1
                        }
                        elseif xobject = matchbook and
                           matchbook is light and
                           candles is not light and
                           candle_life > 0
                        {
                                "The candles are lit."
                                candles is light
                                Activate(Candle)
                        }
                        elseif xobject = matchbook and
                               matchbook is light and
                               candles is light
                        {
                                "The candles are already lit."
                        }
                        elseif xobject = matchbook and
                          matchbook is light and
                          candle_life = 0
                        {
                                "Alas, there's not much left of the candles.
                                Certainly not enough to burn."
                        }
                        else
                        {
                                return false
                        }
                }
        }
        after
        {
                object DoGet
                {
                        if candles is light and
                           location = entrance_to_hades and
                           Ceremony_1 = 1
                        {
                                "The flames flicker wildly and appear
                                to dance. The earth beneath your feet
                                trembles, and your legs nearly buckle
                                beneath you. The spirits cower at your
                                unearthly power."
                                candles is light
                                Ceremony_2 = 1
                        }
                        return false
                }
        }
}

DarkRoom egyptian_room "Egyptian Room"
{
        long_desc
        {
                "This is a room which looks like an Egyptian tomb. There is
                an ascending staircase to the west."
        }
        is thief_free
        w_to temple
        u_to temple
}

treasure coffin "gold coffin"
{
        noun "coffin"
        adjectives "gold" "solid-gold"
        article "a"
        is container, openable
        capacity 50
        size 60
        in egyptian_room
        take_points 10
        deposit_points 15
        initial_desc
        {
                "The solid-gold coffin used for the burial of Ramses II
                is here."
        }
        contains_desc
        {
                "Inside the coffin is";
        }
}

treasure sceptre "sceptre"
{
        nouns "sceptre" "scepter" "enamel"
        adjectives "sharp" "colored"
        article "a"
        is sharp
        in coffin
        take_points 4
        deposit_points 6
        initial_desc
        {
                "A sceptre, possibly that of ancient Egypt itself, is in
                the coffin. The sceptre is ornamented with colored enamel,
                and tapers to a sharp point."
        }
        short_desc
        {
                "An ornamented sceptre, tapering to a sharp point, is here."
        }
        before
        {
                object DoWave
                {
                        if (location = aragain_falls or
                           location = end_of_rainbow) and
                           rainbow is not special
                        {
                                "Suddenly, the rainbow appears to become
                                solid and, I venture, walkable (I think
                                the giveaway was the stairs and bannister)."
                                rainbow is special
                                if pot_of_gold in nothing and
                                   location = end_of_rainbow
                                {
                                        "A shimmering pot of gold appears at
                                        the end of the rainbow."
                                        move pot_of_gold to end_of_rainbow
                                }
                        }
                        elseif (location = aragain_falls or
                                location = end_of_rainbow) and
                                rainbow is special
                        {
                                "The rainbow seems to have become somewhat
                                run-of-the-mill."
                                rainbow is not special
                        }
                        elseif location = on_the_rainbow
                        {
                                "The structural integrity of the rainbow is
                                severely compromised, leaving you hanging in
                                mid-air, supported only by water vapor. Bye."
                                rainbow is not special
                                NotDeadYet
                        }
                        else
                        {
                                "A dazzling display of color briefly
                                emanates from the sceptre."
                        }
                }
        }
}

DarkRoom north_south_passage "North-South Passage"
{
        long_desc
        {
                "This is a high north-south passage, which forks to the
                northeast."
        }
        n_to chasm
        s_to round_room
        ne_to deep_canyon
}

DarkRoom chasm "Chasm"
{
        long_desc
        {
                "A chasm runs southwest to northeast and the path follows it.
                You are on the south side of the chasm, where a crack opens
                into a passage."
        }
        before
        {
                location DoJump
                {
                        "This was not a very safe place to try jumping."
                        JumpMessage
                        NotDeadYet
                }
        }
        s_to north_south_passage
        sw_to east_west_passage
        u_to east_west_passage
        ne_to reservoir_south
}

DarkRoom deep_canyon "Deep Canyon"
{
        long_desc
        {
                "You are on the south edge of a deep canyon. Passages
                lead off to the east, northwest and southwest. A stairway
                leads down.";
                if reservoir_status = 3
                {
                        " You can hear a loud roaring sound, like that of
                        rushing water, from below."
                }
                else
                {
                        ""
                }
        }
        e_to dam
        sw_to north_south_passage
        d_to loud_room
        nw_to reservoir_south
}

LightRoom dam "Dam"
{
        long_desc
        {
                "You are standing on the top of the Flood Control Dam
                #3, which was quite a tourist attraction in times far
                distant. There are paths to the north, south, and west,
                and a scramble down."

                ! 1 = reservoir full
                ! 2 = reservoir drained
                ! 3 = reservoir draining
                ! 4 = reservoir filling

                select reservoir_status
                case 1
                {
                        "The sluice gates on the dam are closed. Behind the
                        dam, there can be seen a wide reservoir. Water is
                        pouring over the top of the now abandoned dam."
                }
                case 2
                {
                        "The water level behind the dam is low: The sluice
                        gates have been opened. Water rushes through the dam
                        and downstream."
                }
                case 3
                {
                      "The sluice gates are open, and water rushes through
                      the dam. The water level behind the dam is still high."
                }
                case 4
                {
                        "The sluice gates are closed. The water level in the
                        reservoir is quite low, but the level is rising
                        quickly."
                }
        }
        n_to dam_lobby
        s_to deep_canyon
        e_to dam_base
        d_to dam_base
        w_to reservoir_south
}

scenery sluice_gate "sluice gate"
{
        nouns "dam" "gate" "gates"
        adjective "sluice"
        article "the"
        in dam
}

object control_panel "control panel"
{
        nouns "panel" "box"
        adjective "control"
        article "a"
        is static
        in dam
        initial_desc
        {
                "There is a control panel here, on which a large metal
                bolt is mounted. Directly above the bolt is a small green
                plastic bubble";
                if yellow_button is special
                {
                        " which is glowing serenely";
                }
                "."
        }
}

scenery bolt "bolt"
{
        noun "bolt"
        adjectives "large" "metal"
        article "a"
        in control_panel
        before
        {
                object DoTurn
                {
                        if not xobject
                        {
                                return false
                        }
                        elseif xobject ~= wrench
                        {
                                "The bolt won't turn using ";
                                print The(xobject);
                                "."
                                return true
                        }
                        elseif xobject = wrench and
                           yellow_button is not special
                        {
                                "The bolt won't turn with your best effort."
                                return true
                        }
                        elseif xobject = wrench and
                           sluice_gate is special and ! special = open
                           yellow_button is special
                        {
                                "The sluice gates close and water
                                 starts to collect behind the dam."
                                 reservoir_status = 4
                                 sluice_gate is not special
                                 Deactivate(EmptyDam)
                                 Activate(FillDam)
                                 return true
                        }
                        elseif xobject = wrench and
                           sluice_gate is not special and
                           yellow_button is special
                        {
                                "The sluice gates open and water
                                pours through the dam."
                                Deactivate(FillDam)
                                Activate(EmptyDam)
                                reservoir_status = 3
                                sluice_gate is special
                                return true
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

object wrench "wrench"
{
        noun "wrench"
        adjective "large"
        article "a"
        in maintenance_room
        long_desc
        {
                "Wrench."
        }
}

LightRoom dam_base "Dam Base"
{
        long_desc
        {
                "You are at the base of Flood Control Dam #3, which looms
                above you and to the north. The river Frigid is flowing by
                here. Along the river are the White Cliffs which seem to
                form giant walls stretching from north to south along the
                shores of the river as it winds its way downstream."
        }
        is thief_free
        n_to dam
        u_to dam
}

object pile_of_plastic "pile of plastic"
{
        nouns "plastic" "valve" "boat"
        adjective "pile"
        article "a"
        is burnable
        in dam_base
        short_desc
        {
                "There is a folded pile of plastic here which has a small
                valve attached."
        }
        before
        {
                object DoPump
                {
                        if Contains(player, pile_of_plastic)
                        {
                                "The boat must be on the ground to be
                                inflated."
                        }
                        elseif xobject = air_pump
                        {
                                "The boat inflates and appears seaworthy."
                                remove pile_of_plastic
                                move magic_boat to location
                                move tan_label to magic_boat
                                WhatsIn(magic_boat)
                        }
                        else
                        {
                                return false
                        }
                }
                object DoCut
                {
                        if xobject is not weapon
                        {
                                return false
                        }
                        else
                        {
                                "You skillfully slice ";
                                print The(object);
                                " into innumerable slivers which
                                blow away."
                                remove pile_of_plastic
                        }
                }
        }
}

object punctured_boat "punctured boat"
{
        noun "boat"
        adjective "punctured"
        article "a"
        is burnable
        in nothing
        before
        {
                object DoPump
                {
                        if xobject = air_pump
                        {
                                "No chance. Some moron punctured it."
                        }
                        else
                        {
                                return false
                        }
                }
                object DoPatch
                {
                        if xobject = viscous_material
                        {
                                "Well done. The boat is repaired."
                                viscous_material is special
                        }
                }
                object DoCut
                {
                        if xobject is not weapon
                        {
                                return false
                        }
                        else
                        {
                                "You skillfully slice ";
                                print The(object);
                                " into innumerable slivers which
                                blow away."
                                remove punctured_boat
                        }
                }
        }
}

boat magic_boat "magic boat"
{
        noun "boat"
        adjective "magic" "seaworthy"
        article "a"
        in nothing
        capacity 100
        reach magic_boat, river4 ! so player can reach the buoy
	before
	{
		parent(player) DoGo
		{
                        if location is not water_location
                        {
                                "You'll have to get out of the magic boat
                                first."
                                return true
                        }

                        if word[1] = "go" and
                           word[2] ~= ""
                        {
                                word[1] = word[2]
                        }

                        if (word[1] = "e" or
                           word[1] = "east")
                        {
                                if location = stream
                                {
                                        move magic_boat to reservoir
                                        location = reservoir
                                        DescribePlace(location, 1)
                                }
                                elseif location = river2
                                {
                                        "The White Cliffs prevent your
                                        landing here."
                                        return true
                                }
                                elseif location = river4
                                {
                                        move magic_boat to sandy_beach
                                        location = sandy_beach
                                        DescribePlace(location, 1)
                                        Deactivate(RiverCurrent)
                                }
                                elseif location = river5
                                {
                                        move magic_boat to shore
                                        location = shore
                                        DescribePlace(location, 1)
                                        Deactivate(RiverCurrent)
                                }
                                else
                                {
                                        return false
                                }
                        }
                        elseif (word[1] = "w" or
                                word[1] = "west")
                        {
                                if location = stream
                                {
                                        "The channel is too narrow."
                                        return true
                                }
                                elseif location = reservoir
                                {
                                        if reservoir_status ~= 1
                                        {
                                                return false
                                        }
                                        else
                                        {
                                                move magic_boat to stream
                                                location = stream
                                                DescribePlace(location, 1)
                                        }
                                }
                                elseif location = river1
                                {
                                        move magic_boat to dam_base
                                        location = dam_base
                                        DescribePlace(location, 1)
                                        Deactivate(RiverCurrent)
                                }
                                elseif location = river2
                                {
                                        "Just in time you steer away from
                                        the rocks."
                                        return true
                                }
                                elseif location = river3
                                {
                                        move magic_boat to beach_north
                                        location = beach_north
                                        DescribePlace(location, 1)
                                        Deactivate(RiverCurrent)
                                }
                                elseif location = river4
                                {
                                        move magic_boat to beach_south
                                        location = beach_south
                                        DescribePlace(location, 1)
                                        Deactivate(RiverCurrent)
                                }
                                else
                                {
                                        return false
                                }
                        }
                        elseif (word[1] = "n" or
                                word[1] = "north")
                        {
                                if location = reservoir
                                {
                                        move magic_boat to reservoir_north
                                        location = reservoir_north
                                        DescribePlace(location, 1)
                                }
                                else
                                {
                                        "Read the label for the boat's
                                        instructions."
                                        return true
                                }
                        }
                        elseif (word[1] = "s" or
                                word[1] = "south")
                        {
                                if location = reservoir
                                {
                                        move magic_boat to reservoir_south
                                        location = reservoir_south
                                        DescribePlace(location, 1)
                                }
                                elseif location = stream
                                {
                                        move magic_boat to stream_view
                                        location = stream_view
                                        DescribePlace(location, 1)
                                }
                                else
                                {
                                        "Read the label for the boat's
                                        instructions."
                                        return true
                                }
                        }
                        elseif verbroutine = &DoGo
                        {
                                "Read the label for the boat's
                                instructions."
                                return true
                        }
		}
                object DoPump
                {
                        if xobject = air_pump
                        {
                                "Inflating it further would probably
                                burst it."
                        }
                        else
                        {
                                return false
                        }
                }
                object DoDeflate
                {
                        if parent(player) = self
                        {
                                "You can't deflate the boat while you're
                                in it."
                        }
                        elseif Contains(player, magic_boat)
                        {
                                "The boat must be on the ground to be
                                deflated."
                        }
                        else
                        {
                                "The boat deflates."
                                remove magic_boat
                                move pile_of_plastic to location
                                remove tan_label
                        }
                }
                object DoCut
                {
                        if xobject is not weapon
                        {
                                return false
                        }
                        else
                        {
                                if parent(player) = self
                                {
                                        "Not a bright idea, especially since
                                        you're in it."
                                }
                                else
                                {
                                        "You skillfully slice ";
                                        print The(object);
                                        " into innumerable slivers which
                                        blow away."
                                        remove magic_boat
                                }
                        }
                }
		object DoClimb
                {
                        Perform(&DoEnter, self)
                }
                object DoEnter
                {
                        local c, i

                        for i in player
                        {
                                if i is sharp
                                {
                                        c++
                                }
                        }

                        if Contains(player, magic_boat)
                        {
                                "You'll have to put it down first."
                                return true
                        }
                        elseif c > 0
                        {
                                "Oops! Something sharp seems to have slipped
                                and punctured the boat. The boat deflates to
                                the sounds of hissing, sputtering, and
                                cursing."
                                remove magic_boat
                                move punctured_boat to location
                        }
                        else
                        {
                                return false
                        }
                }
                object DoPoke
                {
                        if xobject is sharp
                        {
                                DoDrown
                        }
                        else
                        {
                                return false
                        }
                }
	}
}

object tan_label "tan label"
{
        noun "label"
        adjective "tan"
        article "a"
        in nothing
        is readable
        long_desc
        {
                "\_  !!!!  FROBOZZ MAGIC BOAT COMPANY  !!!!\n"

                "Hello, Sailor!\n"

                "Instructions for use:\n"

                "\_ To get into a body of water, say \"Launch\"."
                "\_ To get to shore, say \"Land\" or the direction in
                which you want to maneuver the boat.\n"

                "Warranty:\n"

                "\_ This boat is guaranteed against all defects for a period
                of 76 milliseconds from date of purchase or until first
                used, whichever comes first.\n"

                "Warning:"
                "\_ This boat is made of thin plastic."
                "\_ Good Luck!"
        }
}

LightRoom dam_lobby "Dam Lobby"
{
        long_desc
        {
                "This room appears to have been the waiting room for groups
                touring the dam. There are open doorways here to the north
                and east marked \"Private\", and there is a path leading south
                over the top of the dam."
        }
        is thief_free
        s_to dam
        n_to
        {
                if maint_room_level = 14
                {
                        "The room is full of water and cannot be entered."
                }
                else
                {
                        MovePlayer(maintenance_room)
                }
        }
        e_to
        {
                if maint_room_level = 14
                {
                        "The room is full of water and cannot be entered."
                }
                else
                {
                        MovePlayer(maintenance_room)
                }
        }
}

object guidebook "guidebook"
{
        noun "guidebook" "guidebooks" "book" "books"
        adjective "guide"
        article "a"
        is plural, readable, burnable
        in dam_lobby
        initial_desc
        {
                "Some guidebooks entitled \"Flood Control Dam #3\" are on
                the reception desk."
        }
        long_desc
        {
                "\"\_  Flood Control Dam #3\n"

                "FCD#3 was constructed in year 783 of the Great Underground
                Empire to harness the mighty Frigid River. This work was
                supported by a grant of 37 million zorkmids from your
                omnipotent local tyrant Lord Dimwit Flathead the Excessive.
                This impressive structure is composed of 370,000 cubic feet
                of concrete, is 256 feet tall at the center, and 193 feet
                wide at the top. The lake created behind the dam has a volume
                of 1.7 billion cubic feet, an area of 12 million square feet,
                and a shore line of 36 thousand feet.\n"

                "We will now point out some of the more interesting features
                of FCD#3 as we conduct you on a guided tour of the
                facilities:\n"

                "\_    1) You start your tour here in the Dam Lobby. You
                will notice on your right that....\""
        }
}

object matchbook "matchbook"
{
        nouns "matchbook" "matches" "match"
        article "a"
        in dam_lobby
        is readable, container, openable, not open
        initial_desc
        {
                "There is a matchbook whose cover says \"Visit Beautiful
                FCD#3\" here."
        }
        long_desc
        {
                "The matchbook isn't very interesting, except for what's
                written on it."
        }
        before
        {
                object DoOpen
                {
                        if match_count > 0
                        {
                                "You have ";
                                print number match_count;
                                if match_count = 1
                                        " match."
                                else
                                        " matches."
                        }
                        else
                        {
                                "You have no matches."
                        }
                }
                object DoBurn
                {
                        if match_count > 0 and
                           location = timber_room
                        {
                                "This room is drafty, and the match goes
                                out instantly."
                                match_count--
                        }
                        elseif match_count > 0 and
                           location = gas_room
                        {
                                "How sad for an aspiring adventurer to light
                                a match in a room which reeks of gas.
                                Fortunately, there is justice in the
                                world.\n"

                                "\_   ** BOOOOOOOOOOOM **"

                                match_count--

                                NotDeadYet
                        }
                        elseif match_count > 0
                        {
                                "One of the matches starts to burn."
                                match_count--
                                self is light
                                self is heat_source
                                Activate(Match, 2)
                        }
                        else
                        {
                                "I'm afraid that you have run out of
                                matches."
                        }
                }
                object DoRead
                {
                        "(Close cover before striking)\n"

                        "YOU too can make BIG MONEY in the exciting field of
                        PAPER SHUFFLING!\n"

                        "Mr. Anderson of Muddle, Mass. says: \"Before I took
                        this course I was a lowly bit twiddler. Now with what
                        I learned at GUE Tech I feel really important and can
                        obfuscate and confuse with the best.\"\n"

                        "Dr. Blank had this to say: \"Ten short days ago all
                        I could look forward to was a dead-end job as a
                        doctor. Now I have a promising future and make really
                        big Zorkmids.\"\n"

                        "GUE Tech can't promise these fantastic results to
                        everyone. But when you earn your degree from GUE
                        Tech, your future will be brighter."
                }
        }
}

DarkRoom maintenance_room "Maintenance Room"
{
        long_desc
        {
                "This is what appears to have been the maintenance room for
                Flood Control Dam #3. Apparently, this room has been
                ransacked recently, for most of the valuable equipment is
                gone. On the wall in front of you is a group of buttons
                colored blue, yellow, brown, and red. There are doorways to
                the west and south."
        }
        is thief_free
        s_to dam_lobby
        w_to dam_lobby
}

scenery blue_button "blue button"
{
        noun "button"
        adjective "blue"
        article "a"
        in maintenance_room
        before
        {
                object DoPush
                {
                        if self is not special
                        {
                                "There is a rumbling sound and a stream of
                                water appears to burst from the east wall of
                                the room (apparently, a leak has occurred in
                                a pipe)."
                                self is special
                                move leak to maintenance_room
                                Activate(FillMaintRoom)
                        }
                        else
                        {
                                "The blue button appears to be jammed."
                        }
                }
                object DoPatch
                {
                        if xobject = viscous_material
                        {
                                "By some miracle of Zorkian technology, you
                                have managed to stop the leak in the dam."
                                viscous_material is special
                                Deactivate(FillMaintRoom)
                                return true
                        }
                        return false
                }

        }
}

scenery leak "leak"
{
        nouns "pipe" "leak"
        adjective "water"
        article "the"
        in nothing
}

scenery yellow_button "yellow button"
{
        noun "button"
        adjective "yellow"
        article "a"
        in maintenance_room
        before
        {
                object DoPush
                {
                        "Click."
                        self is special ! Turns on control panel
                }
        }
}

scenery brown_button "brown button"
{
        noun "button"
        adjective "brown"
        article "a"
        in maintenance_room
        before
        {
                object DoPush
                {
                        "Click."
                        yellow_button is not special ! Turns off control panel
                }
        }
}

scenery red_button "red button"
{
        noun "button"
        adjective "red"
        article "a"
        in maintenance_room
        before
        {
                object DoPush
                {
                        "Click."
                        "The lights within the room ";
                        if self is light
                        {
                                "shut off."
                                self is not light
                        }
                        else
                        {
                                "come on."
                                self is light
                        }
                        FindLight(location)
                }
        }
}

object screwdriver "screwdriver"
{
        noun "screwdriver"
        article "a"
        in maintenance_room
}

object tube "tube"
{
        noun "tube"
        article "a"
        in maintenance_room
        is readable, container, openable, not open
        initial_desc
        {
                "There is an object which looks like a tube of
                toothpaste here."
        }
        long_desc
        {
                "---> Frobozz Magic Gunk Company <---"
                "\_    All-Purpose Gunk"
        }
        before
        {
                object DoSqueeze
                {
                        if tube is open and
                           children(tube) = 1
                        {
                                "The viscous material oozes into your hand."
                                move viscous_material to you
                        }
                        elseif tube is not open
                        {
                                "The tube is closed."
                        }
                        elseif children(tube) = 0
                        {
                                "The tube is apparently empty."
                        }
                }
                xobject DoPutIn
                {
                        {
                                "The tube refuses to accept anything."
                        }
                }
        }
}

object viscous_material "viscous material"
{
        nouns "material" "gunk"
        adjectives "viscous" "all-purpose"
        article "the"
        in tube
        before
        {
                xobject DoOil
                {
                        if self is special ! special = player knows it is glue
                        {
                                "The all-purpose gunk isn't a lubricant."
                        }
                        else
                        {
                                "Hmm. It appears the tube contained glue,
                                not oil. Turning the bolt won't get any
                                easier...."
                        }
                }
        }
}

object toolchests "group of tool chests"
{
        nouns "chest" "chests"
        adjectives "tool" "group"
        article "a"
        is plural, container, not open
        in maintenance_room
        capacity 10
        long_desc
        {
                "The chests are all empty."
        }
        before
        {
                object DoOpen, DoPutIn, DoGet, DoTouch
                {
                        "The chests are so rusty and corroded that
                        they crumble when you touch them."
                        remove toolchests
                }
        }
}

DarkRoom reservoir_south "Reservoir South"
{
        long_desc
        {
                ! 1 = reservoir full
                ! 2 = reservoir drained
                ! 3 = reservoir draining
                ! 4 = reservoir filling

                select reservoir_status
                case 1
                {
                        "You are in a long room on the south shore of a large
                         lake, far too deep and wide for crossing."
                }
                case 2
                {
                        "You are in a long room, to the north of which was
                        formerly a lake. However, with the water level
                        lowered, there is merely a wide stream running
                        through the center of the room."
                }
                case 3
                {
                        "You are in a long room. To the north is a large lake,
                        too deep to cross. You notice, however, that the water
                        level appears to be dropping at a rapid rate. Before
                        long, it might be possible to cross to the other side from
                        here."
                }
                case 4
                {
                        "You are in a long room, to the north of which is a
                        wide area which was formerly a reservoir, but now is
                        merely a stream. You notice, however, that the level
                        of the stream is rising quickly and that before long
                        it will be impossible to cross here."
                }
                "There is a path along the stream to the east or west, a
                steep pathway climbing southwest along the edge of a chasm,
                and a path leading into a canyon to the southeast."
        }
        e_to dam
        w_to stream_view
        n_to
        {
                if reservoir_status = 1 or
                   reservoir_status = 3
                {
                        "You'd drown."
                }
                else
                {
                        MovePlayer(reservoir)
                }
        }
        sw_to chasm
        se_to deep_canyon
}

DarkRoom stream_view "Stream View"
{
        long_desc
        {
                "You are standing on a path beside a gently flowing stream.
                The path follows the stream, which flows from west to east."
        }
        e_to reservoir_south
}

DarkRoom stream "Stream"
{
        long_desc
        {
                "You are on the gently flowing stream. The upstream route is
                too narrow to navigate, and the downstream route is invisible
                due to twisting walls. There is a narrow beach to land on."
        }
        is water_location, thief_free
        s_to stream_view
        e_to reservoir
}

scenery water_in_stream "stream"
{
        nouns "stream"
        article "the"
        found_in stream, stream_view
}

DarkRoom reservoir "Reservoir"
{
        long_desc
        {
                if reservoir_status = 1 or
                   reservoir_status = 3
                {
                        "You are on the lake. Beaches can be seen north and
                        south. Upstream a small stream enters the lake
                        through a narrow cleft in the rocks. The dam can
                        be seen downstream."
                }
                else
                {
                        "You are on what used to be a large lake, but which
                        is now a large mud pile. There are \"shores\" to the
                        north and south."
                }
        }
        is water_location, thief_free
        w_to
        {
                "You can't go there without a vehicle."
        }
        s_to reservoir_south
        n_to reservoir_north
}

scenery lake "lake"
{
        nouns "lake" "reservoir"
        article "the"
        found_in reservoir_south, reservoir_north, reservoir
        long_desc
        {
                if reservoir_status = 2 ! Drained
                {
                        "There's not much lake left...."
                }
                else
                {
                        return false
                }
        }
}

treasure trunk_of_jewels "trunk of jewels"
{
        nouns "trunk" "jewels" "chest"
        article "a"
        take_points 15
        deposit_points 5
        in nothing
        is container, not openable, not open
        initial_desc
        {
                "Lying half buried in the mud is an old trunk, bulging with
                jewels."
        }
        short_desc
        {
                "There is an old trunk here, bulging with assorted jewels."
        }
        before
        {
                object DoOpen
                {
                        "The jewels are safely inside; there's no need to
                        do that."
                }
                object DoLook, DoLookIn
                {
                        "There are lots of jewels in there."
                }
        }
}

DarkRoom reservoir_north "Reservoir North"
{
        long_desc
        {
                ! 1 = reservoir full
                ! 2 = reservoir drained
                ! 3 = reservoir draining
                ! 4 = reservoir filling

                select reservoir_status
                case 1
                {
                        "You are in a large cavernous room, north of a large
                        lake."
                }
                case 2
                {
                        "You are in a large cavernous room, the south of
                        which was formerly a lake. However, with the water
                        level lowered, there is merely a wide stream running
                        through there."
                }
                case 3
                {
                        "You are in a large cavernous area. To the south is
                        a wide lake, whose water level appears to be falling
                        rapidly."
                }
                case 4
                {
                        "You are in a cavernous area, to the south of which
                        is a very wide stream. The level of the stream is
                        rising rapidly, and it appears that before long it
                        will be impossible to cross to the other side."
                }
                "There is a slimy stairway leaving the room to the north."
        }
        n_to atlantis_room
        s_to
        {
                if reservoir_status = 1 or
                   reservoir_status = 3
                {
                        "You'd drown."
                }
                else
                {
                        MovePlayer(reservoir)
                }
        }
}

object air_pump "hand-held air pump"
{
        noun "pump"
        adjectives "hand-held" "air"
        article "a"
        in reservoir_north
}                

DarkRoom atlantis_room "Atlantis Room"
{
        long_desc
        {
                "This is an ancient room, long under water. There is an exit
                to the south and a staircase leading up."
        }
        u_to cave2
        s_to reservoir_north
}

treasure trident "crystal trident"
{
        noun "trident"
        adjective "crystal"
        article "a"
        in atlantis_room
        take_points 4
        deposit_points 11
        initial_desc
        {
                "On the shore lies Poseidon's own crystal trident."
        }
}

DarkRoom cave2 "Cave"
{
        long_desc
        {
                "This is a tiny cave with entrances west and north, and a
                staircase leading down."
        }
        s_to atlantis_room
        d_to atlantis_room
        n_to mirror_north
        w_to twisting_passage
}

DarkRoom twisting_passage "Twisting Passage"
{
        long_desc
        {
                "This is a winding passage. It seems that there are only
                exits on the east and north."
        }
        n_to mirror_north
        e_to cave2
}

DarkRoom mirror_north "Mirror Room"
{
        long_desc
        {
                "You are in a large square room with tall ceilings. On
                the south wall is an enormous mirror which fills the entire
                wall. There are exits on the other three sides of the room."
                if mirror is special
                {
                        "Unfortunately, the mirror has been destroyed by your
                        recklessness."
                }
        }
        n_to cold_passage
        w_to twisting_passage
        e_to cave2
}

DarkRoom cold_passage "Cold Passage"
{
        long_desc
        {
                "This is a cold and damp corridor where a long east-west
                passageway turns into a southward path."
        }
        s_to mirror_north
        w_to slide_room
}

DarkRoom slide_room "Slide Room"
{
        long_desc
        {
                "This is a small chamber, which appears to have been part of
                a coal mine. On the south wall of the chamber the letters
                \"Granite Wall\" are etched in the rock. To the east is a
                long passage, and there is a steep metal slide twisting
                downward. To the north is a small opening."
        }
        n_to mine_entrance
        e_to cold_passage
        d_to cellar
}

scenery slide "slide"
{
        nouns "slide" "chute"
        adjectives "metal" "steep"
        article "the"
        is container, open
        door_to cellar
        found_in slide_room
        capacity 100
        before
        {
                xobject DoThrowIn, DoPutIn
                {
                        print CThe(object);
                        " falls into the slide and is gone."
                        move object to cellar
                }
        }
}


scenery fake_granite "granite wall"
{
        noun "wall"
        adjective "granite"
        article "the"
        in slide_room
        long_desc
        {
                local a
                a = random(2)
                select a
                case 1
                {
                        "It only SAYS \"Granite Wall\"."
                }
                case 2
                {
                        "The wall isn't granite."
                }
        }
}

DarkRoom mine_entrance "Mine Entrance"
{
        long_desc
        {
                "You are standing at the entrance of what might have been a
                coal mine. The shaft enters the west wall, and there is
                another exit on the south end of the room."
        }
        s_to slide_room
        w_to squeaky_room
}

DarkRoom squeaky_room "Squeaky Room"
{
        long_desc
        {
                "You are in a small room. Strange squeaky sounds may be heard
                coming from the passage at the north end. You may also escape
                to the east."
        }
        threat_level 1
        n_to bat_room
        e_to mine_entrance
}

DarkRoom bat_room "Bat Room"
{
        long_desc
        {
                "You are in a small room which has doors only to the east
                and south."
        }
        is thief_free
        threat_level 2
        s_to squeaky_room
        e_to shaft_room
        after
        {
                location
                {
                        if bat is not special
                        {
                                local i, f
                                for (i=0; i<3; i++)
                                {
                                        "\_   Fweep!"
                                }

                                "\n\nThe bat grabs you by the scruff of your
                                neck and lifts you away...."

                                f = random(7)
                                select f
                                case 1
                                {
                                        MovePlayer(mine_entrance)
                                }
                                case 2
                                {
                                        MovePlayer(shaft_room)
                                }
                                case 3
                                {
                                        MovePlayer(coal_mine1)
                                }
                                case 4
                                {
                                        MovePlayer(coal_mine2)
                                }
                                case 5
                                {
                                        MovePlayer(coal_mine3)
                                }
                                case 6
                                {
                                        MovePlayer(coal_mine4)
                                }
                                case 7
                                {
                                        MovePlayer(ladder_top)
                                }
                        }
                        if f = 2
                        {
                                current_threat_level = 1
                                old_threat_level = 0
                        }
                        else
                        {
                                current_threat_level = 0
                        }
                        return false
                }
        }
}

object bat "bat"
{
        noun "bat"
        adjective "vampire"
        article "a"
        in bat_room
        is living
        short_desc
        {
                if garlic in player or
                   garlic in bat_room
                {
                        "In the corner of the room on the ceiling
                        is a large vampire bat who is obviously
                        deranged and holding his nose."
                        self is special
                }
                else
                {
                        "A large vampire bat, hanging from the
                        ceiling, swoops down at you!"
                        self is not special
                }
        }
        before
        {
                object DoGet, DoHit
                {
                        "You can't reach him; he's on the ceiling."
                }
                object DoTalk
                {
                        local i
                        for (i=0; i<5; i++)
                        {
                                "\_   Fweep!"
                        }
                        "\n\nThe bat pauses for a moment, perhaps thinking
                        that you should re-read the manual."
                }
        }
}

treasure jade_figurine "exquisite jade figurine"
{
        nouns "figurine" "figure" "statue"
        adjectives "jade" "exquisite"
        article "an"
        in bat_room
        take_points 5
        deposit_points 5
        initial_desc
        {
                "There is an exquisite jade figurine here."
        }
}

DarkRoom shaft_room "Shaft Room"
{
        long_desc
        {
                "This is a large room, in the middle of which is a small
                shaft descending through the floor into darkness below. To
                the west and the north are exits from this room. Constructed
                over the top of the shaft is a metal framework to which a
                heavy iron chain is attached."
        }
        is thief_free
        threat_level 1
        w_to bat_room
        n_to smelly_room
}

scenery chain "iron chain"
{
        noun "chain"
        adjective "iron"
        article "the"
        found_in shaft_room, drafty_room
        long_desc
        {
                "The chain secures a basket within the shaft."
        }
        before
        {
                object DoGet, DoPull
                {
                        "The chain is secure."
                }
                object DoRaise, DoLower
                {
                        "Perhaps you should do that to the basket."
                }
        }
}

object real_cage "basket"
{
        nouns "cage" "basket"
        adjective "iron"
        article "the"
        in shaft_room
        is static, container
        capacity 40
        initial_desc
        {
                "At the end of the chain is a basket."
        }
        long_desc
        {
                if children(real_cage) = 0
                {
                        "The cage is empty."
                }
                else
                {
                        WhatsIn(real_cage)
                }
        }
        before
        {
                object DoGet
                {
                        "The cage is securely fastened to the iron chain."
                }
                object DoRaise
                {
                        Already_done
                }
                object DoLower
                {
                        if self is not special
                        {
                                "The basket is lowered to the bottom of the
                                shaft."
                                move real_cage to drafty_room
                                move dummy_cage to shaft_room
                                FindLight(location)
                        }
                }
        }
}

scenery dummy_cage "basket"
{
        nouns "cage" "basket"
        adjective "iron"
        article "the"
        in nothing
        is container
        long_desc
        {
                "The basket is at the other end of the chain."
        }
        before
        {
                xobject DoPutIn
                {
                        "The basket is at the other end of the chain."
                }
                object DoGet
                {
                        "The basket is at the other end of the chain."
                }
                object DoRaise
                {
                        "The basket is raised to the top of the shaft."
                        move real_cage to shaft_room
                        remove dummy_cage
                        FindLight(location)
                }
                object DoLower
                {
                        Already_done
                }
        }
}

DarkRoom smelly_room "Smelly Room"
{
        long_desc
        {
                "This is a small non-descript room. However, from the
                direction of a small descending staircase a foul odor can
                be detected. To the south is a narrow tunnel."
        }
        is thief_free
        s_to shaft_room
        d_to gas_room
}

DarkRoom gas_room "Gas Room"
{
        long_desc
        {
                "This is a small room which smells strongly of coal gas.
                There is a short climb up some stairs and a narrow tunnel
                leading east."
        }
        is thief_free
        u_to smelly_room
        e_to coal_mine1
        after
        {
                location
                {
                        local c, i

                        for i in player
                        {
                                if i is heat_source
                                {
                                        c++
                                }
                        }

                        if c > 0
                        {
                                "Oh dear. It appears that the smell coming
                                from this room was coal gas. I would have
                                thought twice about carrying flaming objects
                                in here.\n"

                                "\_   ** BOOOOOOOOOOOM **"

                                NotDeadYet
                        }
                        else
                        {
                                return false
                        }
                }
        }
}

treasure bracelet "sapphire-encrusted bracelet"
{
        noun "bracelet"
        adjectives "sapphire" "sapphire-encrusted"
        article "a"
        in gas_room
        take_points 5
        deposit_points 5
        initial_desc
        {
                "There is a sapphire-encrusted bracelet here."
        }
}

CoalRoom coal_mine1 "Coal Mine"
{
        n_to gas_room
        ne_to coal_mine2
        e_to coal_mine1
}

CoalRoom coal_mine2 "Coal Mine"
{
        n_to coal_mine2
        s_to coal_mine1
        se_to coal_mine3
}

CoalRoom coal_mine3 "Coal Mine"
{
        s_to coal_mine3
        e_to coal_mine2
        sw_to coal_mine4
}

CoalRoom coal_mine4 "Coal Mine"
{
        n_to coal_mine3
        d_to ladder_top
        w_to coal_mine4
}

DarkRoom ladder_top "Ladder Top"
{
        long_desc
        {
                "This is a very small room. In the corner is a rickety wooden
                ladder, leading downward. It might be safe to descend. There
                is also a staircase leading upward."
        }
        u_to coal_mine4
        d_to ladder_bottom
}

DarkRoom ladder_bottom "Ladder Bottom"
{
        long_desc
        {
                "This is a rather wide room. On one side is the bottom of a
                narrow wooden ladder. To the west and the south are passages
                leaving the room."
        }
        u_to ladder_top
        w_to timber_room
        s_to mine_dead_end
}

DarkRoom mine_dead_end "Dead End"
{
        long_desc
        {
                "You have come to a dead end in the mine."
        }
        n_to ladder_bottom
}

object coal "small pile of coal"
{
        noun "coal"
        adjectives "small" "pile"
        article "a"
        in mine_dead_end
        is burnable
        initial_desc
        {
                "There is a small pile of coal here."
        }
}

DarkRoom timber_room "Timber Room"
{
        long_desc
        {
                "This is a long and narrow passage, which is cluttered with
                broken timbers. A wide passage comes from the east and turns
                at the west end of the room into a very narrow passageway.
                From the west comes a strong draft."
        }
        is thief_free
        e_to ladder_bottom
        w_to
        {
                if children(player) > 0
                {
                        "You cannot fit through this passage with that
                        load."
                }
                else
                {
                        MovePlayer(drafty_room)
                }
        }
}

object timber "broken timber"
{
        noun "timber"
        adjective "broken"
        article "a"
        in timber_room
        initial_desc
        {
                "There is a broken timber here."
        }
}

DarkRoom drafty_room "Drafty Room"
{
        long_desc
        {
                "This is a small drafty room in which is the bottom of a long
                shaft. To the south is a passageway and to the east a very
                narrow passage. In the shaft can be seen a heavy iron chain."
        }
        is thief_free
        room_points 13
        e_to
        {
                if children(player) > 0
                {
                        "You cannot fit through this passage with that
                        load."
                }
                else
                {
                        MovePlayer(timber_room)
                }
        }

        s_to machine_room
}

DarkRoom machine_room "Machine Room"
{
        long_desc
        {
                "This is a large, cold room whose sole exit is to the
                north. In one corner there is a machine which is reminiscent
                of a clothes dryer. On its face is a switch which is labelled
                \"START\". The switch does not appear to be manipulable by
                any human hand (unless the fingers are about 1/16 by 1/4
                inch). On the front of the machine is a large lid, which is ";
                if machine is open
                {
                        "open."
                }
                else
                {
                        "closed."
                }
        }
        is thief_free
        n_to drafty_room
}

scenery machine "machine"
{
        nouns "machine" "lid"
        adjective "large"
        article "a"
        is container, openable, not open
        capacity 10
        in machine_room
}

scenery start_switch "switch"
{
        nouns "button" "switch"
        adjective "start"
        article "a"
        in machine_room
        before
        {
                object DoPush, DoPushWith
                {
                        "Pushing the switch doesn't seem to work."
                }
                object DoTurn
                {
                        if not xobject
                        {
                                return false
                        }
                        elseif xobject = screwdriver and
                           (children(machine) = 0 or
                            machine is open)
                        {
                                "The machine doesn't seem to want to do
                                anything."
                        }
                        elseif xobject = screwdriver and
                           children(machine) > 0
                        {
                                "The machine comes to life (figuratively)
                                with a dazzling display of colored lights
                                and bizarre noises. After a few moments, the
                                excitement abates."
                                if Contains(machine, coal)
                                {
                                        remove coal
                                        move diamond to machine
                                }
                                else
                                {
                                        remove child(machine)
                                        move slag to machine
                                }
                        }
                        elseif xobject = hands
                        {
                                "You can't turn it with your hands..."
                        }
                        elseif xobject ~= screwdriver
                        {
                                "It seems that ";
                                print The(xobject);
                                " won't do."
                        }
                        else
                        {
                                return false
                        }
                }
        }
        after
        {
                object DoOpen
                {
                        "The lid opens";
                        if children(machine) = 1
                        {
                                ", revealing ";
                                print The(child(machine));
                        }
                        "."
                }
                object DoClose
                {
                        "The lid closes."
                }
        }
}

treasure diamond "huge diamond"
{
        noun "diamond"
        adjective "huge"
        article "a"
        take_points 10
        deposit_points 10
        in nothing
}

object slag "small piece of vitreous slag"
{
        noun "slag"
        adjectives "small" "piece" "vitreous"
        article "a"
        in nothing
        before
        {
                object DoGet, DoTouch
                {
                        "The slag was rather insubstantial, and crumbles
                        into dust at your touch."
                        remove slag
                }
        }
}

!---------------------------------------------------------------------------
!     HELP SYSTEM
!---------------------------------------------------------------------------

replace DoHelp
{
	local m

        while true
        {
                menuitem[0] = "Hugo Zork Help System"
                menuitem[1] = "Introduction"
                menuitem[2] = "Instructions For Playing"
                menuitem[3] = "About This Hugo Adaptation"
                menuitem[4] = "Credits"
                menuitem[5] = "For Your Amusement/Words To Try"
                menuitem[6] = "Step-by-Step Walkthru"
	
                m = Menu(6)
                select m
                case 1:  help_intro
                case 2:  help_instructions
                case 3:  help_about
                case 4:  help_credits
                case 5:  help_amuse
                case 6:  help_walkthru
		case 0
		{
			window 0	! by KT
			cls		!

			PrintStatusline
			DescribePlace(location, true) 
			return
		}
        }
}

routine help_intro
{
        CenterTitle("Introduction")

        "\"Hugo Zork\" was written as a programming exercise. I love text
        adventures and computer programming, but lack the imagination to
        write a completely original game. So, I took Infocom's \BZork I\b
        and rewrote it using Hugo - mainly to see if I could do it. The
        result is the game you are playing now.\n"

        "If you find any bugs or errors, please send e-mail to John
        Menichelli (menichel@pixi.com)\n"

        "Zork I is copyright by Activision. This work does not in any way
        challenge that copyright status.\n"

        pause

}

routine help_instructions
{
        CenterTitle("Communicating With Hugo Zork")

        "\nAside from the standard Interactive Fiction commands (such as
        BRIEF, VERBOSE, LOOK (or L), EXAMINE (or X), TAKE, DROP and
        so on), Hugo Zork also understands the word DIAGNOSE. This will
        give you a report of the player's condition."

        pause
}

routine help_about
{
        CenterTitle("About Hugo Zork")

        "The source code for this game was developed by playing the original
        Zork I, seeing what certain actions did, then coding the effect in
        Hugo.\n"

        "If that sounds painful, it was! It was a great learning experience
        though. The most difficult object to code was the magic boat,
        followed closely by the Loud Room.\n"

        "As you examine the source code, you will probably notice that it is
        not the most efficient thing you've ever read. I'm working on
        tightening it up, but my first effort was aimed at getting something
        that worked out the door.\n"

        pause
}

routine help_credits
{
        CenterTitle("Credits")

        "Hugo Zork owes its existence to, of course, Infocom's Zork I
        and Kent Tessman's Hugo Text Adventure programnming language.\n"

        "The source code for Hugo Zork is freeware. Since it uses the
        actual text from Zork I, those parts are copyright by Activision
        and are used without their permission.\n"

        "The Hugo Compiler and Engine are copyright (c) 1995-1996 by
        Kent Tessman.\n"

        "I would like to thank Kent Tessman for his assistance and patience
        answering all my questions. Without him I would never have finished
        this project.\n"

        "When I was approximately 75% complete, I discovered the source
        code to the TADS port of Dungeon, the precursor to Zork. While
        reading the source code I discovered many things I had not thought
        of (such as what objects fit where, how some objects interact
        with others, and so on.) Many thanks to Darin Johnson
        (tdjohnson@cs.ucsd.edu) for the work he did on the TADS version
        of Dungeon.\n"

        "Some sections of code were taken from the Colossal Cave
        Adventure (colossal.hug) and are copyright by Kent Tessman.\n"

        "The text for Hugo Zork came from Zork I, Revision 88, Serial
        Number 840726, which is available on The Lost Treasures of
        Infocom, Volume I and also on The Classic Text Adventure
        Masterpieces of Infocom.\n"

        "Even though I built upon the work of others, any errors or
        omissions are my fault. Please direct all bug reports to
        menichel@pixi.com."

        pause
}

routine help_amuse
{
        CenterTitle("For Your Amusement")

        "Have you ever:\n"

        "\_  ...opened the grating from beneath while the leaves were still
        on it?"
        "\_  ...tried swearing at ZORK I?"
        "\_  ...waved the sceptre while standing on the rainbow?"
        "\_  ...tried anything nasty with the bodies in Hades?"
        "\_  ...burned the black book?"
        "\_  ...damaged the painting?"
        "\_  ...lit the candles with the torch?"
        "\_  ...read the matchbook?"
        "\_  ...tried to take yourself (or the Thief, Troll, or Cyclops)?"
        "\_  ...tried cutting things with the knife or sword?"
        "\_  ...poured water on something burning?"
        "\_  ...said WAIT or SCORE while dead (as a spirit)?"

        "\nPress any key for more..."

        pause

        CenterTitle("Words To Try")

        "Words you may not have tried:\n"

        "\_  HELLO (to Troll, Thief, Cyclops)"
        "\_  ZORK"
        "\_  OIL (lubricate)"
        "\_  XYZZY"
        "\_  WALK AROUND (in forest or outside house)"
        "\_  PLUGH"
        "\_  FIND (especially with house, hands, teeth, me)"
        "\_  CHOMP (or BARF)"
        "\_  COUNT (candles, leaves, matches, blessings)"
        "\_  WIN"
        "\_  MUMBLE (or SIGH)"
        "\_  LISTEN (especially to the Troll, Thief, or Cyclops)"
        "\_  REPENT"
        "\_  WHAT IS (grue, zorkmid, ...)"
        "\_  YELL (or SCREAM)"
        "\_  SMELL"

        pause
}


routine help_walkthru
{
	local m
	
        while true
	{

                menuitem[0] = "Hugo Zork Walkthru"
                menuitem[1] = "Warning! Warning!"
                menuitem[2] = "Part 1"
                menuitem[3] = "Part 2"
                menuitem[4] = "Part 3"
                menuitem[5] = "Part 4"
                menuitem[6] = "Part 5"
                menuitem[7] = "Part 6"
                menuitem[8] = "Part 7"
                menuitem[9] = "Part 8"

                m = Menu(9)
                select m
                case 1:  help_warning
                case 2:  help_part1
                case 3:  help_part2
                case 4:  help_part3
                case 5:  help_part4
                case 6:  help_part5
                case 7:  help_part6
                case 8:  help_part7
                case 9:  help_part8
                case 0:  return
        }
}

routine help_warning
{
        CenterTitle("Warning! Warning!")

        "There has been much talk on rec.games.int-fiction lately about
        whether or not hints and/or walkthrus should be included with a
        game. I am of the opinion that hints at the very least should come
        with a game."

        "\nAnyway, throwing caution to the wind, I've included this complete
        walkthru for Hugo Zork. It is divided into eight parts to make it
        easier to follow and so that less of the game is revealed at any one
        time."

        "\nThis walkthru may not work exactly as shown, because the thief
        may take some of your items."

        "\nRemember, when in doubt, save!"

        pause
}

routine help_part1
{
        CenterTitle("Walkthru - Part 1")

        "South, East\n
        Open window\n
        Enter house\n
        West\n
        Get lamp\n
        Move rug\n
        Open trap door\n
        Turn on the lamp\n
        Down, South, East\n
        Get painting\n
        North, Up, Up\n
        Get knife and rope\n
        Down, West\n
        Open case\n
        Put painting in case\n
        Drop knife\n
        Get sword\n
        Open trap door\n
        Down."

        "\nNow would be a good time to save."

        pause
}

routine help_part2
{
        CenterTitle("Walkthru - Part 2")

        "North\n
        Kill troll with sword (repeat as necessary)\n
        Drop sword\n
        East, East, Southeast, East\n
        Tie rope to railing\n
        Climb down rope\n
        South, East\n
        Get coffin\n
        West, South\n
        Pray\n
        Turn off the lamp\n
        South, North, East, Down, Down, North\n
        Open coffin\n
        Get sceptre\n
        Wave scepter\n
        Get gold and coffin\n
        Southwest, Up, Up, Northwest, West\n
        Enter house\n
        Open bag\n
        Get garlic\n
        West\n
        Put coffin, scepter, and gold in case"

        pause
}

routine help_part3
{
        CenterTitle("Walkthru - Part 3")

        "Open trap door\n
        Turn on lamp\n
        Down, North, East, North, Northeast, East, North\n
        Get matches\n
        North\n
        Get wrench and screwdriver\n
        Push yellow button\n
        South, South\n
        Turn the bolt with the wrench\n
        West, Southwest, South, South, Southeast, East\n
        Climb down rope\n
        Get the torch\n
        Turn off lamp\n
        South\n
        Get the bell\n
        South\n
        Get book and candles\n
        Down, Down\n
        Ring bell\n
        Light match\n
        Light the candles with the match\n
        Get candles\n
        Read the book\n
        Drop candles\n
        South\n
        Get skull\n
        North, Up, North\n
        Rub mirror\n
        North, West, North, West, North, East\n
        Put torch in basket\n
        Turn on lamp\n
        North, Down"

        pause
}

routine help_part4
{
         CenterTitle("Walkthru - Part 4")

        "Be careful - this maze is tricky!\n"

        "East, Northeast, Southeast, Southwest, Down, Down, South\n
        Get coal\n 
        North, Up, Up, North, East, South, North, Up, South\n
        Put coal and screwdriver in basket\n
        Lower basket\n
        North, Down, East, Northeast, Southeast, Southwest, Down, Down, West\n
        Drop all\n
        West\n
        Get coal, torch and screwdriver\n
        South\n
        Open lid\n
        Put coal into machine\n
        Close the lid\n
        Turn switch with screwdriver\n
        Opem the lid\n
        Get diamond\n
        Drop screwdriver\n
        North\n
        Put torch and diamond in the basket\n
        East\n
        Get skull, lamp and garlic\n
        East, Up, Up, North, East, South, North\n
        Get bracelet\n 
        Up, South\n
        Raise basket\n
        Get torch and diamond\n
        Turn off lamp\n
        West\n
        Get figurine\n
        South, East, South, Down, Up\n
        Put skull, diamond, figurine, bracelet and torch in case\n
        Drop garlic"

        pause
}

routine help_part5
{
        CenterTitle("Walkthru - Part 5")

        "Turn on lamp\n
        North, East, North, Northeast, North\n
        Get trunk\n
        North\n
        Get air pump\n
        North\n
        Get trident\n
        South, South, South, East, East\n
        Inflate boat with pump\n
        Drop pump\n
        Get in boat\n
        Launch\n
        \"Wait\" until you see a buoy\n
        Get buoy\n
        East\n
        Get out of boat\n
        Get shovel\n
        Northeast"

        pause
}

routine help_part6
{
        CenterTitle("Walkthru - Part 6")

        "\"Dig sand with shovel\" until the scarab appears.\n
        Drop the shovel\n
        Get scarab\n
        Southwest\n
        Drop buoy\n
        Open buoy\n
        Get emerald\n
        South, South, West, West\n
        Turn off lamp\n
        Southwest, Up, Up, Northwest, West\n
        Enter house\n
        West\n
        Put scarab, emerald, chest and trident in case\n
        East, East, North, North\n
        Climb up tree\n
        Get egg\n
        Down, South, East, West, West\n
        Turn on lamp\n
        Down, North"

        pause
}

routine help_part7
{
        CenterTitle("Walkthru - Part 7")

        "West, South, East, Up\n
        Take coins and key\n
        Southwest, East, South, Southeast\n
        Ulysses (or Odysseus)\n
        Up\n
        Give egg to thief\n
        Down, East, East\n
        Put coins in case\n
        Get knife\n
        West, West\n"

        pause
}

routine help_part8
{
        CenterTitle("Walkthru - Part 8")

        "Up\n
        \"Kill thief with knife\" until he's dead\n
        Get all\n
        Down, Northwest, South, West, Up, Down, Northeast\n
        Unlock grate\n
        Open grate\n
        Up, South\n
        Wind canary\n
        Get bauble\n
        South, East, West, West\n
        Get canary\n
        Put egg, canary and bauble in case\n
        Down, North, East, East, East\n
        Echo\n
        Get bar\n
        West, West, West, South, Up\n
        Put bar in case\n
        Get map\n
        East, East, North, West\n
        Look\n
        Southwest, West\n"

        "Congratulations! You completed Hugo Zork!"

        pause
}

!-------------------------------------------------------------------------
!     REPLACEMENT MESSAGES
!-------------------------------------------------------------------------

replace NewOMessages(obj, num, a, b)
{
        select obj

	case vehicle
	{
		select num
		case 1
		{
                         "To walk, you'll have to get ";
                         print self.prep #2;
                         " of ";
                         print The(self);
                         "."
                         return true
		}
        }
}

replace NewMessages(r, num, a, b)
{
        select r

        case &DoSuperBrief:
        {
                print "Super-brief descriptions."
                return true
        }

        case &DoVerbose:
        {
                print "Maximum verbosity."
                return true
        }
	case &DescribePlace
	{
		select num
                case 1
                {
                        print "It is pitch black. You are likely to
                               be eaten by a grue."
                        return true
                }
                case 2
                {
                        print "There"; IsorAre(a, true); " "; Art(a); \
                               " here."
                        return true
                }
	}
	case &DoLook
	{
		select num
                case 1
                {
                        print "It is pitch black. You are likely to
                               be eaten by a grue."
                        return true
                }
                case 2
                {
                        print CThe(object); " look"; MatchSubject(object); \
                              " just like you'd expect."
                        return true
                }
	}
        case &DoLookUnder
        {
                "There is nothing but dust there."
                return true
        }
        case &DoHello
        {
                local d
                d = random(4)
                select d
                case 1
                {
                        "Hello."
                        return true
                }
                case 2
                {
                        "Good day."
                        return true
                }
                case 3
                {
                        "Nice weather we've been having lately."
                        return true
                }
                case 4
                {
                        "Goodbye."
                        return true
                }
        }

	case &DoGet
	{
		select num
                case 1
                {
                        print "You already have that."
                        return true
                }
                case 2
                {
                        print "This is not progress you are making."
                        return true
                }
                case 3
                {
                        print CThe(object); " probably wouldn't be too big
				on that idea."
                        return true
                }
		case 4
		{
			print CThe(parent(object)); 
			if parent(object) is plural
				print " don't";
			else
				print " doesn't";
			print " want to give "; The(object); " to you."
                        return true
		}
                case 5
                {
                        print CThe(parent(object)); \
			IsOrAre(parent(object), true); " closed."
                        return true
                }
                case 6
                {
                        print "You can't take "; The(object); " while 
                                you're ";
                        if object.prep:  print object.prep;
                        elseif object is platform:  print "in";
                        else:  print "on";
                        if object is plural:  print " them."
                        else:  print " it."
                        return true
                }
                case 7
                {
                        local c
                        c = random(4)
                        select c
                        case 1
                        {
                                "A valiant attempt."
                        }
                        case 2
                        {
                                "You can't be serious."
                        }
                        case 3
                        {
                                "An interesting idea..."
                        }
                        case 4
                        {
                                "What a concept!"
                        }
                        return true
                }
                case 8
                {
                        print "Taken."
                        return true
                }
                case 9
                {
                        print "You're carrying too much to take that."
                        return true
                }
	}
	case &DoGo
	{
		select num
		case 1
                {
                        print CThe(obstacle); " stop"; \
			MatchSubject(obstacle); " you from going anywhere."
                        return true
                }
		case 2
                {
                        print "You can't go that way."
                        return true
                }
		case 3
		{
                        print "You'll have to get ";
                        if parent(player).prep #2
                        {
                                print parent(player).prep #2; " ";
                        }
                        else
                        {
                                print "out ";
                        }
                        print "of "; The(parent(player)); " first."
                        return true
		}
	}
}                                      

replace DarkWarning
{
        if player is ghost
        {
                DescribePlace(location)
                location is visited
                return false
        }

        "You have moved into a dark place."

	if (dark_warning = 0)
	{
		dark_warning = 1
                NewMessages(&DescribePlace, 1)
	}
        elseif random(3) = 1
	{
                "Oh, no! You have walked into the slavering fangs of
                a lurking grue!"

                NotDeadYet
	}
}

!-------------------------------------------------------------------------
!     NEW ROUTINES
!-------------------------------------------------------------------------

routine DoCount
{
        "You have lost your mind."
}

routine DoFly
{
        "You'll have to explain that one to me."
}

routine Already_done
{
        local a
        a = random(3)
        select a
        case 1
        {
                "Too late for that."
                return true
        }
        case 2
        {
                "Have your eyes checked."
                return true
        }
        case 3
        {
                "Look around."
                return true
        }
}

routine DoSailor
{
        if Contains(location, cyclops)
        {
                "The cyclops, hearing the name of his father's
                deadly nemesis, flees the room by knocking down
                the wall on the east of the room."

                remove cyclops
                wooden_door is special
                trap_door is special
                cyclops_room.threat_level = 0
                maze15.threat_level = 0
        }
        else
        {
                "Wasn't he a sailor?"
                return true
        }
}

routine DoLift
{
        "Playing in this way with ";
        print the(object);
        " has no effect."
}

routine DoEcho
{
        "echo echo ..."
        return true
}

routine JumpMessage
{
        local a
        a = random(3)
        select a
        case 1
        {
                "You should have looked before you leaped."
        }
        case 2
        {
                "In the movies, your life would be passing before your eyes."
        }
        case 3
        {
                "Geronimo..."
        }
}

routine DoTurn
{
        if not xobject
        {
                "What do you want to turn ";
                print The(object);
                " with?"
        }
        else
        {
                "You can't turn that!"
        }
}

routine DoTreasure
{
        if location = temple
        {
                MovePlayer(treasure_room)
        }
        elseif location = treasure_room
        {
                MovePlayer(temple)
        }
        else
        {
                "Nothing happens."
        }
}

routine DoTemple
{
        if location = temple
        {
                MovePlayer(treasure_room)
        }
        elseif location = treasure_room
        {
                MovePlayer(temple)
        }
        else
        {
                "Nothing happens."
        }
}

routine DoPray
{
        if location = altar_room
        {
                trap_door is special
                MovePlayer(forest1)
        }
        else
        {
                "If you pray enough, your prayers may be answered."
        }
}

routine DoZork
{
        "At your service!"
}

routine DoFool
{
        "A hollow voice says \"Fool.\""
}

routine DoChomp
{
        "Preposterous!"
}

routine DoWin
{
        "Naturally!"
}

routine DoRepent
{
        "It could very well be too late!"
}

routine CalculateRank
{
        if score = 350
                rank = 7
        elseif score > 330
                rank = 6
        elseif score > 300
                rank = 5
        elseif score > 200
                rank = 4
        elseif score > 100
                rank = 3
        elseif score > 50
                rank = 2
        elseif score > 25
                rank = 1
        else
                rank = 0
        return true
}

routine DoBug
{
       "Bug? Not in a flawless program like this! (Cough, cough)."
}

routine DoFind
{
        "You don't see any ";
        print object.noun;
        " here!"
}

routine DoMumble
{
        "You'll have to speak up if you expect me to hear you!"
}

routine DoRaise
{
        "Playing in this way with ";
        print The(object);
        " isn't notably helpful."
}

routine DoLower
{
        "Playing in this way with ";
        print The(object);
        " isn't notably helpful."
}

routine DoRing
{
        "Playing in this way with ";
        print The(object);
        " isn't notably helpful."
}

routine DoPushWith
{
        "You can't push the ";
        print The(object);
        " with ";
        print The(xobject)
}

routine DoExtinguish
{
        "You can't extinguish ";
        print The(object);
        "."
}

routine DoPump
{
        if not xobject
        {
                "What do you want to inflate ";
                print The(object);
                " with?"
        }
        else
        {
                "How can you inflate that?"
        }
}

routine DoDeflate
{
        "Come on, now!"
}

routine DoPoke
{
        if not xobject
        {
                "What do you want to puncture ";
                print The(object);
                "with?"
        }
        else
        {
                "Trying to destroy ";
                print The(object);
                " with ";
                print Art(xobject);
                " is futile."
        }
}

routine DoPatch
{
        if not xobject
        {
                "What do you want to patch ";
                print The(object);
                "with?"
        }
        else
        {
                "With ";
                print Art(xobject);
                "?"
        }
}

routine DoTooLoud
{
! Hack alert: if word[1] is "d" or "down" (such as when you move from
! the Deep Canyon to the Loud Room), the routine which moves the player
! to a random room will not work. If anyone has any idea why this is,
! *please* let me know. It's probably something stupid I overlooked,
! but it did take me 6 hours to discover this "solution".

! P.S. I also found that when word[1] is "l" or "look", the same problem
! occurs. I changed the routine to change word[1] to "e" if it wasn't
! already.

! #BeginHack

        if (word[1] = "go" or
            word[1] = "walk") and 
            word[2] ~= ""
        {
                word[1] = word[2]
        }
        if word[1] ~= "e" or
           word[1] ~= "east"
        {
                word[1] = "e"
        }

! #EndHack

        local a

        a = random(3)
        select a
        case 1
        {
                MovePlayer(round_room)
        }
        case 2
        {
                MovePlayer(damp_cave)
        }
        case 3
        {
                MovePlayer(deep_canyon)
        }
        return true
}

routine DoWind
{
        "You cannot wind up ";
        print Art(object);
        "."
}

routine DoBreakEgg
{
        egg is broken
        egg is open
        egg is moved
        egg.adjective #1 = "jewel-encrusted"
        egg.adjective #2 = "broken"
        egg.adjective #3 = "ruined"
        egg.name = "broken jewel-encrusted egg"
}

routine DoWalkOn
{
        "You can't walk on ";
        print The(object);
        "."
}

routine DoCurse
{
        if not object
        {
                "Such language in a high-class establishment like this!"
        }
        elseif object = you
        {
                "Insults of this nature won't help you."
        }
        else
        {
                "What a loony!"
        }
}

routine DoFrobozz
{
        "The FROBOZZ Corporation created, owns, and operates this
        dungeon."
}

routine DoThrowIn
{
	if not xobject
        {
                "You'll have to be a little more specific about what
		you'd like to throw ";
                print The(object); " in."
        }
	elseif xobject is not living
        {
		"What exactly are you hoping for?"
        }
	else
        {
                "You ultimately decide that throwing ";
		print The(object);
                " at ";
                print The(xobject);
		" isn't such a great idea."
        }
	return true
}

routine DoDiagnose
{
        wound_level = max_hit_points - current_hit_points
        if wound_level > 4
        {
                wound_level = 4
        }

        "You ";
        select wound_level
        case 0
        {
                "are in perfect health."
        }
        case 1
        {
                "have a light wound, ";
        }
        case 2
        {
                "have a serious wound, ";
        }
        case 3
        {
                "have several wounds, ";
        }
        case 4
        {
                "have several serious wounds, ";
        }

        if turns_to_heal > 0
        {
                "which will be cured after ";
                print number turns_to_heal;
                if turns_to_heal = 1
                {
                        " move."
                }
                else
                {
                        " moves."
                }
        }

        select current_hit_points
        case 1
        {
                "You can be killed by one more light wound."
        }
        case 2
        {
                "You can be killed by a serious wound."
        }
        case 3
        {
                "You can survive one serious wound."
        }
        case 4, 5
        {
                "You are strong enough to take several wounds."
        }

        if lives_used > 0
        {
                "You have been killed ";
                if lives_used = 1
                {
                        "once."
                }
                else
                {
                        "twice."
                }
        }
        return true
}

routine ResolveAttack(diff)
{
        local chance, roll

        select diff ! chance * 10 = % chance to hit
        case 3, 4, 5
                chance = 9
        case 0, 1, 2
                chance = 5
        case -1, -2, -3
                chance = 3
        case -3, -4, -5, -6
                chance = 1

        roll = random(10)

        if roll <= chance ! OK, now that the target is hit, what happened?
        {
                combat_result = random(6)

                if combat_result = 4
                {
                        damage = 1
                }
                elseif combat_result = 5
                {
                        damage = 2
                }
                elseif combat_result = 6
                {
                        damage = 10
                }

                ! 1 = Stun
                ! 2 = Disarm
                ! 3 = KO
                ! 4 = Light Wound
                ! 5 = Serious Wound
                ! 6 = Kill
        }
        else
        {
                combat_result = 0       ! Miss
        }
}

routine DoRead
{
        Perform(&DoLook, object)
}

routine DoLaunch
{
        local v, moveto

	if player in location
	{
		OMessage(vehicle, 2)    ! "You aren't in anything."
		return false
	}

	v = parent(player)              ! the vehicle
	if v.before:  return true

        select location
                case dam_base
                {
                        moveto = river1
                        Activate (RiverCurrent, 5)
                }
                case beach_north
                {
                        moveto = river3
                        Activate (RiverCurrent, 3)
                }
                case beach_south
                {
                        moveto = river4
                        Activate (RiverCurrent, 2)
                }
                case sandy_beach
                {
                        moveto = river4
                        Activate (RiverCurrent, 2)
                }
                case shore
                {
                        moveto = river5
                        Activate (RiverCurrent, 1)
                }
                case river1, river2, river3, river4, river5
                {
                        "You are on the river, or have you forgotten?"
                        return true
                }
                case reservoir
                {
                        "You are on the lake, or have you forgotten?"
                        return true
                }
                case stream_view
                {
                        moveto = stream
                }
                case reservoir_north
                {
                        moveto = reservoir
                }
                case reservoir_south
                {
                        moveto = reservoir
                }
                case else
                {
                        "You can't do that here."
                        return true
                }
	
	if ObjectisAttached(v, location, moveto)
		return false
	
	! Finally, the vehicle can move
	move v to moveto
	v is moved
	old_location = location
	location = moveto

	MoveAllAttachables(v, old_location, location)
	
	if not FindLight(location)
        {
		DarkWarning
        }
	else
        {
                DescribePlace(location)
		location is visited
        }
	
	run parent(player).after
	
	return true
}

routine DoLand
{
	local v, moveto

	if player in location
	{
                OMessage(vehicle, 2)    ! "You aren't in anything."
		return false
	}

	v = parent(player)              ! the vehicle
	if v.before:  return true

        if word[1] = "land"
        {
                select location
                case river1
                {
                        "The magic boat comes to rest on the shore."
                        moveto = dam_base
                }
                case river2
                {
                        "There is no safe landing spot here."
                        return true
                }
                case river3
                {
                        "The magic boat comes to rest on the shore."
                        moveto = beach_north
                }
                case river4
                {
                        "You need to specify a direction."
                        return true
                }
                case river5
                {
                        "The magic boat comes to rest on the shore."
                        moveto = shore
                }
                case stream
                {
                        "The magic boat comes to rest on the shore."
                        moveto = stream_view
                }
                case else
                {
                        "You can't go that way."
                        return true
                }
                Deactivate(RiverCurrent)
        }

	if ObjectisAttached(v, location, moveto)
		return false
	
	! Finally, the vehicle can move
	move v to moveto
	v is moved
	old_location = location
	location = moveto

	MoveAllAttachables(v, old_location, location)
	
	if not FindLight(location)
        {
		DarkWarning
        }
        else
        {
                DescribePlace(location)
		location is visited
        }
	
	run parent(player).after
	
	return true
}

routine NotDeadYet
{
        "\n\_  ****  You have died  ****"

        score -= 10
        lives_used++
        current_hit_points = max_hit_points
        turns_to_heal = 0

        if lives_used < 3 and
           altar_room is not visited
        {
                "\nNow, let's take a look here... Well, you probably
                deserve another chance. I can't quite fix you up
                completely, but you can't have everything."

                ScatterPossessions
                MovePlayer(forest1)
        }
        elseif lives_used < 3 and
           altar_room is visited
        {
                "\nAs you take your last breath, you feel relieved of your
                burdens. The feeling passes as you find yourself before
                the gates of Hell, where the spirits jeer at you and deny
                you entry. Your senses are disturbed. The objects in the
                dungeon appear indistinct, bleached of color, even unreal."

                player is ghost
                player is light
                Deactivate(ThiefDaemon)
                remove thief
                ScatterPossessions
                MovePlayer(entrance_to_hades)
        }
        else
        {
                "\nYou clearly are a suicidal maniac. We don't allow
                psychotics in the cave, since they may harm other
                adventurers. Your remains will be installed in the
                Land of the Living Dead, where your fellow adventurers
                may gloat over them."

                endflag = 3
        }
}

routine ScatterPossessions
{
        ! If the player is carrying valuable items, move them to random
        ! maze locations. Non-valuable items are scattered above ground,
        ! near the house.

        if Contains(player, lamp)
        {
                move lamp to living_room
                Perform(&DoSwitchOff, lamp)
        }

        if Contains(player, coffin)
        {
                move coffin to egyptian_room
                coffin is not open
        }

        local a, c, i, j, dest

        c = children(player)

        while c > 0
        {
                for i in player
                {
                        if i is valuable
                        {
                                a = random(7)
                                select a
                                case 1
                                {
                                        dest = maze1
                                }
                                case 2
                                {
                                        dest = maze2
                                }
                                case 3
                                {
                                        dest = maze3
                                }
                                case 4
                                {
                                        dest = maze4
                                }
                                case 5
                                {
                                        dest = maze5
                                }
                                case 6
                                {
                                        dest = dead_end1
                                }
                                case 7
                                {
                                        dest = dead_end3
                                }
                        }
                        else
                        {
                                a = random(6)
                                select a
                                case 1
                                {
                                        dest = south_of_house
                                }
                                case 2
                                {
                                        dest = behind_house
                                }
                                case 3
                                {
                                        dest = kitchen
                                }
                                case 4
                                {
                                        dest = forest_path
                                }
                                case 5
                                {
                                        dest = forest2
                                }
                                case 6
                                {
                                        dest = clearing
                                }
                        }
                        j = i
                        move j to dest
                        c--
                }
        }
}

routine DoSqueeze
{
        if object is living
        {
                print CThe(object);
                " does not understand this."
        }
        else
        {
                "How singularly useless."
        }
}

routine DoDrown
{
        "It seems that ";
        print The(object);
        " didn't agree with the boat, as evidenced by the loud hissing
        noise issuing therefrom. With a pathetic sputter, the boat deflates,
        leaving you without."

        select location

        case river1, river2, river3, river4, river5
        {
                "\nIn other words, fighting the fierce currents of the Frigid
                River. You manage to hold your own for a bit, but then you
                are carried over a waterfall and into some nasty rocks.
                Ouch!"

                NotDeadYet
        }
        case reservoir, stream
        {
                "\nAnother pathetic sputter, this time from you, heralds
                your drowning."

                NotDeadYet
        }
}

routine DoMolest
{
        "What a (ahem!) strange idea."
}

routine DoFill
{
        "There's nothing to fill ";
        print The(object);
        " with."
}

routine DoPour
{
        Perform(&DoDrop, object)
}

routine DoWalkAround
{
        if not object
        {
                "What do you want to walk around?"
        }
        elseif object = house
        {
                select location
                case west_of_house
                {
                        MovePlayer(north_of_house)
                }
                case north_of_house
                {
                        MovePlayer(behind_house)
                }
                case behind_house
                {
                        MovePlayer(south_of_house)
                }
                case south_of_house
                {
                        MovePlayer(west_of_house)
                }
        }
        elseif object = forest
        {
                select location
                case forest1
                {
                        MovePlayer(forest_path)
                }
                case forest_path
                {
                        MovePlayer(forest2)
                }
                case forest2
                {
                        MovePlayer(clearing1)
                }
                case clearing1
                {
                        MovePlayer(forest1)
                }
        }
        else
        {
                "Use compass directions for movement."
        }
}

routine DoShake
{
        if object is container and
           children(object) > 0
        {
                "It sounds like there is something inside ";
                print The(object);
                "."
        }
        elseif object is container and
           children(object) = 0
        {
                print CThe(object);
                " sounds empty."
        }
        else
        {
                "Shaken."
        }
}

routine RemoveThief(flag)
{
        local a, i, j
        self = thief

        remove self
        Deactivate(ThiefDaemon)
        self is not living
        self is unconscious
        treasure_room.threat_level = 0
        if not Contains(player, stiletto)
        {
                move stiletto to location
                stiletto is not hidden
        }
        if location = treasure_room and
           flag = 1
        {
                "As the thief dies, the power of his magic decreases, and
                his treasure reappears."
        }
        move silver_chalice to location
        for i in thiefs_bag
        {
                a++
        }
        if a > 0
        {
                "\nHis booty remains."
                while a > 0
                {
                        for i in thiefs_bag
                        {
                                j = i
                                if j = egg and
                                   egg is not broken
                                {
                                        egg is not lockable
                                        egg is open
                                        move egg to location
                                        move canary to egg
                                }
                                else
                                {
                                        move j to location
                                }
                        }
                        a--
                }
        }
        remove thiefs_bag 
        move canvas to location        
        if Contains(player, sword)
        {
                "Your sword is no longer glowing."
        }
}

routine MissMessage(enemy)
{
        local a, b
        if enemy = cyclops
        {
                a = 5
        }
        else
        {
                a = 6
        }
        b = random(a)
        select b
        case 1
        {
                print "You miss "; The(enemy); " by an inch."
        }
        case 2
        {
                print "A good slash, but it misses "; The(enemy); 
                " by a mile."
        }
        case 3
        {
                print "You charge, but "; The(enemy); " jumps nimbly aside."
        }
        case 4
        {
                print "A quick stroke, but "; The(enemy); " is on guard."
        }
        case 5
        {
                print "A good stroke, but it's too slow; "; The(enemy); 
                " dodges."
        }
        case 6
        {
                print "Clang! Crash! "; CThe(enemy); " parries."
        }
        return true
}

routine DazeMessage(enemy)
{
        local a
        a = random(5)
        select a
        case 1
        {
                print CThe(enemy);
                " is staggered, and drops to his knees."
        }
        case 2
        {
                print CThe(enemy);
                " is momentarily disoriented and can't fight back."
        }
        case 3
        {
                "The force of your blow knocks ";
                print The(enemy);
                " back, stunned."
        }
        case 4
        {
                print CThe(enemy);
                " is confused and can't fight back."
        }
        case 5
        {
                "A savage blow on the thigh! "
                print CThe(enemy);
                " is stunned but can still fight!"
        }
}

routine KnockOutMessage(enemy)
{
        local a
        a = random(3)
        select a
        case 1
        {
                print CThe(enemy);
                " is battered into unconsciousness."
        }
        case 2
        {
                "A furious exchange, and ";
                print The(enemy);
                " is knocked out!"
        }
        case 3
        {
                "The haft of your weapon knocks out ";
                print The(enemy);
                "."
        }
}

routine DisarmedMessage(enemy)
{
        local a
        a = random(2)
        select a
        case 1
        {
                "The quickness of your thrust knocks ";
                print The(enemy);
                "'s weapon to the floor, leaving him unarmed."
        }
        case 2
        {
                print CThe(enemy);
                " is disarmed by a subtle feint past his guard."
        }
}

routine MinorWoundMessage(enemy)
{
        local a
        a = random(4)
        select a
        case 1
        {
                print CThe(enemy);
                " is struck on the arm; blood begins to
                trickle down."
        }
        case 2
        {
                "Your weapon pinks ";
                print The(enemy);
                " on the wrist, but it's not serious."
        }
        case 3
        {
                "Your stroke lands, but it was only the flat of the blade."
        }
        case 4
        {
                "The blow lands, making a shallow gash in ";
                print The(enemy);
                "'s arm!"
        }
}

routine SeriousWoundMessage(enemy)
{
        local a
        a = random(3)
        select a
        case 1
        {
                print CThe(enemy);
                " receives a deep gash in his side."
        }
        case 2
        {
                "Slash! Your blow lands! That one hit an artery, it could
                be serious!"
        }
        case 3
        {
                "Slash! Your stroke connects! This could be serious!"
        }
}

routine DeadMessage(enemy)
{
        local a
        a = random(3)
        select a
        case 1
        {
                "It's curtains for ";
                print The(enemy);
                " as you remove his head."
        }
        case 2
        {
                "The fatal blow strikes ";
                print The(enemy);
                " square in the heart: He dies."
        }
        case 3
        {
                print CThe(enemy);
                " takes a fatal blow and slumps to the floor dead."
        }
}

routine DoOil
{
        if not xobject
        {
                "What do you want to oil ";
                print The(object);
                " with?"
        }
        else
        {
                "You probably put spinach in your gas tank, too."
        }
}

!-------------------------------------------------------------------------
!     REPLACEMENT ROUTINES
!-------------------------------------------------------------------------

replace DoBurn
{
        if not xobject
        {
                "What do you want to burn ";
                print The(object);
                " with?"
                return true
        }
        elseif xobject is heat_source
        {
                if object is not burnable
                {
                        "You can't burn ";
                        print Art(object);
                        "."
                }
                elseif Contains(player, object)
                {
                        print CThe(object);
                        " catches fire. Unfortunately, you were ";
                        if parent(player) = magic_boat
                        {
                                "in";
                        }
                        else
                        {
                                "holding";
                        }
                        if object is plural
                        {
                                " them";
                        }
                        else
                        {
                                " it";
                        }
                        " at the time."
                        remove object
                        object is moved
                        NotDeadYet
                }
                else
                {
                        print CThe(object);
                        " catches fire and is consumed."
                        remove object
                        object is moved
                }
        }
        else
        {
                "With ";
                print Art(xobject);
                "??!?"
        }
        return true
}

replace DoYell
{
        "Aaaarrrrgggghhhh!"
        return true
}

replace DoJump
{
        local a
        a = random(4)
        select a
        case 1
        {
                "Very good. Now you can go to the second grade."
        }
        case 2
        {
                "Are you enjoying yourself?"
        }
        case 3
        {
                "Wheeeeeeeeee!!!!!"
        }
        case 4
        {
                "Do you expect me to applaud?"
        }
        return true
}

replace PrintScore(end_of_game)
{
        if end_of_game:  print ""
        "Your score is ";
        print number score;
        " (total of ";
        print number MAX_SCORE;
        " points), in ";
        print number counter;
        if counter = 1
        {
                " move."
        }
        else
        {
                " moves."
        }
        CalculateRank
        "This gives you the rank of ";
        print ranking[rank];
        "."
}

replace DoDig
{
        if not xobject
        {
                "What do you want to dig ";
                print The(object);
                " with?"
        }
        else
        {
                "You can't dig ";
                print The(object);
                " with ";
                print The(xobject);
                "."
        }
}

replace DoSmell
{
        "It smells like ";
        print Art(object);
        "."
}

replace DoHit
{
        if player is stunned
        {
                player is not stunned
                "You are still recovering from that last blow, so your
                attack is ineffective."
                return true
        }

        elseif xobject and
           xobject ~= hands and
           not Contains(player, xobject)
        {
                "You aren't even holding ";
                print The(xobject);
                "."
                return true
        }

        if object is not living
        {
                "I've known strange people, but fighting ";
                print Art(object);
                "?"
        }
        else
        {
                if children(player) = 0 or
                   xobject = hands
                {
                        "Trying to attack ";
                        print Art(object);
                        " with your bare hands is suicidal."
                }
                elseif not xobject
                {
                        "What do you want to fight ";
                        print The(object);
                        " with?"
                }
                elseif xobject is not weapon
                {
                        "Trying to attack ";
                        print The(object);
                        " with ";
                        print Art(xobject);
                        " is suicidal."
                }
                elseif xobject is weapon
                {
                        local a, diff, target

                        CalculateRank
                        select object
                        case troll
                        {
                                a = 0
                                target = troll
                        }
                        case cyclops
                        {
                                a = 6
                                target = cyclops
                        }
                        case thief
                        {
                                a = 6
                                target = thief
                        }

                        if target is unconscious
                        {
                                "The unconscious ";
                                print target.name;
                                " cannot defend himself: He dies."
                                damage = 10
                                run target.take_damage
                                return true
                        }
                        elseif target is disarmed
                        {
                                "The unarmed ";
                                print target.name;
                                " cannot defend himself: He dies."
                                damage = 10
                                run target.take_damage
                                return true
                        }
                        else
                        {
                                target is hostile

                                if xobject = nasty_knife
                                {
                                        rank++
                                }
                                elseif xobject = stiletto
                                {
                                        rank += 2
                                }

                                diff = rank - a
                                ResolveAttack(diff)

                                select combat_result
                                case 0
                                {
                                        MissMessage(target)
                                }
                                case 1
                                {
                                        target is stunned
                                        DazeMessage(target)
                                }
                                case 2
                                {
                                        run target.no_weapon
                                }
                                case 3
                                {
                                        run target.knocked_out
                                }
                                case else
                                {
                                        run target.take_damage
                                }
                        }
                }
        }
        return true
}

replace DoCut
{
        if not xobject
        {
                "What do you want cut ";
                print The(object);
                 " with?"
        }
        else
        {
                if xobject is weapon
                {
                        "Strange concept, cutting ";
                        print The(object);
                        "."
                }
                else
                {
                        "The \"cutting edge\" of ";
                        print Art(xobject);
                        " is hardly adequate."
                }
        }
}

!----------------------------------------------------------------------------
!
!  PrintStatusline
!  Replaces the old StatusLine routine - this one prints out the words
!  "Score:" and "Moves:" on the status line
!
!  v2.4 revision by KT
!
!----------------------------------------------------------------------------

replace PrintStatusline
{
        local temp_it_obj

        temp_it_obj = it_obj

	if display.linelength < 80
		display.statusline_height = 2

	Font(BOLD_OFF | ITALIC_OFF | UNDERLINE_OFF | PROP_OFF)
	window display.statusline_height
	{
		color SL_TEXTCOLOR, SL_BGCOLOR
		cls
		locate 1, 1
		if not light_source
			print "In the dark";
		else
		{
                        print "\_";
			print capital location.name;
                        if player not in location
                        {
                                if parent(player).prep
                                        print ", "; parent(player).prep; " ";
                                else
                                        print ", "; IN_WORD; " ";
                                print Art(parent(player));
                        }
		}
		
		if display.statusline_height = 1
			print to 50;
		else
		{
			locate 2, 2
		}

                print "Score: "; number score;
		! Print to 65 or 15
                print to ((display.statusline_height = 1)*50 + 15);
                print "Moves: "; number counter;
	}
	color TEXTCOLOR, BGCOLOR
	Font(DEFAULT_FONT)
        it_obj = temp_it_obj
}

replace ParseError(errornumber, obj)
{
        if location = loud_room and
           loud_room is not special and
           errornumber = 1
        {
                print parse$;
                " ";
                print parse$;
                " ..."
                words = 0
                word[1] = ""
                return true
        }
        if location = loud_room and
           loud_room is not special and
           errornumber = 6
        {
                ". . ..."
                words = 0
                word[1] = ""
                return true
        }
	if errornumber >= 100
	{
		CustomError(errornumber, obj)
		word[1] = ""            ! force ParseError(0)
		words = 0
		customerror_flag = true
		return true
	}
	if customerror_flag
	{
		customerror_flag = 0    ! CustomError already printed error
		return true
	}
	
	select errornumber
		
		case 6
			print "That doesn't make any sense."
		
		case 9
		{
			print "Nothing to ";
			if verbroutine
				print parse$; "."
			else:  print "do."
		}
		
		case 10
		{
			print "You haven't seen ";
			if obj is living
				print "anybody";
			else:  print "anything";
			print " like that."
		}
		
		case 11
		{
			if not ObjectisKnown(obj)
				ParseError(10, obj)
			elseif obj is living
			{
				CThe(obj)
				if obj is plural
					print " aren't";
				else:  print " isn't";
				print " here."
			}
			else
			{
				print "You don't see ";
				if obj is plural
					print "those."
				else:  print "that."
			}
		}
		case 12
			print "You can't do that with "; The(obj) ; "."
		
		case 14
		{
			if xobject is living
				print CThe(xobject); \
				" doesn't have "; The(obj); "."
			else
				print "You don't see "; The(obj); " there."
		}
		
		case 15
		{
			print "You aren't holding "; 
			if obj is plural
				print "those."
			else:  print "that."
		}
		
		case else: return false         ! print the default message

	return true                             ! message already printed
}

replace DoExit
{
	local p

        if not object and
           parent(player) = magic_boat and
           location is water_location
        {
                "You realize that getting out here would be fatal."
                return true
        }

	if object = nothing or object = location
	{
		if player in location
			{word[1] = "out"
			word[2] = ""
			return Perform(&DoGo)}
	}

	p = parent(player)
  
	if object and player not in object
		Message(&DoExit, 1)             ! "You aren't in that."
	elseif p is openable, not open
		Message(&DoLookIn, 1)           ! "X is closed."
	else
	{
		if object = nothing
			object = p
		move player to location
		if not object.after
			Message(&DoExit, 2)     ! "You get out.."
	}
	return true
}

replace DoTouch
{
        "Fiddling with ";
        The(object)
        " probably isn't the best use of your time at the moment."
        return true
}

replace DoSwim
{
        if FindObject(river, location) or
           FindObject(lake, location) or
           FindObject(water_in_stream, location)
        {
                "Swimming isn't usually allowed in the dungeon."
        }
        else
        {
                "Go jump in a lake!"
        }
}

! This routine replaces "~all" with "grue" - if "~all" is passed through
! while in a dark location or while the player is a ghost, multiple
! "It's too dark to see!" or "Your hand passes through the object." messages
! will be printed; one for each object in the location. I replaced it with
! "grue" because the grue is a scenery item that is always in the player's
! location and thus can always be referred to.

replace PreParse
{
        if (not FindLight(location) or
           player is ghost) and
           word[1] ~= "drop"
        {
                if word[2] = "~all" 
                {
                        word[2] = "grue"
                }
                elseif word[3] = "~all"
                {
                        word[3] = "grue"
                }
        }
        return false
}

!----------------------------------------------------------------------------
! DescribePlace(location, [optional parameter])
! prints the location name, followed by the location description, if
! required
!
! DescribePlace(location, true)
! forces a location description
!
! This routine changes the standard Hugo routine so that the name of
! each location is not printed in bold print.
!
!----------------------------------------------------------------------------

replace DescribePlace(place, long)
{
	local obj, count, notlisted, tempformat

	! Since, for example, a room description following entering via
	! DoGo does not trigger before/after properties tied to looking 
	! around:
	!
	if verbroutine ~= &DoLookAround
	{
		if place is not visited and verbosity ~= 1
			return Perform(&DoLookAround)
		elseif long = true or verbosity = 2
			return Perform(&DoLookAround)
	}

	if not light_source
		{Message(&DescribePlace, 1)     ! "It's too dark to see..."
		return}

	place is known

	! Print the name of the location as a heading
!        Font(BOLD_ON)
	print "\n"; capital place.name;

	! Print ", in <something>" if necessary
	if location = place and player not in place
	{
		if parent(player).prep
			print ", "; parent(player).prep; " ";
		else
			print ", "; IN_WORD; " ";
		print Art(parent(player))
	}
	print newline

!        Font(BOLD_OFF)
	override_indent = false

	if place is not visited and verbosity ~= 1
	{
		if &place.initial_desc or &place.long_desc
			Indent
		if not place.initial_desc
			run place.long_desc
	}
	elseif long = true or verbosity = 2
	{
		if &place.long_desc
			Indent
		run place.long_desc
	}
	
	if &place.list_contents and FORMAT & DESCFORM_F
		print ""        ! for double-space-after-heading formatting
	
	! A location may contain an overriding listing routine, as may any
	! parent, in the list_contents property
	!
	if not place.list_contents
	{
		list_nest = 0

		! For double-space-after-heading formatting:
		if FORMAT & DESCFORM_F:
		{
			for obj in place
			{
				if obj is not hidden and 
				  (player not in obj or children(obj) > 1):
				{
					print ""
					break
				}
			}
		}

		! List contents of chair, vehicle, etc. player is in
		if player not in location
			WhatsIn(Parent(player))
			
		! List all characters, if any
		count = 0
		for obj in place
		{
			if obj is hidden or obj is not living or 
				player in obj:
				obj is already_listed
			else
			{
				obj is not already_listed
				ShortDescribe(obj)
				if obj is not already_listed
					count++
			}        
		}
		
		list_count = count
		count = 0

		if list_count           ! if characters are to be listed
		{
			tempformat = FORMAT
			FORMAT = FORMAT | FIRSTCAPITAL_F | ISORAREHERE_F
			FORMAT = FORMAT | USECHARNAMES_F
			if FORMAT & LIST_F
			{
				FORMAT = FORMAT & ~LIST_F       ! clear it
				FORMAT = FORMAT | TEMPLIST_F
			}
			Indent
			list_nest = 0
			ListObjects(place)
			FORMAT = tempformat
		}

		for obj in place
		{
#ifset USE_ATTACHABLES
			! Exclude all attachables for now (and characters)

			if obj is living or obj.type = attachable or
				player in obj
#else
			if obj is living or player in obj
#endif
				obj is already_listed
			else
				obj is not already_listed
		}
		
		for obj in place
		{
#ifset USE_PLURAL_OBJECTS
			! ...And don't list identical objects yet, either

			if (obj.identical_to).type = identical_class
			{
				if obj is not hidden
					count++
			}
			elseif player not in obj
#else
			if player not in obj
#endif
			{
				if obj is not already_listed and
					obj is not hidden:
				{
					ShortDescribe(obj)
					if obj is not already_listed
						notlisted++
				}
			}
		}

		if notlisted or count
		{
			list_count = notlisted + count
			tempformat = FORMAT
			FORMAT = FORMAT | FIRSTCAPITAL_F | ISORAREHERE_F
			if FORMAT & LIST_F
			{
				FORMAT = FORMAT & ~LIST_F       ! clear it
				FORMAT = FORMAT | TEMPLIST_F
			}
			Indent
			list_nest = 0
			ListObjects(place)
			FORMAT = tempformat
		}

#ifclear NO_OBJLIB
#ifset USE_ATTACHABLES
		for obj in place
		{
			! Print attachables last
			if obj.type = attachable and obj is not hidden
			{
				ShortDescribe(obj)
				if obj is not already_listed
					Message(&DescribePlace, obj, 2)
			}
		}
#endif

		print newline
		override_indent = false
		
		! Finally, list contents of scenery objects (unless we've
		! already done so as the parent of the player
		!
		for obj in place
		{
			if obj.type = scenery and player not in obj
				WhatsIn(obj)
		}
#endif  ! ifclear NO_OBJLIB
	
	}
}

