! ----------------------------------------------------------------------------
! Odieus's Quest for the Magic Flingshot
! ----------------------------------------------------------------------------

Switches xv5;

Constant Debug;

Constant Story "ODIEUS'S QUEST FOR THE MAGIC FLINGSHOT";
Constant Headline "^A LADS adventure downloaded from CompuServe,^\
                   converted to AGT and ~embellished~ by David Malmberg^\
                   converted to Inform 5.4 by Teo Kwang Liak^^";


Include "Parser";

Constant MAX_CARRIED 6;         ! The player can carry at most 6 items


! ----------------------------------------------------------------------------
! The complete scoring system
! ----------------------------------------------------------------------------

Constant TASKS_PROVIDED;
Constant NUMBER_TASKS 10;
Global   task_scores  initial 5 5 10 10 20 10 10 10 20 40;
Constant MAX_SCORE 150;
Constant OBJECT_SCORE 2;
Constant ROOM_SCORE 2;

Include "VerbLib";


! ----------------------------------------------------------------------------
!
! Area Flung
!
! ----------------------------------------------------------------------------

Object Area_Flung "Area Flung"
 with description "This cool grassy area is where Zinness flung you. \
        Apparently you are somewhere near Blackwing's Pit. To the south \
        a glass structure glints in the sun, and a dismal cottage lies to \
        the east.",
     n_to Front_of_Pit,
     s_to Greenhouse,
     e_to Dismal_Cottage,
     w_to Statue_Room,
 has light;


! ----------------------------------------------------------------------------
!
!  Dismal Cottage
!
! ----------------------------------------------------------------------------

Object Dismal_Cottage "Dismal Cottage"
 with description
      "The cottage's interior is rather nice, actually. A heavy marble \
       table sits among ruby tiles, gold trimming lines ornate pillars, \
       and the sapphire studded ceiling is garnished with a crystal \
       chandelier.",
      name "tiles" "pillars" "sapphire" "chandelier",
      w_to Area_Flung,
      out_to Area_Flung,
 has light;

Nearby Silverware "beautiful silverware"
 with name "beautiful" "silverware" "silver" "ware" "setting",
      initial "There is a setting of beautiful silverware here.",
      description "A fine set of silverware.",
 has scored;

Nearby big_cup "big cup"
 with name "big" "cup",
      describe [;
        if (self hasnt general) "^There is an empty cup here.";
        "^You see a cup filled with water here.";
      ],
      description [;
        if (self hasnt general) "A big empty cup.";
        "A big cup that's always filled to the brim with water.";
      ],
      before [;
        Fill: if (hot_spring hasnt general)
                "Youch!! The water is so boiling hot that you can't bring \
                 the cup near it.";
              if (child(self)~=0) "You ought to empty the cup first.";
              move pond_water to big_cup;
              remove hot_spring;
              give self general;
              "The water begins to fill the cup and doesn't stop till the \
               whole pond dries up. It is amazing how the cup manage to \
               hold all that water.";
        Receive: if (self hasnt general) rfalse;
                 "The cup is already full.";
        Letgo: <<Wet player>>;
      ],
 has container open;

Nearby plate "plate"
 with short_name [;
        if (self has general) print "polished plate";
        else print "dusty plate";
        rtrue;
      ],
      initial "A dusty plate lies in a dusty corner.",
      parse_name [ i j;
        if (self has general) j='polished'; else j='dusty';
        while (NextWord()=='plate' or j) i++;
        return i;
      ],
      before [;
        Rub:  if (self has general) "It is as polished as it can be.";
              "Your best polishing effort has no effect on the dusty plate.";
      ];

Nearby Cabinet "wooden cabinet"
 with name "wooden" "cabinet",
      when_closed "A wooden cabinet is fixed to the wall. It is closed.",
      when_open [ x;
        print "The wooden cabinet has been opened. ";
        x = children(self);
        if (x == 0) "Its shelves are empty.";
        print "On its shelves ";
        if (x == 1) print "is "; else print "are ";
        x = FULLINV_BIT + ENGLISH_BIT + RECURSE_BIT;
        WriteListFrom (child(self), x, 1); print ".";
      ],
      with_key diamond_key,
 has openable container lockable openable locked static;

! --
! Contraption
! --

Object contraption "contraption" cabinet
 with name "contraption" "machine", article "some kind of a",
      description [;
        print "The contraption is made of stainless steel, has a slot \
          about six inches long, a lever is attached to it's side, and a \
          sign is pasted onto it. "; <<examine slot>>;
        ],
      before [;
        Receive:  <<Insert noun slot>>;
      ],
 has static transparent;

Nearby slot "slot"
 with name "slot",
      before [;
        Receive: if (noun~=plate) { CDefArt(noun); " does not fit the slot.";}
        Letgo:  move noun to player;
                "Taken. (You noted that the machine has done a great \
                 plate-polishing job.)";
      ],
 has container open;

Nearby sign "sign"
 with name "sign",
      description "I'm sorry, it's written in Polish.";

