home *** CD-ROM | disk | FTP | other *** search
/ CD PowerPlay 6 / TheCompleteAdventureCollection1995 / CDPP6.ISO / utility / agtsrc / execsubs.pa4 < prev    next >
Encoding:
Text File  |  1989-12-20  |  57.9 KB  |  1,363 lines

  1.  
  2.   { EXECSUBS.PA2}
  3.  
  4.   FUNCTION Is_Or_Are(num : Integer) : words;
  5.   BEGIN
  6.     IF ((num >= First_noun) AND (num <= MaxNoun))
  7.     THEN Is_Or_Are := IsOrAre[N[num]^.SingOrPlur]
  8.     ELSE Is_Or_Are := 'is';
  9.   END;                            {Is_Or_Are}
  10.  
  11.   FUNCTION It_Or_Them(num : Integer) : words;
  12.   BEGIN
  13.     IF ((num >= First_noun) AND (num <= MaxNoun))
  14.     THEN It_Or_Them := ItOrThem[N[num]^.SingOrPlur]
  15.     ELSE It_Or_Them := 'it';
  16.   END;                            {Is_Or_Are}
  17.  
  18.  
  19.   { Procedure List_Exits }
  20.   { Given the room number, lists all obvious exits}
  21.  
  22.   PROCEDURE List_Exits(rm : Integer);
  23.  
  24.   VAR Dir : Direction;
  25.     ValidExit : Boolean;
  26.     TargetRoom : Integer;
  27.   BEGIN
  28.     IF LightIsHere {i.e., can see in current room} THEN
  29.       BEGIN                       {can see exits - if any here}
  30.         ValidExit := False;
  31.         FOR Dir := NORTH TO Exit DO
  32.           BEGIN
  33.             TargetRoom := Room[rm]^.Path[Dir];
  34.             IF (TargetRoom >= First_Room) AND (TargetRoom <= MaxRoom)
  35.             THEN ValidExit := True;
  36.           END;
  37.         Write(IO, 'Obvious directions: ');
  38.         IF NOT ValidExit THEN WriteLn(IO, 'NONE')
  39.         ELSE WITH Room[rm]^ DO
  40.           BEGIN
  41.             IF ((Path[NORTH] >= First_Room) AND (Path[NORTH] <= MaxRoom))
  42.             THEN Write(IO, 'north ');
  43.             IF ((Path[northwest] >= First_Room) AND (Path[northwest] <= MaxRoom))
  44.             THEN Write(IO, 'northwest ');
  45.             IF ((Path[WEST] >= First_Room) AND (Path[WEST] <= MaxRoom))
  46.             THEN Write(IO, 'west ');
  47.             IF ((Path[southwest] >= First_Room) AND (Path[southwest] <= MaxRoom))
  48.             THEN Write(IO, 'southwest ');
  49.             IF ((Path[SOUTH] >= First_Room) AND (Path[SOUTH] <= MaxRoom))
  50.             THEN Write(IO, 'south ');
  51.             IF ((Path[southeast] >= First_Room) AND (Path[southeast] <= MaxRoom))
  52.             THEN Write(IO, 'southeast ');
  53.             IF ((Path[EAST] >= First_Room) AND (Path[EAST] <= MaxRoom))
  54.             THEN Write(IO, 'east ');
  55.             IF ((Path[northeast] >= First_Room) AND (Path[northeast] <= MaxRoom))
  56.             THEN Write(IO, 'northeast ');
  57.             IF ((Path[up] >= First_Room) AND (Path[up] <= MaxRoom))
  58.             THEN Write(IO, 'up ');
  59.             IF ((Path[down] >= First_Room) AND (Path[down] <= MaxRoom))
  60.             THEN Write(IO, 'down ');
  61.             IF ((Path[enter] >= First_Room) AND (Path[enter] <= MaxRoom))
  62.             THEN Write(IO, 'enter ');
  63.             IF ((Path[Exit] >= First_Room) AND (Path[Exit] <= MaxRoom))
  64.             THEN Write(IO, 'exit ');
  65.           END;                    { with}
  66.         WriteLn(IO, ' ');
  67.       END                         {can see exits}
  68.     ELSE WriteLn(IO, 'It is too dark to see any exits!');
  69.     morecount := morecount+1;
  70.   END;                            { list_exits}
  71.  
  72.   { Procedure Help }
  73.   { (Give appropriate room HELP message)}
  74.  
  75.   PROCEDURE Help;
  76.  
  77.   VAR Help_For_Room : Integer;
  78.   BEGIN
  79.     Help_For_Room := Help_Ptr[Current_room].start;
  80.     IF Help_For_Room <= 0
  81.     THEN WriteLn(IO, 'Sorry, you''re on your own here.')
  82.     ELSE Describe_It('HELP', Current_room);
  83.   END;                            {HELP}
  84.  
  85.  
  86.   PROCEDURE Detach(num : Integer);
  87.   {Make object num's position = none,
  88.   i.e., it is no longer "in", "near", "on", etc. some other object}
  89.  
  90.   VAR i : Integer;
  91.   BEGIN
  92.     WITH N[num]^ DO
  93.       BEGIN
  94.         position := 'none';
  95.         IF SomethingPositionedNearThisNoun THEN
  96.           BEGIN
  97.             FOR i := First_noun TO MaxNoun DO
  98.               IF N[i]^.ThisNounPositionedNearNounNumber = num THEN
  99.                 BEGIN
  100.                   N[i]^.ThisNounPositionedNearNounNumber := 0;
  101.                   N[i]^.position := 'none';
  102.                 END;
  103.             SomethingPositionedNearThisNoun := False;
  104.           END;
  105.       END;                        {WITH}
  106.   END;                            {Detach}
  107.  
  108.   { Take (noun) }
  109.   { e.g., take axe or get nugget}
  110.  
  111.   PROCEDURE Take(noun : words);
  112.  
  113.   VAR num, i : Integer;
  114.     Noun_S_Adj : words;
  115.   BEGIN
  116.     num := Noun_Number(noun);
  117.     Normalize(noun);
  118.     Noun_S_Adj := Things_Adjective(num);
  119.     IF noun = 'door'
  120.     THEN IF Room[Current_room]^.locked_door
  121.       THEN WriteLn(IO, 'The door won''t budge.')
  122.       ELSE WriteLn(IO, 'The doorway won''t budge.')
  123.     ELSE IF num < First_creature THEN
  124.       BEGIN                       { if not a creature}
  125.         IF N[num]^.location = Player
  126.         THEN WriteLn(IO, 'You already have the ', Noun_S_Adj, ' ', noun, '!')
  127.         ELSE IF NOT Is_Visible(num)
  128.         THEN BEGIN
  129.           WriteLn(IO, ' ');
  130.           WriteLn(IO, 'Sorry, but there ', Is_Or_Are(num), ' no ', noun, ' here to ', Original_Verb, '.');
  131.         END
  132.         ELSE
  133.           WITH N[num]^ DO
  134.             IF NOT movable
  135.             THEN WriteLn(IO, 'Sorry, but it is impossible to ', Original_Verb, ' the ', noun, '.')
  136.             ELSE IF (weight > Max_Weight)
  137.             THEN WriteLn(IO, 'Too heavy! You aren''t strong enough to carry the ', noun, '.')
  138.             ELSE IF (size > Max_Size)
  139.             THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' far too bulky to carry.')
  140.             ELSE IF (Load_Weight+weight > Max_Weight)
  141.             THEN BEGIN
  142.               WriteLn(IO, 'You aren''t strong enough to carry your current load ');
  143.               WriteLn(IO, 'plus the ', noun, '.');
  144.             END
  145.             ELSE IF (Load_Size+size > Max_Size)
  146.             THEN WriteLn(IO, 'Your load would be too bulky to manage if you took the '
  147.                          , noun, '.')
  148.             ELSE                  { it can be taken}
  149.               BEGIN
  150.                 Adjust_Count(location, -1);
  151.                 location := Player;
  152.                 Adjust_Count(Player, 1);
  153.                 Detach(num);      {make 'position' = none}
  154.                 WriteLn(IO, 'You are now carrying the ', Noun_S_Adj, ' ', noun, '.');
  155.                 IF N[num]^.game_win THEN Room[Current_room]^.game_win := True;
  156.               END;
  157.       END                         { if not a creature}
  158.     ELSE                          { if it is a creature}
  159.       BEGIN                       { if it is a creature}
  160.         WITH M[num]^ DO
  161.           IF hostile
  162.           THEN BEGIN
  163.             WriteLn(IO, 'As you reach out to take the ', noun, ', ', Subject_IT[gender], ' ', Snarls[gender]);
  164.             WriteLn(IO, 'at you. ', Cap_Subject_IT[gender], ' doesn''t seem to want to cooperate.')
  165.           END
  166.           ELSE BEGIN
  167.             WriteLn(IO, 'As you reach for ', Object_IT[gender], ', the ', noun, ' seems happy to be touched');
  168.             WriteLn(IO, 'but as soon as ', Subject_IT[gender], ' realizes that you want to take ');
  169.             WriteLn(IO, Object_IT[gender], ', ', Subject_IT[gender], ' slips from your grasp.');
  170.           END;
  171.       END                         { if a creature}
  172.   END;                            { take}
  173.  
  174.   { Wear (noun) }
  175.   { e.g., wear armor or put on hat}
  176.  
  177.   PROCEDURE Wear(noun : words);
  178.  
  179.   VAR num, i : Integer;
  180.     Noun_S_Adj : words;
  181.   BEGIN
  182.     num := Noun_Number(noun);
  183.     Normalize(noun);
  184.     IF num < First_creature THEN
  185.       BEGIN                       { if not a creature}
  186.         Noun_S_Adj := Things_Adjective(num);
  187.         IF N[num]^.location = Wearing
  188.         THEN WriteLn(IO, 'You are already wearing the ', Noun_S_Adj, ' ', noun, '!')
  189.         ELSE IF NOT Is_Visible(num)
  190.         THEN BEGIN
  191.           WriteLn(IO, ' ');
  192.           Normalize(noun);
  193.           WriteLn(IO, 'Sorry, but there ', Is_Or_Are(num), ' no ', noun, ' here to ', Original_Verb, '.');
  194.           WriteLn(IO, ' ');
  195.         END
  196.         ELSE                      {is visible}
  197.           WITH N[num]^ DO
  198.             IF (NOT wearable)
  199.             THEN WriteLn(IO, 'Sorry, but the ', Noun_S_Adj, ' ', noun, ' can''t be worn.')
  200.             ELSE IF (NOT movable)
  201.             THEN WriteLn(IO, 'Sorry, but it is impossible to ', Original_Verb, ' the ', noun, '.')
  202.             ELSE IF (weight > Max_Weight)
  203.             THEN WriteLn(IO, 'Too heavy! You aren''t strong enough to wear the ', noun, '.')
  204.             ELSE IF (size > Max_Size)
  205.             THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' far too bulky to wear.')
  206.             ELSE IF (Load_Weight+weight > Max_Weight)
  207.             THEN BEGIN WriteLn(IO, 'You aren''t strong enough to carry your current load ');
  208.               WriteLn(IO, 'plus the ', noun, '.');
  209.             END
  210.             ELSE IF (Load_Size+size > Max_Size)
  211.             THEN WriteLn(IO, 'Your load would be too bulky to manage if you took the '
  212.                          , noun, '.')
  213.             ELSE                  { it can be taken}
  214.               BEGIN
  215.                 Adjust_Count(location, -1);
  216.                 location := Wearing;
  217.                 Adjust_Count(Wearing, 1);
  218.                 Detach(num);      {make 'position' = none}
  219.                 WriteLn(IO, 'You are now wearing the ', Noun_S_Adj, ' ', noun, '.');
  220.               END;
  221.       END                         { if not a creature}
  222.     ELSE                          { if it is a creature}
  223.       BEGIN                       { if it is a creature}
  224.         WITH M[num]^ DO
  225.           IF hostile
  226.           THEN BEGIN
  227.             WriteLn(IO, 'As you reach out to take the ', noun, ', ', Subject_IT[gender], ' ', Snarls[gender]);
  228.             WriteLn(IO, 'at you. ', Cap_Subject_IT[gender], ' doesn''t seem to want to cooperate.')
  229.           END
  230.           ELSE BEGIN
  231.             WriteLn(IO, 'As you reach for ', Object_IT[gender], ', the ', noun, ' seems happy to be touched');
  232.             WriteLn(IO, 'but as soon as ', Subject_IT[gender], ' realizes that you want to take ');
  233.             WriteLn(IO, Object_IT[gender], ', ', Subject_IT[gender], ' slips from your grasp.');
  234.           END;
  235.       END                         { if a creature}
  236.   END;                            { wear}
  237.  
  238.   { Throw (something) (at|to|in|into|inside|across something)}
  239.   { throw coin to troll or throw water at door }
  240.   { or throw coin into fountain }
  241.  
  242.   PROCEDURE Throw(noun, prep, object_word : words);
  243.  
  244.   VAR n_num, m_num, o_num : Integer;
  245.   BEGIN                           {Throw}
  246.     IF (noun = 'ALL') OR (object_word = 'ALL')
  247.     THEN WriteLn(IO, 'Not everything at once - one at a time!')
  248.     ELSE BEGIN
  249.       IF prep = ''
  250.       THEN Drop(noun)
  251.       ELSE
  252.         BEGIN
  253.           IF NOT((prep = 'AT') OR (prep = 'TO') OR (prep = 'ACROSS') OR (prep = 'IN')
  254.                  OR (prep = 'INSIDE') OR (prep = 'INTO'))
  255.           THEN WriteLn(IO, ' I don''t understand what you mean.')
  256.           ELSE IF (noun = 'ALL') OR (object_word = 'ALL')
  257.           THEN WriteLn(IO, 'Not everything at once - one at a time!')
  258.           ELSE
  259.             IF Is_Creature(object_word)
  260.             THEN
  261.               BEGIN
  262.                 n_num := Noun_Number(noun);
  263.                 m_num := Creature_Number(object_word);
  264.                 IF (location(n_num) <> Player) AND (location(n_num) <> Wearing)
  265.                 THEN BEGIN
  266.                   Normalize(noun);
  267.                   WriteLn(IO, 'You don''t have the ', noun, '.');
  268.                 END
  269.                 ELSE
  270.                   IF (M[m_num]^.location <> Current_room)
  271.                   THEN BEGIN
  272.                     Normalize(object_word);
  273.                     Normalize(prep);
  274.                     WriteLn(IO, 'Sorry, but there is no ', object_word, ' here to ', Original_Verb, ' ', prep, '.');
  275.                   END
  276.                   ELSE            { creature is here, player has noun}
  277.                     IF M[m_num]^.hostile
  278.                     THEN
  279.                       IF (M[m_num]^.weapon = n_num)
  280.                       THEN
  281.                         BEGIN
  282.                           Normalize(noun);
  283.                           Normalize(object_word);
  284.                           WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, '.');
  285.                           WriteLn(IO, 'It''s a direct hit!');
  286.                           WriteLn(IO, 'The ', object_word, ' ', Screeches[M[m_num]^.gender],
  287.                                   ' angrily and writhes in agony as');
  288.                           WriteLn(IO, Subject_IT[M[m_num]^.gender], ' fades away in a cloud of green smoke.');
  289.                           M[m_num]^.location := 0;
  290.                           Adjust_Count(N[n_num]^.location, -1);
  291.                           Adjust_Count(Current_room, 1);
  292.                           N[n_num]^.location := Current_room;
  293.                           Detach(n_num); {make 'position' = none}
  294.                         END
  295.                       ELSE        { wrong weapon thrown at hostile creature}
  296.                         BEGIN
  297.                           Normalize(noun);
  298.                           Normalize(object_word);
  299.                           WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, '.');
  300.                           WriteLn(IO, 'It''s a direct hit!');
  301.                           IF NOT N[n_num]^.drinkable
  302.                           THEN
  303.                             BEGIN
  304.                               WriteLn(IO, 'Unfortunately, the ', noun, ' merely bounces off the ', object_word,
  305.                                       '''s', ' head,');
  306.                               WriteLn(IO, 'and appears to make ', Object_IT[M[m_num]^.gender], ' quite angry.');
  307.                               Adjust_Count(N[n_num]^.location, -1);
  308.                               Adjust_Count(Current_room, 1);
  309.                               N[n_num]^.location := Current_room;
  310.                               Detach(n_num); {make 'position' = none}
  311.                               M[m_num]^.counter := M[m_num]^.counter+1;
  312.                             END
  313.                           ELSE
  314.                             BEGIN
  315.                               WriteLn(IO, 'The ', noun, ' splashes against the ', object_word, ' soaking ',
  316.                                       Object_IT[M[m_num]^.gender], ' and');
  317.                               WriteLn(IO, 'clearly angering ', Object_IT[M[m_num]^.gender], '. Although the ', noun,
  318.                                       ' evaporates quickly,');
  319.                               WriteLn(IO, 'the ', object_word, ' doesn''t seem to like you.');
  320.                               Adjust_Count(N[n_num]^.location, -1);
  321.                               N[n_num]^.location := Nowhere;
  322.                               M[m_num]^.counter := M[m_num]^.counter+1;
  323.                             END;
  324.                         END
  325.                     ELSE          { creature isn't hostile}
  326.                       IF (M[m_num]^.weapon = n_num)
  327.                       THEN
  328.                         BEGIN
  329.                           Normalize(noun);
  330.                           Normalize(object_word);
  331.                           WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, '.');
  332.                           WriteLn(IO, 'It''s a direct hit!');
  333.                           WriteLn(IO, 'The ', object_word, ' ', Screeches[M[m_num]^.gender],
  334.                                   ' and gives you a puzzled look, as if');
  335.                           WriteLn(IO, Subject_IT[M[m_num]^.gender], ' couldn''t understand why you would want to hurt ',
  336.                                   Object_IT[M[m_num]^.gender], '.');
  337.                           WriteLn(IO, Cap_Subject_IT[M[m_num]^.gender],
  338.                                   ' writhes in agony and fades away in a cloud of white smoke,');
  339.                           WriteLn(IO, 'but never seems even a bit angry; only confused, upset, and perhaps betrayed.');
  340.                           M[m_num]^.location := 0;
  341.                           Adjust_Count(N[n_num]^.location, -1);
  342.                           Adjust_Count(Current_room, 1);
  343.                           N[n_num]^.location := Current_room;
  344.                           Detach(n_num); {make 'position' = none}
  345.                         END
  346.                       ELSE        { wrong weapon thrown at friendly creature}
  347.                         IF NOT N[n_num]^.drinkable
  348.                         THEN
  349.                           BEGIN
  350.                             Normalize(noun);
  351.                             Normalize(object_word);
  352.                             WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, '.');
  353.                             WriteLn(IO, 'It''s a direct hit!');
  354.                             WriteLn(IO, 'The ', object_word, ' ', Screeches[M[m_num]^.gender],
  355.                                     ' and gives you a puzzled look,');
  356.                             WriteLn(IO, 'clearly confused by your actions. ', Cap_Subject_IT[M[m_num]^.gender],
  357.                                     ' retreats a');
  358.                             WriteLn(IO, 'few inches, watching you more carefully than before, but');
  359.                             WriteLn(IO, 'still doesn''t seem hostile.');
  360.                             Adjust_Count(N[n_num]^.location, -1);
  361.                             Adjust_Count(Current_room, 1);
  362.                             N[n_num]^.location := Current_room;
  363.                             Detach(n_num); {make 'position' = none}
  364.                           END
  365.                         ELSE
  366.                           BEGIN
  367.                             Normalize(noun);
  368.                             Normalize(object_word);
  369.                             WriteLn(IO, 'The ', noun, ' soars through the air and splashes onto the ', object_word, '.');
  370.                             WriteLn(IO, 'The ', object_word, ' shakes off the ', noun, ', which evaporates quickly.');
  371.                             WriteLn(IO, 'The ', object_word, ' seems quite puzzled by your actions, but still doesn''t');
  372.                             WriteLn(IO, 'seem hostile.');
  373.                             Adjust_Count(N[n_num]^.location, -1);
  374.                             N[n_num]^.location := Nowhere;
  375.                           END;
  376.               END                 { if Is_Creature}
  377.             ELSE                  { throw it at another noun}
  378.               BEGIN
  379.                 n_num := Noun_Number(noun);
  380.                 o_num := Noun_Number(object_word);
  381.                 Normalize(noun);
  382.                 Normalize(object_word);
  383.                 Normalize(prep);
  384.                 IF (n_num = o_num) THEN WriteLn(IO, 'Sorry, but it is impossible to ', Original_Verb,
  385.                                                 ' the ', noun, ' ', prep, ' itself!')
  386.                 ELSE
  387.                   IF (location(n_num) <> Player) AND (location(n_num) <> Wearing)
  388.                   THEN WriteLn(IO, 'You don''t have the ', noun, '.')
  389.                   ELSE IF location(o_num) <> Current_room
  390.                   THEN WriteLn(IO, 'There ', Is_Or_Are(o_num), ' no ', object_word, ' here.')
  391.                   ELSE            { object is here, player has noun}
  392.                     IF N[n_num]^.drinkable { if it's liquid, let it slosh!}
  393.                     THEN
  394.                       IF NOT N[o_num]^.open
  395.                       THEN
  396.                         BEGIN
  397.                           WriteLn(IO, 'The ', noun, ' soars through the air toward the', object_word, ', and splashes');
  398.                           WriteLn(IO, 'against ', It_Or_Them(o_num),
  399.                                   '. For a moment, everything is soaked with '
  400.                                   , noun, ',');
  401.                           WriteLn(IO, 'but the liquid quickly evaporates.');
  402.                           Adjust_Count(N[n_num]^.location, -1);
  403.                           N[n_num]^.location := Nowhere;
  404.                         END
  405.                       ELSE
  406.                         BEGIN
  407.                           WriteLn(IO, 'The ', noun, ' soars through the air toward the', object_word, ', and sloshes');
  408.                           WriteLn(IO, 'into and around ', It_Or_Them(o_num),
  409.                                   '. For a moment, everything is soaked with ', noun, ',');
  410.                           WriteLn(IO, 'but the liquid quickly evaporates.');
  411.                           Adjust_Count(N[n_num]^.location, -1);
  412.                           N[n_num]^.location := Nowhere;
  413.                         END
  414.                     ELSE          { object is here, player has noun}
  415.                       IF NOT N[o_num]^.open
  416.                       THEN
  417.                         BEGIN
  418.                           WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, ', and lands');
  419.                           WriteLn(IO, 'with a "thud" next to ', It_Or_Them(o_num), '.');
  420.                           Adjust_Count(N[n_num]^.location, -1);
  421.                           Adjust_Count(N[o_num]^.location, 1);
  422.                           N[n_num]^.location := N[o_num]^.location;
  423.                         END
  424.                       ELSE
  425.                         BEGIN
  426.                           WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, ', and lands');
  427.                           WriteLn(IO, 'in ', It_Or_Them(o_num), ' with a "thunk."');
  428.                           Adjust_Count(N[n_num]^.location, -1);
  429.                           Adjust_Count(o_num, 1);
  430.                           Detach(n_num); {make 'position' = none}
  431.                           N[n_num]^.location := o_num;
  432.                         END;
  433.               END;                { if is_creature .. else}
  434.         END;                      { if prep = '' .. else}
  435.     END;
  436.   END;                            { throw}
  437.  
  438.   { Put or Place (noun, prep, object) }
  439.   { put (something) (in|into|inside|with|near|behind|beside|by|on|under something)}
  440.   { E.G., place book in box or put jewel with treasure}
  441.  
  442.   PROCEDURE Put(noun, prep, object_word : words);
  443.  
  444.   VAR num, l : Integer;
  445.     dest, num2 : Integer;
  446.     st : words;
  447.   BEGIN                           {PUT}
  448.     IF (noun = 'ALL') OR (object_word = 'ALL')
  449.     THEN WriteLn(IO, 'Not everything at once - one at a time!')
  450.     ELSE
  451.       BEGIN
  452.         num := Noun_Number(noun);
  453.         Normalize(noun);
  454.         Normalize(prep);
  455.         Normalize(verb);
  456.         l := location(num);
  457.         IF NOT Is_Visible(num)
  458.         THEN WriteLn(IO, 'Sorry, but there ', Is_Or_Are(num), ' no ', noun, ' here.')
  459.         ELSE
  460.           IF (num >= First_noun) AND (num <= MaxNoun) AND (NOT N[num]^.movable)
  461.           THEN WriteLn(IO, 'Sorry, but it is impossible to move the ', noun, '.')
  462.           ELSE
  463.             BEGIN
  464.               IF (prep = 'in') OR (prep = 'inside') OR (prep = 'into')
  465.               THEN
  466.                 BEGIN
  467.                   dest := Noun_Number(object_word);
  468.                   l := location(dest);
  469.                   Normalize(object_word);
  470.                   IF (dest = num) THEN WriteLn(IO, 'Sorry, but it is impossible to ', Original_Verb,
  471.                                                ' the ', noun, ' ', prep, ' itself!')
  472.                   ELSE
  473.                     IF NOT Is_Visible(dest)
  474.                     THEN WriteLn(IO, 'Sorry, but there ', Is_Or_Are(dest), ' no ', object_word, ' here.')
  475.                     ELSE IF (dest >= First_creature) AND (dest <= MaxCreature)
  476.                     THEN WriteLn(IO, 'Sorry, but the ', object_word, ' won''t let you.')
  477.                     ELSE IF (num >= First_creature) AND (num <= MaxCreature)
  478.                     THEN WriteLn(IO, 'Sorry, but the ', noun, ' won''t let you.')
  479.                     ELSE IF NOT(N[dest]^.open)
  480.                     THEN
  481.                       IF NOT(N[dest]^.closable)
  482.                       THEN WriteLn(IO, 'It is impossible to ', verb, ' the ', noun, ' ', prep, ' the ', object_word)
  483.                       ELSE WriteLn(IO, 'The ', object_word, ' isn''t open!')
  484.                     ELSE          { it's open & here }
  485.                       IF N[num]^.size >= N[dest]^.size
  486.                       THEN WriteLn(IO, 'The ', noun, ' won''t fit ', prep, ' the ',
  487.                                    object_word, '!')
  488.                       ELSE
  489.                         BEGIN
  490.                           Adjust_Count(N[num]^.location, -1);
  491.                           Adjust_Count(dest, 1);
  492.                           N[num]^.location := dest;
  493.                           WriteLn(IO, 'You have put the ', noun, ' ', prep, ' the ', object_word, '.');
  494.                         END;
  495.                 END
  496.               ELSE IF (prep = 'with')
  497.               OR (prep = 'near')
  498.               OR (prep = 'behind')
  499.               OR (prep = 'beside')
  500.               OR (prep = 'on')
  501.               OR (prep = 'by')
  502.               OR (prep = 'under')
  503.               THEN
  504.                 BEGIN
  505.                   num2 := Noun_Number(object_word);
  506.                   Normalize(object_word);
  507.                   l := location(num2);
  508.                   IF (num2 = num) THEN WriteLn(IO, 'Sorry, but it is impossible to ', Original_Verb,
  509.                                                ' the ', noun, ' ', prep, ' itself!')
  510.                   ELSE
  511.                     IF l = Player THEN WriteLn(IO, 'You are carrying the ', object_word, '.')
  512.                     ELSE IF l = Wearing THEN WriteLn(IO, 'You are wearing the ', object_word, '.')
  513.                     ELSE IF NOT Is_Visible(num2)
  514.                     THEN WriteLn(IO, 'There ', Is_Or_Are(num2), ' no ', object_word, ' here!')
  515.                     ELSE IF (num2 >= First_creature) AND (num2 <= MaxCreature)
  516.                     THEN WriteLn(IO, 'Sorry, but the ', object_word, ' won''t let you.')
  517.                     ELSE IF (num >= First_creature) AND (num <= MaxCreature)
  518.                     THEN WriteLn(IO, 'Sorry, but the ', noun, ' won''t let you.')
  519.                     ELSE
  520.                       IF (N[num]^.location > MaxRoom)
  521.                       THEN
  522.                         IF (N[num]^.size+N[num2]^.size
  523.                             >= N[N[num2]^.location]^.size)
  524.                         THEN
  525.                           BEGIN
  526.                             Write(IO, 'The ', noun, ' won''t fit in the ');
  527.                             st := N[N[num2]^.location]^.name;
  528.                             Normalize(st);
  529.                             WriteLn(IO, st, ' ', prep, ' the ', object_word, '.');
  530.                           END
  531.                         ELSE
  532.                           BEGIN
  533.                             Adjust_Count(N[num]^.location, -1);
  534.                             Adjust_Count(N[num2]^.location, 1);
  535.                             N[num]^.location := N[num2]^.location;
  536.                             st := N[N[num2]^.location]^.name;
  537.                             Normalize(st);
  538.                             Write(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now');
  539.                             IF (N[num2]^.location > MaxRoom)
  540.                             THEN Write(IO, ' in the ', st);
  541.                             WriteLn(IO, ' ', prep, ' the ', object_word, '.');
  542.                           END
  543.                       ELSE
  544.                         BEGIN
  545.                           Adjust_Count(N[num]^.location, -1);
  546.                           Adjust_Count(N[num2]^.location, 1);
  547.                           N[num]^.location := N[num2]^.location;
  548.                           Write(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now');
  549.                           WriteLn(IO, ' ', prep, ' the ', object_word, '.');
  550.                           N[num]^.position := prep+' the '+object_word;
  551.                           N[num2]^.SomethingPositionedNearThisNoun := True;
  552.                           N[num]^.ThisNounPositionedNearNounNumber := num2;
  553.                         END;
  554.                 END
  555.               ELSE
  556.                 BEGIN
  557.                   syntax_error := True;
  558.                   WriteLn(IO, 'Sorry, I don''t understand what you mean.');
  559.                   WriteLn(IO, 'You need to "', Original_Verb, '" the "', noun, '" some place.');
  560.                 END;
  561.             END;
  562.       END;
  563.   END;                            { put}
  564.  
  565.   { Open_Noun (noun,prep,object_word) }
  566.   { open box or open chest with gold key}
  567.  
  568.   PROCEDURE Open_Noun(noun, prep, object_word : words);
  569.  
  570.   VAR n_num, o_num : Integer;
  571.     i : Integer; match : Boolean;
  572.     Noun_S_Adj : words;
  573.   BEGIN
  574.     IF ((noun = 'DOOR') OR (noun = 'DOORS'))
  575.     { allows user defined DOOR nouns in room}
  576.     AND (location(NounNumber) <> Current_room) THEN
  577.       BEGIN
  578.         IF NOT Room[Current_room]^.locked_door
  579.         THEN WriteLn(IO, 'Open what door? There isn''t any closed door here!')
  580.         ELSE WriteLn(IO, 'You try your best, but the door won''t open!')
  581.       END
  582.     ELSE IF (noun = 'ALL') THEN
  583.       BEGIN
  584.         match := False;
  585.         FOR i := First_noun TO MaxNoun DO
  586.           IF Is_Visible(i) AND N[i]^.closable
  587.           THEN
  588.             BEGIN
  589.               Open_Noun(N[i]^.name, prep, object_word); { Recursive}
  590.               match := True;
  591.             END;
  592.         IF NOT match THEN WriteLn(IO, 'There''s nothing here to open!');
  593.       END
  594.     ELSE                          { open a regular noun}
  595.       BEGIN
  596.         n_num := Noun_Number(noun);
  597.         o_num := Noun_Number(object_word);
  598.         Normalize(noun);
  599.         Normalize(object_word);
  600.         Noun_S_Adj := Things_Adjective(n_num);
  601.         IF (prep <> '') AND (prep <> 'WITH')
  602.         THEN WriteLn(IO, 'I''m not sure what you mean by that.')
  603.         ELSE
  604.           BEGIN
  605.             IF (NOT Is_Visible(n_num))
  606.             THEN WriteLn(IO, 'There ', Is_Or_Are(n_num), ' no ', Noun_S_Adj, ' ', noun, ' here.')
  607.             ELSE
  608.               BEGIN
  609.                 IF ((NOT Is_Visible(o_num)) AND (object_word <> ''))
  610.                 THEN WriteLn(IO, 'There ', Is_Or_Are(o_num), ' no ', object_word, ' here.')
  611.                 ELSE              { everything is here}
  612.                   IF NOT N[n_num]^.closable
  613.                   THEN
  614.                     WriteLn(IO, 'There doesn''t seem to be any way to open the ', noun, '.')
  615.                   ELSE
  616.                     IF N[n_num]^.open
  617.                     THEN WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' already open!')
  618.                     ELSE
  619.                       IF N[n_num]^.locked
  620.                       THEN
  621.                         IF prep = ''
  622.                         THEN WriteLn(IO, 'You need to unlock ', It_Or_Them(n_num), ' first!')
  623.                         ELSE
  624.                           BEGIN
  625.                             IF N[n_num]^.key <> o_num
  626.                             THEN WriteLn(IO, 'You can''t open the ', noun,
  627.                                          ' with the ', object_word, '!')
  628.                             ELSE
  629.                               BEGIN
  630.                                 N[n_num]^.locked := False;
  631.                                 N[n_num]^.open := True;
  632.                                 WriteLn(IO, 'You have opened the ', Noun_S_Adj, ' ', noun,
  633.                                         ' with the ', object_word, '.');
  634.                               END;
  635.                           END
  636.                       ELSE        { it's unlocked and openable!}
  637.                         BEGIN
  638.                           N[n_num]^.open := True;
  639.                           WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' now open.');
  640.                         END;
  641.               END;
  642.           END;
  643.       END;
  644.   END;
  645.  
  646.   { Close_Noun (noun)}
  647.   { e.g., close box }
  648.  
  649.   PROCEDURE Close_Noun(noun : words);
  650.  
  651.   VAR n_num : Integer;
  652.     i : Integer;
  653.     match : Boolean;
  654.     Noun_S_Adj : words;
  655.   BEGIN
  656.     IF (noun = 'ALL') THEN
  657.       BEGIN
  658.         match := False;
  659.         FOR i := First_noun TO MaxNoun DO
  660.           IF Is_Visible(i) AND N[i]^.closable
  661.           THEN
  662.             BEGIN
  663.               Close_Noun(N[i]^.name); { Recursive}
  664.               match := True;
  665.             END;
  666.         IF NOT match THEN WriteLn(IO, 'There''s nothing here to close!');
  667.       END
  668.     ELSE
  669.       BEGIN
  670.         n_num := Noun_Number(noun);
  671.         Noun_S_Adj := Things_Adjective(n_num);
  672.         Normalize(noun);
  673.         IF NOT Is_Visible(n_num)
  674.         THEN IF ((noun = 'door') OR (noun = 'doors'))
  675.           { allows user defined DOOR nouns in room}
  676.           AND (location(NounNumber) <> Current_room) THEN
  677.             IF (Room[Current_room]^.locked_door)
  678.             THEN WriteLn(IO, 'The door is already closed!')
  679.             ELSE WriteLn(IO, 'None of the doors here seem to be closable!')
  680.           ELSE WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' not here!')
  681.         ELSE IF NOT N[n_num]^.closable
  682.         THEN WriteLn(IO, 'The ', noun, ' can''t be closed!')
  683.         ELSE IF NOT N[n_num]^.open
  684.         THEN WriteLn(IO, 'The ', noun, ' isn''t open!')
  685.         ELSE                      { it's open, closable, and here -- so close it}
  686.           BEGIN
  687.             N[n_num]^.open := False;
  688.             WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' now closed.');
  689.           END;
  690.       END;
  691.   END;
  692.  
  693.   { Shoot (noun,prep,object) }
  694.   { (attack, fight, kill) }
  695.   { kill troll with laser or shoot laser at troll}
  696.  
  697.   PROCEDURE Shoot(noun, prep, object_word : words);
  698.  
  699.   VAR m_num, o_num : Integer;
  700.     w : words;
  701.   BEGIN
  702.     IF (noun = 'ALL') OR (object_word = 'ALL')
  703.     THEN WriteLn(IO, 'Not everything at once - one at a time!')
  704.     ELSE
  705.       BEGIN
  706.         IF prep = 'AT' THEN BEGIN
  707.           w := noun;
  708.           noun := object_word;
  709.           object_word := w;
  710.           prep := 'WITH';
  711.         END;
  712.         IF NOT Is_Creature(noun)
  713.         THEN
  714.           BEGIN
  715.             WriteLn(IO, 'It would really make more sense to specify some living');
  716.             WriteLn(IO, 'creature. Hostility really requires a target of some sort.');
  717.           END
  718.         ELSE IF ((NOT Is_Noun(object_word)) OR (Length(prep) <= 1))
  719.         THEN BEGIN
  720.           Normalize(object_word); Normalize(noun);
  721.           IF ((Length(object_word) <= 1) OR (Length(prep) <= 1))
  722.           THEN WriteLn(IO, 'You need to specify what you want to use to ',
  723.                        'shoot at the ', noun, '!')
  724.           ELSE WriteLn(IO, 'Using the ', object_word, ' to kill the ', noun,
  725.                        ' doesn''t make much sense!');
  726.         END
  727.         ELSE                      { shoot creature with noun}
  728.           BEGIN
  729.             m_num := Creature_Number(noun);
  730.             o_num := Noun_Number(object_word);
  731.             Normalize(noun); Normalize(object_word);
  732.             IF ((Length(object_word) <= 1) OR (Length(prep) <= 1))
  733.             THEN WriteLn(IO, 'You need to specify what you want to use to ',
  734.                          'shoot at the ', noun, '!')
  735.             ELSE IF ((location(o_num) <> Player) AND (location(o_num) <> Current_room))
  736.             THEN WriteLn(IO, 'Sorry, but there is no ', object_word, ' here.')
  737.             ELSE IF NOT N[o_num]^.can_shoot
  738.             THEN WriteLn(IO, 'You can''t seem to get the ', object_word, ' to shoot!')
  739.             ELSE IF N[o_num]^.num_shots < 1
  740.             THEN WriteLn(IO, 'The ', object_word, ' seems to be empty!')
  741.             ELSE IF (M[m_num]^.location <> Current_room)
  742.             THEN BEGIN
  743.               WriteLn(IO, 'There is no ', noun, ' here.');
  744.             END
  745.             ELSE                  { creature is here, player has noun}
  746.               BEGIN
  747.                 IF (location(o_num) = Current_room)
  748.                 THEN BEGIN
  749.                   WriteLn(IO, 'You reach down to get the ', object_word, '.  You fumble and almost drop it.');
  750.                   N[o_num]^.location := Player;
  751.                 END;
  752.                 IF M[m_num]^.hostile
  753.                 THEN
  754.                   IF (M[m_num]^.weapon = o_num)
  755.                   THEN
  756.                     BEGIN
  757.                       WriteLn(IO, 'You aim the ', object_word, ' at the ', noun, ' and pull the trigger.');
  758.                       WriteLn(IO, 'It''s a direct hit!');
  759.                       WriteLn(IO, 'The ', noun, ' ', Screeches[M[m_num]^.gender], ' angrily, and writhes in agony and ');
  760.                       WriteLn(IO, 'fades away in a cloud of green smoke.');
  761.                       M[m_num]^.location := 0;
  762.                       N[o_num]^.num_shots := N[o_num]^.num_shots-1;
  763.                     END
  764.                   ELSE            { wrong weapon shot at hostile creature}
  765.                     BEGIN
  766.                       Normalize(noun);
  767.                       Normalize(object_word);
  768.                       WriteLn(IO, 'You aim the ', object_word, ' at the ', noun, ' and pull the trigger.');
  769.                       WriteLn(IO, 'It''s a direct hit!');
  770.                       WriteLn(IO, 'The ', noun, ' ', Screeches[M[m_num]^.gender], ' angrily, and falls to the floor');
  771.                       WriteLn(IO, 'for a moment. Then ', Subject_IT[M[m_num]^.gender], ' leaps up and eyes you quite');
  772.                       WriteLn(IO, 'angrily. Though wounded, ', Subject_IT[M[m_num]^.gender], ' seems no less dangerous');
  773.                       WriteLn(IO, 'or hostile.');
  774.                       N[o_num]^.num_shots := N[o_num]^.num_shots-1;
  775.                       M[m_num]^.counter := M[m_num]^.counter+1;
  776.                     END
  777.                 ELSE              { creature isn't hostile}
  778.                   IF (M[m_num]^.weapon = o_num)
  779.                   THEN
  780.                     BEGIN
  781.                       WriteLn(IO, 'You aim the ', object_word, ' at the ', noun, ' and pull the trigger.');
  782.                       WriteLn(IO, 'It''s a direct hit!');
  783.                       WriteLn(IO, 'The ', noun, ' ', Screeches[M[m_num]^.gender], ' and gives you a puzzled look');
  784.                       WriteLn(IO, 'as if ', Subject_IT[M[m_num]^.gender], ' couldn''t understand why you would want');
  785.                       WriteLn(IO, 'to hurt ', Object_IT[M[m_num]^.gender], '. ', Cap_Subject_IT[M[m_num]^.gender],
  786.                               ' writhes in agony and fades away in a cloud ');
  787.                       WriteLn(IO, 'of white smoke, but never seems even a bit angry; only confused, upset,');
  788.                       WriteLn(IO, 'and perhaps betrayed.');
  789.                       M[m_num]^.location := 0;
  790.                       N[o_num]^.num_shots := N[o_num]^.num_shots-1;
  791.                     END
  792.                   ELSE            { wrong weapon shot at friendly creature}
  793.                     BEGIN
  794.                       Normalize(noun);
  795.                       Normalize(object_word);
  796.                       WriteLn(IO, 'You aim the ', object_word, ' at the ', noun, ' and pull the trigger.');
  797.                       WriteLn(IO, 'It''s a direct hit!');
  798.                       WriteLn(IO, 'The ', noun, ' is knocked back by the force of the shot, and ', Screeches[M[m_num]^.
  799.                               gender]
  800.                               );
  801.                       WriteLn(IO, 'as ', Subject_IT[M[m_num]^.gender], ' falls to the floor. After a moment,');
  802.                       WriteLn(IO, Subject_IT[M[m_num]^.gender], ' rises, wounded and confused by your unexpected actions.');
  803.                       WriteLn(IO, Cap_Subject_IT[M[m_num]^.gender],
  804.                               ' retreats a few inches, watching you more carefully than ');
  805.                       WriteLn(IO, 'before, but still doesn''t seem hostile.');
  806.                       N[o_num]^.num_shots := N[o_num]^.num_shots-1;
  807.                     END;
  808.               END;
  809.           END;
  810.       END;                        { else begin...}
  811.   END;                            { Procedure shoot}
  812.  
  813.   { Unlock (noun,prep,object) }
  814.   { unlock box with key, unlock door}
  815.  
  816.   PROCEDURE Unlock(noun, prep, object_word : words);
  817.  
  818.   VAR n_num, o_num : Integer;
  819.     i : Integer;
  820.     match : Boolean;
  821.     Noun_S_Adj : words;
  822.   BEGIN
  823.     IF (noun = 'ALL') THEN
  824.       BEGIN
  825.         match := False;
  826.         FOR i := First_noun TO MaxNoun DO
  827.           IF Is_Visible(i) AND N[i]^.lockable
  828.           THEN
  829.             BEGIN
  830.               Unlock(N[i]^.name, prep, object_word); { recursive}
  831.               match := True;
  832.             END;
  833.         IF NOT match THEN WriteLn(IO, 'There''s nothing here to unlock!');
  834.       END
  835.     ELSE
  836.       BEGIN
  837.         n_num := Noun_Number(noun);
  838.         o_num := Noun_Number(object_word);
  839.         Normalize(noun);
  840.         Normalize(object_word);
  841.         IF ((noun = 'door') OR (noun = 'doors'))
  842.         { allows user defined DOOR nouns in room}
  843.         AND (location(NounNumber) <> Current_room) THEN
  844.           IF Room[Current_room]^.locked_door
  845.           THEN WriteLn(IO, 'Nice try, but you can''t seem to unlock the door.')
  846.           ELSE WriteLn(IO, 'All the doors here are already open!')
  847.         ELSE IF (prep = '') OR (prep <> 'WITH') THEN
  848.           BEGIN
  849.             WriteLn(IO, 'What a strange request!  I really can''t figure out what you mean by that.');
  850.             WriteLn(IO, 'Perhaps, you need to specify a tool to unlock the ', noun, ' with.');
  851.             syntax_error := True;
  852.           END
  853.         ELSE
  854.           BEGIN
  855.             Noun_S_Adj := Things_Adjective(n_num);
  856.             IF (NOT Is_Visible(n_num))
  857.             THEN WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' not here.')
  858.             ELSE
  859.               IF (location(o_num) <> Player)
  860.               THEN WriteLn(IO, 'You aren''t carrying the ', object_word, '!')
  861.               ELSE                { everything is here}
  862.                 IF NOT N[n_num]^.lockable
  863.                 THEN WriteLn(IO, 'The ', noun, ' can''t be locked or unlocked!')
  864.                 ELSE
  865.                   IF NOT N[n_num]^.locked
  866.                   THEN WriteLn(IO, 'The ', noun, ' isn''t locked!')
  867.                   ELSE
  868.                     IF N[n_num]^.open
  869.                     THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(n_num), ' open. Why unlock ', It_Or_Them(n_num), '?')
  870.                     ELSE
  871.                       IF (N[n_num]^.key <> o_num)
  872.                       THEN WriteLn(IO, 'You can''t seem to unlock the ', noun,
  873.                                    ' with the ', object_word, '.')
  874.                       ELSE        { all is here, correct key}
  875.                         BEGIN
  876.                           N[n_num]^.locked := False;
  877.                           WriteLn(IO, 'You have now unlocked the ', Noun_S_Adj, ' ', noun,
  878.                                   ', using the ', object_word, '.');
  879.                         END;
  880.           END;
  881.       END;
  882.   END;                            { unlock}
  883.  
  884.   { lock (noun,prep,object) }
  885.   { lock box with brass key or lock door}
  886.  
  887.   PROCEDURE Lock(noun, prep, object_word : words);
  888.  
  889.   VAR n_num, o_num : Integer;
  890.     i : Integer;
  891.     match : Boolean;
  892.     Noun_S_Adj : words;
  893.   BEGIN
  894.     IF (noun = 'ALL') THEN
  895.       BEGIN
  896.         match := False;
  897.         FOR i := First_noun TO MaxNoun DO
  898.           IF Is_Visible(i) AND N[i]^.lockable
  899.           THEN
  900.             BEGIN
  901.               Lock(N[i]^.name, prep, object_word); { Recursive}
  902.               match := True;
  903.             END;
  904.         IF NOT match THEN WriteLn(IO, 'There''s nothing here to lock!');
  905.       END
  906.     ELSE
  907.       BEGIN
  908.         n_num := Noun_Number(noun);
  909.         o_num := Noun_Number(object_word);
  910.         Normalize(noun);
  911.         Normalize(object_word);
  912.         IF ((noun = 'door') OR (noun = 'doors'))
  913.         { allows user defined DOOR nouns in room}
  914.         AND (location(NounNumber) <> Current_room) THEN
  915.           IF Room[Current_room]^.locked_door
  916.           THEN WriteLn(IO, 'The door is already locked!')
  917.           ELSE WriteLn(IO, 'You can''t lock these doors!')
  918.         ELSE IF (prep = '') OR (prep <> 'WITH') THEN
  919.           BEGIN
  920.             WriteLn(IO, 'What a strange request!  I really can''t figure out what you mean by that.');
  921.             WriteLn(IO, 'Perhaps, you need to specify a tool to lock the ', noun, ' with.');
  922.             syntax_error := True;
  923.           END
  924.         ELSE
  925.           BEGIN
  926.             Noun_S_Adj := Things_Adjective(n_num);
  927.             IF (NOT Is_Visible(n_num))
  928.             THEN WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' not here.')
  929.             ELSE
  930.               IF (location(o_num) <> Player)
  931.               THEN WriteLn(IO, 'You aren''t carrying the ', object_word, '!')
  932.               ELSE                { everything is here}
  933.                 IF NOT N[n_num]^.lockable
  934.                 THEN WriteLn(IO, 'The ', noun, ' can''t be locked!')
  935.                 ELSE
  936.                   IF N[n_num]^.locked
  937.                   THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(n_num), ' already locked!')
  938.                   ELSE
  939.                     IF N[n_num]^.open
  940.                     THEN WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun,
  941.                                  ' has to be closed before you can lock ', It_Or_Them(n_num), '!')
  942.                     ELSE
  943.                       IF (N[n_num]^.key <> o_num)
  944.                       THEN WriteLn(IO, 'You can''t seem to lock the ', noun,
  945.                                    ' with the ', object_word, '.')
  946.                       ELSE        { all is here, correct key}
  947.                         BEGIN
  948.                           N[n_num]^.locked := True;
  949.                           WriteLn(IO, 'You have now locked the ', Noun_S_Adj, ' ', noun,
  950.                                   ' securely with the ', object_word, '.');
  951.                         END;
  952.           END;
  953.       END;
  954.   END;                            { lock}
  955.  
  956.   { Eat (noun) }
  957.   { eat the apple pie or eat all of the food}
  958.  
  959.   PROCEDURE Eat(noun : words);
  960.  
  961.   VAR n_num : Integer;
  962.     i : Integer;
  963.     match : Boolean;
  964.   BEGIN
  965.     IF (noun = 'ALL') THEN
  966.       BEGIN
  967.         match := False;
  968.         FOR i := First_noun TO MaxNoun DO
  969.           IF Is_Visible(i) AND N[i]^.edible
  970.           THEN
  971.             BEGIN
  972.               Eat(N[i]^.name);    { Recursive}
  973.               match := True;
  974.             END;
  975.         IF NOT match THEN WriteLn(IO, 'There''s nothing here to eat!');
  976.       END
  977.     ELSE
  978.       BEGIN
  979.         n_num := Noun_Number(noun);
  980.         Normalize(noun);
  981.         IF (NOT Is_Visible(n_num))
  982.         THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(n_num), ' not here to eat!')
  983.         ELSE IF ((n_num < First_noun) OR (n_num > MaxNoun))
  984.         THEN WriteLn(IO, 'Eat the ', noun, '?  You must be kidding!')
  985.         ELSE IF NOT N[n_num]^.edible
  986.         THEN WriteLn(IO, 'Eat the ', noun, '?  You must be kidding!')
  987.         ELSE Consume(noun);
  988.       END;
  989.   END;
  990.  
  991.   { Drink (noun) }
  992.   { drink the red wine, or drink all of the water}
  993.  
  994.   PROCEDURE Drink(noun : words);
  995.  
  996.   VAR n_num : Integer;
  997.     i : Integer;
  998.     match : Boolean;
  999.   BEGIN
  1000.     IF (noun = 'ALL') THEN
  1001.       BEGIN
  1002.         match := False;
  1003.         FOR i := First_noun TO MaxNoun DO
  1004.           IF Is_Visible(i) AND N[i]^.drinkable
  1005.           THEN
  1006.             BEGIN
  1007.               Drink(N[i]^.name);  { RECURSIVE}
  1008.               match := True;
  1009.             END;
  1010.         IF NOT match THEN WriteLn(IO, 'There''s nothing here to drink!');
  1011.       END
  1012.     ELSE
  1013.       BEGIN
  1014.         n_num := Noun_Number(noun);
  1015.         Normalize(noun);
  1016.         IF (NOT Is_Visible(n_num))
  1017.         THEN WriteLn(IO, 'The ', noun, 'is not here to drink.')
  1018.         ELSE IF ((n_num < First_noun) OR (n_num > MaxNoun))
  1019.         THEN WriteLn(IO, 'You must be joking about drinking the ', noun, '!')
  1020.         ELSE IF NOT N[n_num]^.drinkable
  1021.         THEN WriteLn(IO, 'You must be joking about drinking the ', noun, '!')
  1022.         ELSE Consume(noun);
  1023.       END;
  1024.   END;
  1025.  
  1026.   { Inventory }
  1027.   { displays items being carried and items being worn (if any)}
  1028.  
  1029.   PROCEDURE Inventory;
  1030.  
  1031.   VAR i : Integer;
  1032.     st : words;
  1033.   BEGIN
  1034.     IF Items_Being_Carried > 0
  1035.     THEN BEGIN
  1036.       WriteLn(IO, 'You are carrying the following:');
  1037.       FOR i := First_noun TO MaxNoun DO
  1038.         IF N[i]^.location = Player THEN
  1039.           BEGIN
  1040.             st := '  ';
  1041.             IF (N[i]^.adj <> 'NO_ADJ') THEN st := st+N[i]^.adj+' ';
  1042.             st := st+N[i]^.name;
  1043.             Normalize(st);
  1044.             WriteLn(IO, st);
  1045.             IF N[i]^.open THEN List_Contents(i, 2);
  1046.           END;
  1047.     END                           {something being carried}
  1048.     ELSE WriteLn(IO, 'You aren''t carrying anything.');
  1049.     IF Items_Being_Worn > 0
  1050.     THEN BEGIN
  1051.       WriteLn(IO, 'You are wearing the following:');
  1052.       FOR i := First_noun TO MaxNoun DO
  1053.         IF N[i]^.location = Wearing THEN
  1054.           BEGIN
  1055.             st := '  ';
  1056.             IF (N[i]^.adj <> 'NO_ADJ') THEN st := st+N[i]^.adj+' ';
  1057.             st := st+N[i]^.name;
  1058.             Normalize(st);
  1059.             WriteLn(IO, st);
  1060.             IF N[i]^.open THEN List_Contents(i, 2);
  1061.           END;
  1062.     END;                          {something being worn}
  1063.     {ELSE -- don't print anything if nothing being worn}
  1064.   END;                            { inventory}
  1065.  
  1066.   { Read (noun) }
  1067.   { read the scroll or read the cereal box}
  1068.  
  1069.   PROCEDURE Read_Noun(noun : words);
  1070.  
  1071.   VAR num : Integer;
  1072.   BEGIN
  1073.     IF (noun = 'ALL')
  1074.     THEN WriteLn(IO, 'Not everything at once - one at a time!')
  1075.     ELSE
  1076.       BEGIN
  1077.         num := Noun_Number(noun);
  1078.         IF (NOT Is_Visible(num))
  1079.         THEN
  1080.           BEGIN
  1081.             Normalize(noun);
  1082.             Write(IO, 'The ', noun, ' ', Is_Or_Are(num), ' not here --');
  1083.             WriteLn(IO, ' which makes ', It_Or_Them(num), ' difficult to read!');
  1084.           END
  1085.         ELSE
  1086.           IF NOT N[num]^.readable
  1087.           THEN BEGIN
  1088.             Normalize(noun);
  1089.             WriteLn(IO, 'It is somewhat difficult to read the ', noun,
  1090.                     '...let me try to describe ', It_Or_Them(num), '.');
  1091.             Describe(noun);
  1092.           END
  1093.           ELSE Describe_It('TEXT', num);
  1094.       END;                        { if all..else}
  1095.   END;                            { read}
  1096.  
  1097.   { Light (noun) }
  1098.   { turn on the flashlight or light the fire}
  1099.  
  1100.   PROCEDURE light(noun : words);
  1101.  
  1102.   VAR num : Integer;
  1103.   BEGIN
  1104.     {$V-} Capitalize(noun);
  1105.     num := Noun_Number(noun);
  1106.     Normalize(noun);
  1107.     {$V+} IF (num < First_noun) OR (num > MaxNoun)
  1108.     THEN WriteLn(IO, 'Sorry, I don''t know how to do that with the ', noun)
  1109.     ELSE IF NOT N[num]^.is_light
  1110.     THEN WriteLn(IO, 'Sorry, I don''t know how to do that with the ', noun)
  1111.     ELSE IF N[num]^.on
  1112.     THEN IF verb = 'LIGHT'
  1113.       THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' already lit!')
  1114.       ELSE WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' already on!')
  1115.     ELSE BEGIN
  1116.       N[num]^.on := True;
  1117.       IF verb = 'LIGHT'
  1118.       THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now lit!')
  1119.       ELSE WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now on!');
  1120.     END;
  1121.   END;                            { light}
  1122.  
  1123.   { Extinguish (noun) }
  1124.   { turn off the flashlight or extingusih the fire}
  1125.  
  1126.   PROCEDURE Extinguish(noun : words);
  1127.  
  1128.   VAR num : Integer;
  1129.   BEGIN
  1130.     {$V-} Capitalize(noun);
  1131.     num := Noun_Number(noun);
  1132.     Normalize(noun);
  1133.     {V$+} IF (num < First_noun) OR (num > MaxNoun)
  1134.     THEN WriteLn(IO, 'Sorry, I don''t know how to do that with the ', noun)
  1135.     ELSE IF NOT N[num]^.is_light
  1136.     THEN WriteLn(IO, 'Sorry, I don''t know how to do that with the ', noun)
  1137.     ELSE IF NOT N[num]^.on
  1138.     THEN IF verb = 'EXTINGUISH'
  1139.       THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' not even lit!')
  1140.       ELSE WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' not even on!')
  1141.     ELSE BEGIN
  1142.       N[num]^.on := False;
  1143.       IF verb = 'EXTINGUISH'
  1144.       THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now extinguished!')
  1145.       ELSE WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now off!');
  1146.     END;
  1147.   END;                            { light}
  1148.  
  1149.   { Quit }
  1150.   { e.g., quit the game}
  1151.  
  1152.   PROCEDURE Quit;
  1153.  
  1154.   VAR reply : s;
  1155.   BEGIN
  1156.     Write(IO, 'Are you sure you want to quit now? (y/n) ');
  1157.     reply := GetInputString;
  1158.     IF (reply = 'Y') OR (reply = 'YES')
  1159.     THEN WriteLn(IO, 'OK - quitting game.')
  1160.     ELSE verb := 'qwerty';
  1161.   END;                            { quit}
  1162.  
  1163.   { Show_score }
  1164.   { e.g., display the score}
  1165.  
  1166.   PROCEDURE show_score;
  1167.  
  1168.   VAR i, r, J, P, t : Integer;
  1169.   BEGIN
  1170.     IF player_dead THEN
  1171.       BEGIN
  1172.         WriteLn(IO, ' ');
  1173.         WriteLn(IO, '*** You are dead. ***');
  1174.         WriteLn(IO, ' ');
  1175.       END;
  1176.     IF game_won THEN
  1177.       BEGIN
  1178.         WriteLn(IO, ' ');
  1179.         WriteLn(IO, '*** Congratulations. You have won the game. ***');
  1180.         WriteLn(IO, ' ');
  1181.       END;
  1182.     i := 0;                       { number of rooms seen}
  1183.     r := 0;                       { number of defined rooms}
  1184.     FOR J := First_Room TO MaxRoom DO
  1185.       BEGIN
  1186.         IF Room[J]^.has_seen THEN i := i+1;
  1187.         IF (Room[J]^.name <> 'none') THEN r := r+1;
  1188.       END;
  1189.     WriteLn(IO, 'You have seen ', i, ' locations (out of ', r, '), in ', Num_turns, ' turns.');
  1190.     P := ScoreAdjustment;         { player's points scored -- adjusted}
  1191.     t := 0;                       { total points possible}
  1192.     FOR i := First_Room TO MaxRoom DO
  1193.       BEGIN
  1194.         IF Room[i]^.has_seen THEN P := P+Room[i]^.points;
  1195.         IF (Room[i]^.name <> 'none') THEN t := t+Room[i]^.points;
  1196.       END;
  1197.     FOR i := First_noun TO MaxNoun DO
  1198.       BEGIN                       { give points for items carried, worn, in room, or in Treasure_Room}
  1199.         IF (Is_Visible(i)) OR (location(i) = Treasure_Room) THEN P := P+N[i]^.points;
  1200.         IF (N[i]^.name <> 'none') THEN t := t+N[i]^.points;
  1201.       END;
  1202.     IF MaxCreature > 0 THEN FOR i := First_creature TO MaxCreature DO
  1203.       BEGIN                       { give points for creatures in room}
  1204.         IF Is_Visible(i) THEN P := P+M[i]^.points;
  1205.         IF (M[i]^.name <> 'none') THEN t := t+M[i]^.points;
  1206.       END;
  1207.     IF Maximum_Score > 0 THEN t := Maximum_Score; {If max score -- use it}
  1208.     WriteLn(IO, 'Your score is ', P, ' out of a possible ', t, ' points.');
  1209.     WriteLn(IO, '(This game was saved ', Num_saves, ' times and restored ',
  1210.             num_restores, ' times.)');
  1211.   END;
  1212.  
  1213.   { Function ScoreValue }
  1214.   { e.g., calculate and return the score}
  1215.  
  1216.   FUNCTION ScoreValue : Integer;
  1217.  
  1218.   VAR i, P : Integer;
  1219.   BEGIN
  1220.     P := ScoreAdjustment;         { player's points scored -- adjusted}
  1221.     FOR i := First_Room TO MaxRoom DO
  1222.       IF Room[i]^.has_seen THEN P := P+Room[i]^.points;
  1223.     FOR i := First_noun TO MaxNoun DO
  1224.       { give points for items carried, worn, in room, or in Treasure_Room}
  1225.       IF (Is_Visible(i)) OR (location(i) = Treasure_Room) THEN P := P+N[i]^.points;
  1226.     IF MaxCreature > 0 THEN FOR i := First_creature TO MaxCreature DO
  1227.       { give points for creatures in room}
  1228.       IF Is_Visible(i) THEN P := P+M[i]^.points;
  1229.     ScoreValue := P;
  1230.   END;                            {ScoreValue}
  1231.  
  1232.   { Do_Nothing}
  1233.   { i.e., wait }
  1234.  
  1235.   PROCEDURE Do_Nothing;
  1236.  
  1237.   BEGIN
  1238.     WriteLn(IO, 'Time passes...');
  1239.   END;
  1240.  
  1241.   { Scream!}
  1242.  
  1243.   PROCEDURE Scream;
  1244.  
  1245.   BEGIN
  1246.     WriteLn(IO, ' ');
  1247.     WriteLn(IO, 'YYYYAAAAAAAUUUUUUGGGGGGGHHHHHHH YAI YAI YOW! AAAAUUUUGGGHHHH!!');
  1248.     WriteLn(IO, ' ');
  1249.     WriteLn(IO, 'Your voice echoes loudly through the area, and the volume of ');
  1250.     WriteLn(IO, 'your shriek causes the very ground to vibrate. You feel much ');
  1251.     WriteLn(IO, 'better having let out some steam, but nothing else has changed.');
  1252.     WriteLn(IO, ' ');
  1253.   END;
  1254.  
  1255.   { SCRIPT }
  1256.   { Causes all output to go to both screen and printer}
  1257.  
  1258.   PROCEDURE Script;
  1259.  
  1260.     { PRTEST }
  1261.     { Turbo Pascal routines to read printer status}
  1262.  
  1263.     FUNCTION PrTest(WhichPrt : Integer) : Boolean;
  1264.     VAR reg : registers;
  1265.       i : Word;
  1266.     BEGIN
  1267.       reg.ax := $0200;
  1268.       reg.dx := WhichPrt AND $0002; { Don't Allow Greater than 2}
  1269.       INTR($17, Dos.registers(reg)); { 0 = 1st Ptr, 1 = 2nd Ptr }
  1270.       i := ((reg.ax AND $ff00) SHR 8);
  1271.   { prtest returns 8 Printer Deselected
  1272.   40 Out of Paper
  1273.   136 Printer off line
  1274.   144 All OK
  1275.   Bit Test is
  1276.   0 = Timeout
  1277.   1,2 = Unused
  1278.   3 = I/O Error
  1279.   4 = Selected
  1280.   5 = Out of Paper
  1281.   6 = Acknowledge
  1282.   7 = Not Busy}
  1283.       IF (i = 144) THEN PrTest := True
  1284.       ELSE PrTest := False;
  1285.     END;                          {PrTest}
  1286.  
  1287.   BEGIN                           {SCRIPT}
  1288.     IF PrTest(0) THEN
  1289.       BEGIN
  1290.         Scripting := True;
  1291.         WriteLn(IO, 'OK.');
  1292.       END
  1293.     ELSE WriteLn(IO, ' *** Printer is not ready to Print ***');
  1294.   END;                            {SCRIPT}
  1295.  
  1296.   { UNSCRIPT }
  1297.   { Causes all output to go to only the screen}
  1298.  
  1299.   PROCEDURE UNScript;
  1300.  
  1301.   BEGIN
  1302.     Scripting := False;
  1303.     WriteLn(IO, 'OK.');
  1304.   END;
  1305.  
  1306.   { RESURRECT }
  1307.   { Give player another chance after moving}
  1308.   { him back to the starting room }
  1309.  
  1310.   PROCEDURE Resurrect;
  1311.  
  1312.   VAR
  1313.     Answer : s;
  1314.   BEGIN
  1315.     ResurrectedFlag := False;
  1316.     WriteLn(IO, ' ');
  1317.     player_dead := False;         {resurrect player except if all lives used}
  1318.     DoingCompoundCommands := False;
  1319.     IF Current_Life = 1 THEN
  1320.       BEGIN
  1321.         WriteLn(IO, 'Oh dear, you seem to have gotten yourself killed.');
  1322.         WriteLn(IO, ' ');
  1323.         Write(IO, 'Would you like me to try to get you resurrected?.... ');
  1324.       END;
  1325.     IF (Current_Life > 1) AND (Current_Life <= Max_Lives) THEN
  1326.       BEGIN
  1327.         WriteLn(IO, 'Oh you clumsy oaf, you''ve gone and done it again!');
  1328.         WriteLn(IO, 'I don''t know how long I can keep patching you up....');
  1329.         Write(IO, 'Would you like me to try to get you resurrected again?.... ');
  1330.       END;
  1331.     IF Current_Life > Max_Lives THEN
  1332.       BEGIN
  1333.         player_dead := True;      {resurrection no longer possible}
  1334.         WriteLn(IO, 'I''m all out of orange smoke, and you''ve used all of');
  1335.         WriteLn(IO, 'your available lives. Better luck next time!');
  1336.       END
  1337.     ELSE BEGIN
  1338.       Answer := GetInputString;
  1339.       WriteLn(IO, ' ');
  1340.       IF Answer[1] IN ['Y', 'y']
  1341.       THEN BEGIN
  1342.         ResurrectedFlag := True;
  1343.         Current_Life := Current_Life+1; {used up one life}
  1344.         Current_room := Resurrection_Room; {send back to Resurrection (Starting) room}
  1345.         WriteLn(IO, 'I''ll try...but don''t blame me if something goes wr@#%&&');
  1346.         WriteLn(IO, ' ');
  1347.         WriteLn(IO, '                 ---- POOF----');
  1348.         WriteLn(IO, ' ');
  1349.         WriteLn(IO, 'You are engulfed in a cloud of thick orange smoke, and');
  1350.         WriteLn(IO, 'you emerge coughing and gasping, and find that');
  1351.         WriteLn(IO, 'you must start all over ...');
  1352.         WriteLn(IO, ' ');
  1353.         morecount := 9;
  1354.         Describe_It('ROOM_DESCR', Current_room);
  1355.       END
  1356.       ELSE BEGIN
  1357.         player_dead := True;      {resurrection no longer wanted}
  1358.         WriteLn(IO, 'OKay. If you''re so smart, do it yourself! I''m leaving!');
  1359.       END;
  1360.     END;
  1361.   END;                            {resurrent}
  1362.  
  1363.