Nearby lever "lever"
 with name "lever" "handle",
      before [;
        Push, Pull, Turn:
          if (plate in slot && plate hasnt general) {
            give plate general;
            Achieved (1);
          }
          "That started the machine humming. A few moments later \
           it quiets down and the lever springs back to its original \
           position.";
      ];

! ----------------------------------------------------------------------------
!
! Pleasant Meadow
!
! ----------------------------------------------------------------------------

Object Pleasant_Meadow "Pleasant Meadow"
 with name "grass" "zephyrs" "yews",
      description "This is the beginning of a pleasant meadow that continues \
        to the east. Tall grass is swept with soft zephyrs, whistling through \
        the elegant yews which surround you. There is a particularly large \
        oak on your right. A glass structure glints in the sun to \
        the west.",
      e_to End_Of_Meadow,
      w_to GreenHouse,
 has light;

Nearby Dwarf "gruff-looking dwarf"
 with initial "Sitting on a nearby tree stump is a gruff-looking dwarf.",
      description "Huge fingers stroke a fiery red beard as he hums a \
        gruff tune. A double edged axe is strapped to his side.",
      each_turn [;
        if (random(5)==2) rtrue;
        if (silverware in player) "^The dwarf seems to steal glances at you \
          while you're not watching.";
         "^~HiHo, HiHo...~, hums Gruffy, the dwarf.";
      ],
      name "gruff-looking" "gruffy" "dwarf" "midget",
      life [;
        Give:  if (noun == silverware) {
                 remove silverware;
                 move axe to location;
                 remove dwarf;
                 "Giving the silverware to the dwarf must have caught \
                  his attention, since he tosses you his axe in return \
                  and walks jubiliantly away. You hear him mumble \
                  something about the ingenious financial abilities \
                  of magicians.";
               }
        Attack: "He's the one holding the axe, not you!";
        Kiss: "~Touch me and you die.~";
        Ask, Answer, Show: "The dwarf nonchantly pulls his beard.";
      ],
 has animate transparent;

Nearby oak "oak tree"
 with name "large" "huge" "oak" "tree",
      before [;
        Cut:  if (self has general) rfalse;
              if (second ~= axe) {
                print "You planned to chop the big oak with "; DefArt(second);
                "?";
              }
              give self general ~concealed;
              move oak_branch to Pleasant_Meadow;
              "The tremendous oak sways, hovers dangerously, then topples \
               to the ground with a loud CRASH.";
        Take, Push, Turn:
          if (self has general) "The oak is too heavy for your puny muscles.";
          "The oak tree is firmly rooted to the ground.";
        Letgo, Receive:
          if (self hasnt general) "The branches are beyond your reach.";
      ],
      after [;
        Letgo:  if (noun == diamond_key && noun hasnt moved) Achieved(0);
      ],
      describe [;
        if (self hasnt general) rfalse;
        "^Lying on it's side amidst the tall grass is a huge oak.";
      ],
      description [;
        if (diamond_key in self) "At the very tip of one long branch \
          dangles a diamond encrusted key!";
        "Just like any other ordinary oak tree you've encountered.";
      ],
 has static concealed supporter;

Object oak_branch "branch"
 with name "branch" "stick" "wood" "firewood" "torch" "burning" "broken",
      short_name [;
        if (self has light) print "burning torch"; else print "broken branch";
        rtrue;
      ],
      description "A thick piece of branch that was broken off from an oak \
        tree.",
      before [;
        Burn: if (location~=Grand_Hallway)
                "There is no fire to light the branch.";
              if (self has general) "The wood is already burnt up.";
              StartTimer(self, 20); give self light general;
              "Lighting the branch turns it into a handy torch. It won't last \
               long, however.";
      ],
      time_left 0,
      time_out [;
        give self ~light;
        "Your torch finally burns up.";
      ];

Object diamond_key "diamond encrusted key" oak
 with name "diamond" "encrusted" "sparkling" "key";

Object axe "double-edged axe" Dwarf
 with name "sharp" "double" "edged" "double-edged" "axe",
      describe [; "^A double-edged axe is embedded in the ground.";],
      description "A very sharp tree-chopping tool.",
 has scored;

! ----------------------------------------------------------------------------
!
! End of Meadow
!
! ----------------------------------------------------------------------------

Object End_of_Meadow "End of Meadow"
 with description "You have reached the end of the pleasant meadow that \
        started from the west. The grass over here is curiously singed at \
        the bottom.",
      before [;
        Swim:  "It is wiser to heed the sign.";
      ],
      w_to Pleasant_Meadow,
 has light;

Nearby Hot_Spring "hot spring"
 with name "hot" "bubbling" "spring" "pond" "steam",
      describe [;
        print "^There is a ";
          if (self has general) "pool of cool water here.";
        "hot spring here: bubbling violently and giving off steam.";
      ],
 has static enterable container transparent;

Nearby wooden_sign "wooden sign"
 with name "wooden" "sign" "writing" "writings",
      initial [;
        print "A large wooden sign stands besides the ";
        if (Hot_Spring has general) "pond of cool water.";
        "hot spring.";
      ],
      description "The sign reads ~D A N G E R - - - N O   S W I M M I N G~.",
 has static;

Attribute Is_liquid;

Object pond_water "water" Hot_Spring
 with name "water" "fluid" "liquid", article "some",
      description "Crystal clear, probably drinkable.",
      before [;
        Drink:  "You take a few sips and find the water refreshing.";
        Take:  "The only thing you will get is wet if you don't use a \
                container.";
        GetWith:  <<Fill second noun>>;
        Wet: "A surreal idea.";
      ],
 has is_liquid;

! ----------------------------------------------------------------------------
!
! GreenHouse
!
! ----------------------------------------------------------------------------

Object Greenhouse "Green House"
 with n_to Area_flung,
      e_to Pleasant_meadow,
      u_to 0,
      description [;
        print "The greenhouse contains a variety of exotic plants, \
          tropical greenery. In the middle of some purple-black shrubs \
          sits ";
        if (small_plant in self) print "a recently "; else print "the only ";
        "empty plot, beside which is growing a banana tree.";
      ],
  has light;

Nearby banana_tree "banana tree"
  with name "banana" "fruit" "tree",
       description [;
         if (green_bananas notin self)
           "Someone has stolen all the bananas from the tree. It is now as \
            bare as a new-born baby.";
         "It is bulging with banana clusters, all of which are as \
         hard as rock.";
       ],
       before [;
         Receive: "You can't put anything on the banana tree.";
       ],
  has scenery container open;

Nearby flat_reed "thin flat reed"
 with name "thin" "flat" "reed";

Object green_bananas "green bananas" banana_tree
 with name "green" "unripe" "banana" "bananas" "fruit" "fruits"
           "cluster" "clusters", article "some",
      describe [; "^Some green bananas are scattered around.";],
      before [;
        Eat: "Try as you might, you are unable to remove the peel.";
      ],
 has edible;

Object Small_Plant "plant"
 with short_name [;
        if (self has general) print "tall plant"; else print "small plant";
        rtrue;
      ],
      name "small" "tall" "plant" "beanstalk" "stalk",
      describe [;
        if (self has general)
          "^A tall, healthy, and bright green beanstalk stretches high into \
           the heavens. It is bursting with enormous beans and leaves, all \
           too large to handle.";
         "^There is a four-foot-high plant occupying the plot.";
      ],
      door_dir 0,
      door_to 0,
      before [;
        Wet: if (self has general)
               "I think the plant has enough water for the time being.";
             give self general door open;
             self.door_dir=u_to; self.door_to=Over_GreenHouse;
             GreenHouse.u_to= self;
             remove pond_water; give big_cup ~general;
             "The plant shudders visibly, then all of a sudden shoots up in \
              a long, green streak of leaves and zips through the ceiling. \
              You cannot see where it ends.";
        Climb: <<Go u_obj>>;
      ],
 has static door;

! ----------------------------------------------------------------------------
!
! Statue Room
!
! ----------------------------------------------------------------------------

Object Statue_Room "Statue Room"
 with e_to Area_flung,
      w_to [; if (plate in player && plate has general) {
              self.w_to=Sphinx_room;
              Achieved(2);
              print "You walk in holding the polished plate over your face. \
                The sphinx catches sight of it's own face reflected in the \
                mirror-like surface of the plate and turns to dust.^";
                return sphinx_room;
              }
              Deadflag=1;
              "^Facing you is a deadly stone guardian-sphinx. It has you \
               fixed with it's fatal stare. You recall from your college \
               lectures the result of meeting the sphinx's gaze - instant \
               stonification.";
      ],
      description "This grey area is filled with stone sculptures of \
        all types of creatures. Upon closer examination you note they \
        are extraordinarily well carved. A strange feeling you usually \
        don't get in museums comes over you.",
 has light;

Nearby warning_in_statue_room "warning sign"
 with initial "A warning sign hangs above the entrance to the west.",
      name "stone" "warning" "sign" "poster",
      description
        "The sign depicts the usual skull-and-crossed-bone sign. It is \
         carved out of stone.",
 has static;

Nearby sculptures "sculptures"
 with name "stone" "statues" "sculpture" "sculptures" "creatures"
           "statues" "statue",
      description "Too life-like to be sculpted by hands."
 has scenery;

Object Sphinx_Room "Sphinx Room"
 with e_to Statue_Room,
      out_to Statue_Room,
      w_to Guarded_Cell,
      in_to Guarded_Cell,
      description "The room you've just entered is totally bare of all \
      furniture. It is colored grey, and filled with dust.",
 has light;

Object Guarded_Cell "Guarded Cell"
 with e_to Sphinx_room,
      out_to Sphinx_room,
      description "This is a small cell whose walls are composed of a \
        massive inter-twining of trailing vines which convene above you \
        in a big tangle of leaves and ivy.",
 has light;

! ----------------------------------------------------------------------------
!
! Bean class definition
!
! ----------------------------------------------------------------------------

Attribute Is_bean;

Class  Bean_Class
 with description "You recognize them as part of the magic bean family, \
        classed by the revered magi-biologist, Jack son of Jackyl, under \
        Aurius Stawcus. Two of them have different properties, but you \
        can't remember what the properties are.",
      parse_name [ i j;
        for (::)
        {   j=NextWord();
            if (j=='bean' or 'seed' or 'pod' || j==self.name) i++;
            else
            {   if (j=='beans' or 'seeds' or 'pods')
                {   parser_action=##PluralFound; i++; }
                else return i;
            }
        }
      ],
 has is_bean;

Nearby bean1 "white bean"
class Bean_Class
 with name "white";
Nearby bean2 "green bean"
class bean_class
 with name "green",
      before [;
        Plant:  if (location~=GreenHouse && location ~=End_of_Meadow) rfalse;
                if (location==GreenHouse) {
                  remove self;
                  move small_plant to GreenHouse;
                  Achieved(4);
                  "A few seconds after planting the beans, a greenish plant \
                   emerges and struggles to a height of about four feet.";
                }
                "You threw the bean into the bubbling hot water and waited. \
                 A minute later, the water spits out the green bean which \
                 travels in a graceful arc and lands right back into your \
                 hand. Nothing else interesting has happened.";
      ];

Nearby bean3 "blue bean"
class bean_class
 with name "blue",
      description "You recognize them as part of the magic bean family, \
        classed by the revered magi-biologist, Jack son of Jackyl, under \
        Aurius Stawcus. Two of them have different properties, but you \
        can't remember what the properties are.\
        ^^The blue beans are cold to the touch.",
      before [;
        Plant:  if (location~=GreenHouse && location~=End_of_Meadow) rfalse;
                if (location==End_of_Meadow) {
                  remove self;
                  give Hot_Spring general;
                  Achieved(3);
                  "The beans sinks slowly to the bottom of the hot springs.  \
                   The bubbling recedes and at length ceases. After a while, \
                   the steam from the hot springs disappears.";
                }
                "As soon as you planted the blue bean, the temperature of the \
                 greenhouse started to fall rapidly. Somewhere an alarm \
                 sounded, and the soil spits out the blue bean which \
                 travels in a graceful arc and lands right back into your \
                 hand. Nothing else interesting has happened.";
      ];

! ----------------------------------------------------------------------------
!
! front of the Pit
!
! ----------------------------------------------------------------------------

Object Front_of_Pit "In Front of Pit"
 with s_to Area_flung,
      description "Before you, spiralling downward, lies the great black \
        maw of Blackwing's Pit.",
      n_to GorillaSub,
      d_to GorillaSub,
      has light;

[ GorillaSub;
   if (Gorilla notin Front_of_Pit) {
      move gorilla to Front_of_Pit;
     "A portly gorilla emerges from the Pit's depths and bars your way.^^\
      ~Comin' to see the old boy, eh?~ the gorilla chuckles, ~Jolly good! \
       Er - there is the small matter of a tiny fee, of course. Purely for \
       entry purposes, you understand...~ He beams good-naturedly.";
   }
   if (Gorilla hasnt general) "A hairy arm blocks your way. ~The fee, sir?~";
   return Grand_Hallway;
];

Object gorilla "stout gorilla"
 with name "stout" "gorilla" "ape" "monkey" "hairy",
      describe [;
        if (self has general)
          "^Off to one side is a happy gorilla gaping awe-stricken at a golden \
           banana.";
         "^There is a stout gorilla here, waiting expectantly.";
      ],
      description "The gorilla is covered with black fur, skin, muscles, \
        veins, and whatever else gorillas are usually covered with. Most \
        of his face is covered with a stupid grin. You assume he is stronger \
        than you are.",
      life [;
        Give: if (noun~= golden_banana)
                "The gorilla looks at your offering disdainfully. ~Surely, \
                 you can do better than that,~ he yawns.";
              move noun to self;
              give self general;
              self.each_turn=0;
              Achieved (5);
              "The gorilla's nostrils open wide. ~Umm...er...that'll do \
               nicely,~ he manages, relieving you of your fee. He stumbles \
               over to the side and stares at it, drooling in admiration.";
        Attack:  "The lost of your flingshot must have affected your brain.";
        Kiss:  "~An entry fee, sir, not a sexual favour!~";
        Answer:  if (special_word=='hello' or 'hallo' or 'hi')
                   "~A good day to you, sir.  Bought anything for me?~";
                 "The gorilla grins stupidly at you";
        Order:  "~I'm sorry but I was expelled from the obedience school \
                  the old boy has send me. I wasn't good at following orders, \
                  you see.~";
      ],
      each_turn [ i;
        if (self has general) rtrue;
        if (random(3)~=1) rtrue;
        print "^The gorilla ";
          i=random(3); if (i==1) "picks his teeth.";
          if (i==2) "scratches his armpits.";
          "absentmindedly searches for fleas in his fur.";
      ],
 has animate transparent;

!-----------------------------------------------------------------------------
!
! Grand Hallway
!
!-----------------------------------------------------------------------------

Object Grand_Hallway "Grand Hallway"
 with n_to Dining_Room,
      e_to Hex_Room,
      w_to Taxedermist_shop,
      u_to Front_of_Pit,
      description "You are standing in the grand hallway of the Pit. \
        Faint light comes from an opening above you. Large open doorways \
        beckon from three sides. A fireplace burns behind you.",
  has light;

Nearby Fireplace "fireplace"
 with name "fire" "fireplace",
      description "The fire is blazing brightly. It warms the room cheerfully.",
 has scenery;

Nearby threaded_object "threaded object"
 with name "threaded" "object",
      description "The object is about one inch long, round, one inch in \
        diameter, and threaded at one end.";

! ----------------------------------------------------------------------------
!
! Taxedermist Shop
!
! ----------------------------------------------------------------------------

Object Taxedermist_Shop "Taxedermist Shop"
 with e_to Grand_Hallway,
      out_to Grand_Hallway,
      description "This appears to be a taxedermist display area. Stuffed \
        creatures abound everywhere with plaques marking them below.",
      name "bulbs" "flourescent" "bulb" "creatures" "stuffed",
 has light;

Nearby Plaques "plaques"
 with name "plaques" "plaque",
      description "All written in Latin and you cannot understand a word of it.",
 has scenery;

Nearby bird "bird"
 with name "sleeping" "bird",
      initial "Oddly enough, there is a bird here who is very much alive. \
        It is sleeping.",
      description "The bird has a long beak, blue-green feathers, and sharp \
        talons. It is presently asleep.",
      before [;
        WakeOther:
          if (location==taxedermist_shop)
            "The bird wakes up, finds itself in familiar surroundings, and \
             goes back to sleep again.";
          move self to taxedermist_shop; give self ~moved;
          "With a deafening SKRAKIT, the bird spreads its wings and \
           flies away.^";
        Take: if (self hasnt animate) rfalse;
             give self ~animate;
             <Take self>;
             give self animate; rtrue;
      ],
      after [;
        Drop:  <<WakeOther bird>>;
      ],
 has animate;

Object Dining_Room "Dining Room"
 with s_to Grand_Hallway,
      e_to Living_Room,
      w_to [; StartTimer(lions,5); return Den;],
      n_to 0,
      after [;
        Go:  if (noun~=e_obj || fur_coat has worn) rfalse;
             StopTimer(lions);
             if (player has light) print
               "^The lions chase you out of the den but go no further...^";
      ],
      description [;
        print "An oval table and satin seats mark this room as the \
          dining room. The exits to the east and west are labeled, \
          respectively, living room and den. ";
        if (brass_ring has general)
          "A section of the wall has opened to reveal a closet \
           to the north."; else new_line;
      ],
      name "table" "seats" "satin" "oval";

Nearby brass_ring "brass ring"
 with name "brass" "ring",
      initial "A brass ring is attached to the east wall.",
      before [;
        Pull, Push, Take: "It resists your attempts to move it. Maybe you \
                          should twist it.";
        Turn:  if (self has general) {
                 give self ~general;
                 Dining_Room.n_to=0;
                 "The section of the wall slides smoothly close and the \
                  closet disappears from view.";
               }
               give self general;
               Dining_Room.n_to=Elevator;
               Achieved(7);
               "A section of the wall slides smoothly open. There is now a \
                closet to the north.";
      ],
 has static;

! ----------------------------------------------------------------------------
!
! Den
!
! ----------------------------------------------------------------------------

Object Den "Den (of Lions)"
 with e_to Dining_Room,
      ne_to [; if (fur_coat has worn) return Behind_Den;
               "I'm afraid you'll have to get past the lions first";] ,
      description "This is obviously the den. A family of lions \
        are presently occupying the room. Behind them to the northeast is an \
        open doorway.",
      each_turn [;
        if (fur_coat has worn || location~=Den) StopTimer(lions);
        if (player hasnt light) "^You hear the blood curdling growls of \
          some creatures.";
        if (fur_coat hasnt worn)
          "^The lions growl hungrily.";
      ],
      before [;
        Blow:  if (noun~=magic_horn || flat_reed notin magic_horn) rfalse;
               "Whoever said that ~Music sooths the savage beast~ obviously \
                didn't know about these lions. They stare at you in \
                disbelief as you blow your silly little horn.";
        Wear:  if (noun~=fur_coat) rfalse;
               StopTimer(lions);
               print "The lions stop growling.^";
        Disrobe:  if (noun~=fur_coat) rfalse;
                  DeadFlag=1;
                  "^Removing your fur coat is a big mistake. The lions soon \
                   realised that they have been tricked. The only consolation \
                   is that your death is swift.";
      ];

Nearby Lions "lions"
 with name "lions" "beasts" "lion" "beast" "lioness" "cub" "cubs",
      article "a pack of",
      describe [;
        if (fur_coat has worn)
          "^A pack of lions are flattened against the wall, staring at you \
            with much fear.";
        "^The ferocious-looking lions are glaring at you for disturbing them.";
      ],
      description [;
        if (fur_coat has worn)
          "The lions seem to hold the wearer of the fur coat in awe. In \
           fact they looked terrified.";
        "They seem ready to tear you to pieces any time.";
      ],
      time_left 0,
      time_out [;
        DeadFlag=1;
        if (player has light) print "^The lions "; else print "^The unknown \
          creatures ";
        "decided that they cannot wait any longer. What follows \
         is a little gruesome, let's say it involves some screaming and a \
         bit of bloodshed. One thing is for sure:";
      ],
      life [;
        Show: if (fur_coat has worn) "The lions back off in fear.";
              if (noun==fur_coat)
                "The lions frown as if they vaguely recognised the fur coat. \
                 The frown was soon dispelld by growls as hunger overrules \
                 the attempts to think.";
              print "The lions look at ";DefArt(noun);" hungrily.";
        Attack:  if (fur_coat has worn)
                   "They back off in fright, leaving you clear passage to \
                    the doorway.";
                 "The lions will tear you to shreds. Definitely.";
        ThrowAt: if (fur_coat has worn) "Leave the frightened kittens alone, \
                  you big bully!";
                 "There are too many lions to be dealt with by one throw.";
        Kiss:  if (fur_coat has worn) "Don't push your luck.";
               "Losing your head, aren't you?";
        Order:  "These lions are definitely not circus-trained.";
        Give:  if (fur_coat has worn) "The lions back off in fear.";
               "It is doubtful that the lions will appreciate your \
                show of generosity.";
      ],
 has animate;

! ----------------------------------------------------------------------------
!
! Living Room
!
! ----------------------------------------------------------------------------

Object Living_Room "Living Room"
 with w_to Dining_Room,
      description [;
        print
          "This is the living room. It is rather strange, since \
          everything here seems to be alive. The chairs are singing, the \
          lamp fixture is sweeping the carpet, and the air conditioner is ";
          if (oak_branch has light) {
            if (oak_branch in self || oak_branch in player) "coughing from your \
              torch's smoke."
          }
          "wheezing from a asthma attack.";
      ],
      before [;
        Blow:
          if (talking_door has open || noun~=magic_horn || flat_reed notin magic_horn)
            rfalse;
          give talking_door open;
          self.n_to=talking_door;
          "The door's black mood is suddenly replaced by a cheerful \
           one. ~Trying to get through?~ it observes, ~my pleasure.~ \
           It opens wide.";
      ],
      n_to "You interrupted a conversation going on between the door \
        and the window. That made the door quite furious, and I doubt \
        he'll let you through.",;

Nearby talking_door "door"
 with name "talking" "door",
      initial "To the north, a door is hob-knobing with the fixtures.",
      door_to power_room,
      door_dir n_to,
 has door talkable static;

Nearby musical_chair "musical chair"
 with name "musical" "chair" "chairs",
      description "It seems to be a musical chair, since it is participating \
        in a chorus of other chair-voices.",
 has scenery animate;

Nearby Air_conditioner "air-conditioner"
 with name "air" "con" "air-con" "air-conditioner" "conditioner",
      description "Seems to be in poor health.",
 has scenery;

Nearby Lamp_fixture "lamp fixture"
 with name "lamp" "fixture",
      description "A rather diligent fellow.",
 has scenery;

Nearby magic_horn "magic horn"
 with name "magic" "horn" "musical" "instrument" "Quatikus" "music",
      describe [; "^Someone left a black horn on the floor.";],
      description "The lovely black horn comes from the goat species \
        Quatikus, and, if fitted with the proper reed, it supposedly will \
        calm all anger and sooth savage beasts.",
      before [;
        Receive: if (noun==flat_reed) rfalse;
                 "Only a reed can fit into the horn.";
        Blow: if (flat_reed notin self) "~Pzzt!~";
              "As you play the horn, you feel a sense of calm over you.";
      ],
 has container open;

! ----------------------------------------------------------------------------
!
! Power Room
!
! ----------------------------------------------------------------------------

Object Power_Room "Power Room"
 with s_to Living_Room,
      out_to Living_Room,
      description [;
        print "This area appears to be the power source for the entire \
          Pit complex. Pipes and wires are strewn about, and there is a \
          series of holes on the far end, all occupied";
          if (self hasnt general) " save one."; else ".";
      ];

Nearby power_hole "hole"
 with name "hole" "holes",
      description [;
        if (self hasnt transparent) {
          print "About an inch in diameter. It ";
          if (child(self)==0) "is empty.";
          print "contains ";DefArt(child(self));".";
        }
        "All the holes are occupied.";
      ],
      capacity 1,
      after [;
        Receive: if (noun~= threaded_object) rfalse;
                 give self transparent ~container ~open;
                 give power_room general;
                 give player light;
                 Achieved(6);
                 "The object is a perfect fit. In fact, it seems to be \
                  stuck in the hole. And, oh yes, the entire room has \
                  lighted up.";
      ],
 has container open scenery;

! ----------------------------------------------------------------------------
!
! Behind Den
!
! ----------------------------------------------------------------------------

Object Behind_Den "Behind Den (of Lions)"
 with sw_to Den,
      out_to Den,
      description "You are behind the den of lions. Whatever they were \
        placed there to guard must have already been removed, as there \
        doesn't seem to be anything of value about.",
 has scored;

Nearby paper "crumbled paper"
 with name "crumbled" "paper", article "a piece of",
      description "Someone has scribbled something on it: ~All keys grow \
        on trees.";

! ----------------------------------------------------------------------------
!
! Elevator
!
! ----------------------------------------------------------------------------

Object Elevator "Elevator (cum closet)"
 with s_to Dining_Room,
      out_to Dining_Room,
      n_to 0,
      description "You are in a tight closet, presumably the elevator. \
        A red button is on the wall.",
 has light;

Nearby red_button "red button"
 with name "red" "button",
      description "Big, red button. Designed to be pushed.",
      before [;
        Push:  if (elevator has general) {
                 give elevator ~general;
                 elevator.s_to=Dining_Room;
                 elevator.n_to=0;
                 elevator.out_to=Dining_Room;
               };
               else {
                 give elevator general;
                 elevator.s_to=0;
                 elevator.n_to=Large_Cavern;
                 elevator.out_to=Large_Cavern;
               };
               "The door closes and you feel yourself moving for a few \
                minutes. Then the door slides open again.";
      ],
 has scenery;

Nearby fur_coat "expensive fur coat"
 with name "expensive" "fur" "coat", article "an",
      initial "A coat has been carelessly discarded on the floor.",
      description "Oh my, a fur coat sewn from an entire lion skin.",
 has clothing scored;

! ----------------------------------------------------------------------------
!
! Large Cavern
!
! ----------------------------------------------------------------------------

Object Large_Cavern "Large Cavern"
 with s_to Elevator,
      d_to 0,
      cant_go [;
        if (self has general)
          "You explore the rest of the cavern, carefully avoiding the \
           30 feet radius that contains the giant, but find no other \
           exit.";
        "You explore the rest of the cavern but find no other exit";
      ],
      description "This is a tremendous cavern. There is a stifling \
        stench in the air. The elevator is back south.",
      before [;
        Drop, WakeOther:  if (noun==bird) give self general;
        Smell:  "A disgusting idea.";
      ],
      after [;
        Go:  if (oak_branch hasnt light) rfalse;
             give oak_branch ~light;
             StopTimer(oak_branch);
             print "^As you enter the cavern, a strong draft smelling of \
              beer blows out your torch...^";
      ];

Nearby Giant "tall giant"
 with name "tall" "wide" "deep" "giant" "socks" "sock",
      initial "A 20 feet tall, wide and deep giant is snoring gratingly \
        over here.",
      each_turn [;
        if (large_cavern hasnt general) rtrue;
        remove self;
        move flight_of_stairs to large_cavern;
        large_cavern.d_to=flight_of_stairs;
        Achieved(8);
        "The eyes of the giant open wide. Then, upon catching sight of \
         you, they open wider. Wildy and speechlessly gesticulating in \
         horror, it bounds to its feet and scrambles bellowing out of \
         the room.\
         ^^As the dust settles, you see a flight of stairs that was \
         covered by the giant.";
      ],
      description "A 20 foot tall, wide and deep giant is snoring gratingly \
        over here. At every breath you are consumed by a fog of beer-black \
        breath. In addition to his breath, his socks give off an odor that \
        almost knocks YOUR socks off.",
      before [;
        if (Action==##Examine) rfalse;
        "I wouldn't go within ten feet of those socks if I were you. \
         You could die from the stench.";
      ],
 has animate;

Object Flight_of_Stairs "stairs"
 with name "flight" "stairs" "staircase" "steps",
      initial "A flight of stairs plunges downward.",
      before [;
        Climb:  <<go self>>;
      ],
      door_dir d_to,
      door_to Staircase,
 has static door open;

! ----------------------------------------------------------------------------
!
! Staircase
!
! ----------------------------------------------------------------------------

Object Staircase "Staircase"
 with u_to Large_Cavern,
      d_to [; if (keyholes has general) {
                Deadflag=2;
                "This is Blackwing's safe. Buried among his various \
                 treasures is your precious flingshot. You grab the \
                 flingshot (with a fair helping to some spoils) and fling \
                 yourself back home.";
              }
              return 0;
      ],
      description "This is the bottom of the rickety staircase.";

Nearby keyholes "keyholes"
 with name "keyholes" "holes" "keyhole" "hole",
      initial "Before you stands a wooden wall, studded with many large \
        keyholes.",
      description " The keyholes run from bottom to top, and are \
        extraordinarily big.",
      before [;
        Receive:
          if (noun~=green_bananas) "The keyholes are of the wrong size.";
          give self general;
        Letgo: give self ~general;
      ],
      after [;
        Receive: Achieved (9);
                 "The bananas are now in the holes. I know this is \
                  difficult to believe, but the bananas acted as a key \
                  and caused a secret passageway to open revealing a \
                  staircase leading downward.";
        Letgo: "The secret passageway disappears.";
      ],
 has static container open;

! ----------------------------------------------------------------------------
!
! Hex Room
!
! ----------------------------------------------------------------------------
Object Hex_Room "Hex Room"
 with w_to Grand_Hallway,
      out_to Grand_Hallway,
      description "This room is shaped like a hexagon. It is colored red, \
        the overhead lights are shattered, and the floor has a colorful \
        mosiac.";

! ----------------------------------------------------------------------------
!
! Over the greenhouse
!
! ----------------------------------------------------------------------------

Object Over_Greenhouse "Above the Greenhouse"
 with d_to Greenhouse,
      u_to On_Cloud,
      cant_go "You're on a beanstalk! You can only go up or down this \
               gigantic plant.",
      description "You are about one quarter up the tall beanstalk, and \
        200 feet above the greenhouse."
 has light;

Object On_Cloud "On Cloud"
 with d_to Over_GreenHouse,
      cant_go "Down is more likely.",
      description "This is where the tall beanstalk thins out. Only the tip \
        emerges amongst the fluffy white clouds. It is rather \
        silent up here.",
 has light;

Nearby golden_banana "golden banana"
 with name "golden" "banana" "fruit",
      initial "There is a golden banana here, glistening in the light.",
      description "Pure gold. Clouds may not have a silver lining but they \
                   sure have golden bananas.",
      before [;
        Eat: "You almost broke your tooth: this banana is made of gold.";
      ],
 has edible scored;

Object Middle_Stalk "beanstalk"
 with name "beanstalk" "plant" "tall",
      found_in over_greenhouse on_cloud,
      Before [;
        climb: "Just say ~up~ or ~down~ will do.";
        cut: "It is prudent not to cut the plant that you're on.";
      ],
 has scenery;

! ----------------------------------------------------------------------------
!
! Initialise and miscellaneous routines
!
! ----------------------------------------------------------------------------

[ Initialise;
 location = Area_Flung;
 print "^^^^^INTRODUCTION\
       ^    You are Odieus, son of Odielle of the ancient Winwood family. \
       Coming from a long line of sorcerors and enchantresses, you \
       naturally undertook the presevation of your ancestric traditions. \
       In Oxvord you majored in casting spells and you received you Phd in \
       Effective Cursing and Spell Flinging.\
       ^    Just two zifs ago, your bitter archenemy Blackwing son of \
       Blackfeather has deviously contrived to seperate you from the most \
       important instrument of your field - your magic flingshot. Being an \
       expert Filcher, he has successfully executed his evil designs. But \
       you don't panic, you keep calm. Only after scrambling through the \
       village yelling at the top of your lungs and frantically \
       searching through every nook and cranny for a clue, do you finally \
       decide to consult your friend and fellow Flinger, Zinness son of \
       Zinnesess.\
       ^    Having reclined liesurely on his plush velvet sofa and chatted \
       comfortably for about half a zif, he advises you to pursue Blackwing \
       and obtain eternal vengeance. You bravely undertake the mission and \
       declare your absolute confidence, but oddly you can't stand up since \
       your knees are shaking too much. When you recover, Zinness takes you \
       into his flingroom and transports you somewhere near Blackwing's \
       abode; that is, the Pit.^^";
];

[ PrintTaskName ach;
 if (ach==0)  "retrieving the diamond key";
 if (ach==1)  "polishing the plate";
 if (ach==2)  "turning the sphinx into dust";
 if (ach==3)  "cooling the hot spring";
 if (ach==4)  "planting beanstalk";
 if (ach==5)  "bribing the gorilla";
 if (ach==6)  "restoring the power";
 if (ach==7)  "discovering the secret elevator";
 if (ach==8)  "waking the giant";
 if (ach==9)  "opening Blackwing's safe";
];

[ PrintRank;
 print ", earning you the rank of ";

 if (score >= 150)  "Enchanter.";
 if (score >= 100)  "Master Flinger.";
 if (score >= 70)  "Effective Curser.";
 if (score >= 50)  "charlatan.";
 if (score >= 10)  "amateur magician.";
 "a Filcher.";
];

! ----------------------------------------------------------------------------
!
! The Grammar and its extensions
!
! ----------------------------------------------------------------------------

[ PlantSub;
 "I wouldn't consider this a suitable place to start your agricultural \
  experiments. Perhaps some other place where the environment is friendlier.";
];

[ WetSub;
 print "You will only get ";DefArt(noun); " wet.";
];

[ WetOnSub;
 <<Wet second noun>>;
];

[ GetWithSub;
 <Take noun>;
 "Frankly, your bare hands will do the job.";
];

Include "Grammar";

Verb "play"
      * held                                    -> Blow;
Verb "bury" "plant"
      * Is_bean                                 -> Plant;
Verb "water"
      * noun "with" Is_liquid                   -> Wet;
Verb "pour"
      * Is_liquid "on" noun                     -> WetOn;

Extend "cut" replace
      * noun "with" held                        -> Cut;
Extend "fill" replace
      * container "with" Is_liquid              -> Fill;
Extend "screw" last
      * held "in" noun                          -> Insert;
Extend "get" last
      * noun "with" container                   -> GetWith;
end;