home *** CD-ROM | disk | FTP | other *** search
/ CD PowerPlay 6 / TheCompleteAdventureCollection1995 / CDPP6.ISO / utility / agtsrc / init.pa3 < prev    next >
Encoding:
Text File  |  1989-12-19  |  33.7 KB  |  851 lines

  1.  
  2.   {INIT.PA2}
  3.  
  4.   PROCEDURE PAD(VAR sentence : s);
  5.   CONST
  6.     Blanks = '                                                                                ';
  7.   VAR
  8.     LongLine : String[255];
  9.   BEGIN
  10.     LongLine := sentence+Blanks;
  11.     sentence := Copy(LongLine, 1, 79);
  12.   END;
  13.  
  14.  
  15.   FUNCTION NOT_END(sentence : s) : Boolean;
  16.     {Returns YES if sentence does not begin with END_ or end_}
  17.   BEGIN
  18.     sentence := Copy(sentence, 1, 4);
  19.     Capitalize(sentence);
  20.     IF sentence = 'END_'
  21.     THEN NOT_END := False
  22.     ELSE NOT_END := True;
  23.   END;                            {NOT_END}
  24.  
  25.  
  26.   { Initialize }
  27.   {Initialize the noun and creature arrays; }
  28.   {also initialize player data and locate the }
  29.   {the player in room 2 or STARTING_ROOM value.}
  30.  
  31.   {Initialize Part 1}
  32.   PROCEDURE Initialize_Part1;
  33.     {all variables are global to INITIALIZE}
  34.   VAR i, vv : Integer;
  35.     sentence, TopSen, InSen : s;
  36.     st : words;
  37.     Dir : Direction;
  38.   BEGIN
  39.     {initialize_part1}
  40.     Word_Chars := ['0'..'9', 'A'..'Z', 'a'..'z', '-', '_'];
  41.     Skip_A_Line := True;
  42.     player_dead := False;
  43.     Current_Life := 1;
  44.     Num_turns := 0;
  45.     Num_saves := 0; num_restores := 0;
  46.     verbose := True;              {default is to describe every room}
  47.     game_won := False;
  48.     game_end := False;
  49.     Treasure_Room := 3000;
  50.     Maximum_Score := 0;
  51.     Resurrection_Room := 2;
  52.     Max_Lives := 3;
  53.     FOR i := 0 TO MaxCounter DO counter[i] := 0; {zero counters}
  54.     FOR i := 0 TO MaxVariable DO Variable[i] := 0; {zero variable}
  55.     FOR i := 0 TO MaxFlag DO Flag[i] := False; {make all flags FALSE}
  56.     FOR i := 0 TO MaxQuestion DO
  57.       BEGIN
  58.         Question[i] := 'NONE';
  59.         Answer[i] := 'NONE';
  60.       END;
  61.     QuestionStatus := False;
  62.     FOR i := 0 TO Last_Creature DO
  63.       BEGIN
  64.         StartingIndex[i] := MaxCommand+10; {used for index sequential search}
  65.         EndingIndex[i] := -1;
  66.       END;                        { for i := 0 to num_verbs }
  67.  
  68.     Subject_IT[Thing] := 'it';    {Subject pronouns for Creature = Thing}
  69.     Cap_Subject_IT[Thing] := 'It';
  70.     Object_IT[Thing] := 'it';
  71.     Snarls[Thing] := 'snarls';    {verbs for Creature = Thing}
  72.     Screeches[Thing] := 'screeches';
  73.     Subject_IT[Man] := 'he';      {Subject pronouns for Creature = Man}
  74.     Cap_Subject_IT[Man] := 'He';
  75.     Object_IT[Man] := 'him';
  76.     Snarls[Man] := 'scowls';      {verbs for Creature = Man}
  77.     Screeches[Man] := 'screams';
  78.     Subject_IT[Woman] := 'she';   {Subject pronouns for Creature = Woman}
  79.     Cap_Subject_IT[Woman] := 'She';
  80.     Object_IT[Woman] := 'her';
  81.     Snarls[Woman] := 'scowls';    {verbs for Creature = Woman}
  82.     Screeches[Woman] := 'screams';
  83.     IsOrAre[Singular] := 'is';
  84.     IsOrAre[Plural] := 'are';
  85.     ItOrThem[Singular] := 'it';
  86.     ItOrThem[Plural] := 'them';
  87.  
  88.     {zero out the room information}
  89.     Current_room := First_Room;   {start off in first room (as default)}
  90.     Starting_room := First_Room;  {default}
  91.     FOR i := First_Room TO Last_Room DO
  92.       BEGIN
  93.         New(Room[i]);             {must create space in heap}
  94.         WITH Room[i]^ DO
  95.           BEGIN
  96.             name := 'none';
  97.             Replaced_Word := 'none'; {Room Synonyms}
  98.             Replacing_Words := 'none';
  99.             FOR Dir := NORTH TO Exit DO Path[Dir] := 0;
  100.             special := 0;
  101.             has_seen := False;
  102.             locked_door := False;
  103.             key := 0;
  104.             light := 0;
  105.             points := 0;
  106.             nouns_inside := 0;
  107.             game_end := False;
  108.             game_win := False;
  109.             player_dead := False;
  110.           END;
  111.         Room_Ptr[i].start := -1;
  112.         Room_Ptr[i].len := 0;
  113.         Help_Ptr[i].start := -1;  {Room Helps}
  114.         Help_Ptr[i].len := 0;
  115.         Special_Ptr[i].start := -1;
  116.         Special_Ptr[i].len := 0;
  117.       END;                        {for i := first_room..last_room}
  118.  
  119.     Intro_Ptr.start := -1;
  120.     Intro_Ptr.len := 0;
  121.  
  122.     {now zero-out the message information}
  123.     FOR i := First_Message TO Last_Message DO
  124.       BEGIN
  125.         Message_Ptr[i].start := -1; {Messages}
  126.         Message_Ptr[i].len := 0;
  127.       END;
  128.  
  129.     {now zero-out the noun information}
  130.     FOR i := First_noun TO Last_noun DO
  131.       BEGIN
  132.         New(N[i]);                {must create space in heap}
  133.         WITH N[i]^ DO
  134.           BEGIN
  135.             name := 'none';
  136.             position := 'none';
  137.             SingOrPlur := Singular;
  138.             SomethingPositionedNearThisNoun := False;
  139.             ThisNounPositionedNearNounNumber := 0;
  140.             adj := '';
  141.             Has_Synonyms := False;
  142.             synonyms := '';       {Synonyms for this noun}
  143.             readable := False;
  144.             closable := False;
  145.             wearable := False;
  146.             open := False;
  147.             on := False;
  148.             pushable := False;
  149.             turnable := False;
  150.             playable := False;
  151.             pullable := False;
  152.             lockable := False;
  153.             locked := False;
  154.             poisonous := False;
  155.             edible := False;
  156.             drinkable := False;
  157.             movable := True;
  158.             weight := 1;
  159.             size := 1;
  160.             location := 0;
  161.             key := 0;
  162.             is_light := False;
  163.             points := 0;
  164.             nouns_inside := 0;
  165.             can_shoot := False;
  166.             num_shots := 0;
  167.             game_win := False;
  168.           END;
  169.         Noun_Ptr[i].start := -1; Push_Ptr[i].start := -1;
  170.         Pull_Ptr[i].start := -1; Text_Ptr[i].start := -1;
  171.         Turn_Ptr[i].start := -1; Play_Ptr[i].start := -1;
  172.         Noun_Ptr[i].len := 0; Push_Ptr[i].len := 0;
  173.         Pull_Ptr[i].len := 0; Text_Ptr[i].len := 0;
  174.         Turn_Ptr[i].len := 0; Play_Ptr[i].len := 0;
  175.         Intro_Ptr.start := 0; Intro_Ptr.len := 0;
  176.       END;
  177.  
  178.     {now zero out the creature information}
  179.     FOR i := First_creature TO Last_Creature DO
  180.       BEGIN
  181.         New(M[i]);                {must create space in heap}
  182.         WITH M[i]^ DO
  183.           BEGIN
  184.             location := 0;
  185.             name := 'none';
  186.             adj := '';
  187.             Has_Synonyms := False;
  188.             synonyms := '';       {Synonyms for this creature}
  189.             groupmember := False;
  190.             weapon := 0;
  191.             hostile := False;
  192.             points := 0;
  193.             nouns_inside := 0;
  194.             counter := 0;
  195.             threshhold := 3;
  196.             timethresh := -1;
  197.             timecounter := 0;
  198.             gender := Thing;      {beast/animal/default creature}
  199.           END;
  200.         Creature_Ptr[i].start := -1;
  201.         Creature_Ptr[i].len := 0;
  202.       END;
  203.     MaxRoom := 0;                 {zero upper index limit to start with}
  204.     MaxNoun := 0;                 {zero upper index limit to start with}
  205.     MaxCreature := 0;             {zero upper index limit to start with}
  206.     {finished zeroing out}
  207.  
  208.     {now -- read data files}
  209.     Assign(descr_file, descr_file_name);
  210.     Rewrite(descr_file);
  211.     sentence := ' >> Temporary data file of strings for AGT << ';
  212.     Write(descr_file, sentence);  {fill line 0 in file}
  213.  
  214.     IF File_Exists(message_file_name) THEN
  215.       BEGIN                       {message file exists}
  216.         Assign(datafile, message_file_name); {message file}
  217.         Reset(datafile);
  218.         REPEAT                    {until (sentence = 'END OF FILE') or (EOF(datafile))}
  219.           ReadLn(datafile, sentence);
  220.           Capitalize(sentence);
  221.           st := first_word(sentence);
  222.           IF st <> '' THEN
  223.             IF st = 'MESSAGE' THEN
  224.               BEGIN
  225.                 vv := Value(sentence);
  226.                 (* *) IF vv > MaxMessage THEN MaxMessage := vv; (** Set new upper limit **)
  227.                 InSen := sentence;
  228.                 (* *) TestParameter(vv, '', InSen, MessageTest);
  229.                 Message_Ptr[vv].start := FilePos(descr_file);
  230.                 ReadLn(datafile, sentence);
  231.                 WHILE NOT_END(sentence) DO
  232.                   BEGIN
  233.                     PAD(sentence); {Pads out sentence with blanks}
  234.                     sentence := Encode(sentence);
  235.                     Write(descr_file, sentence);
  236.                     Message_Ptr[vv].len := Message_Ptr[vv].len+1;
  237.                     ReadLn(datafile, sentence);
  238.                   END;
  239.               END;
  240.         UNTIL (POS('END OF FILE', sentence) <> 0) OR (EOF(datafile));
  241.         Close(datafile);
  242.       END;                        {message file exists}
  243.  
  244.     Assign(datafile, data_file_name); {normal datafile}
  245.     Reset(datafile);
  246.  
  247.   END;                            {initialize_part1}
  248.  
  249.   {Initialize Part 2}
  250.   PROCEDURE Initialize_Part2;
  251.   VAR i, vv, zz, qLoc : Integer;
  252.     qst, qst2, sentence : s;
  253.     TopSen, InSen : s;
  254.     st, st2 : words;
  255.     match : Boolean;
  256.  
  257.     PROCEDURE TestForFatalError(num : Integer; FromNum : Integer; ToNum : Integer);
  258.     BEGIN
  259.       IF (num < FromNum) OR (num > ToNum) THEN
  260.         BEGIN
  261.           WriteLn('This is a FATAL error!!!  Fix it, then COMPILE again.');
  262.           Halt;
  263.         END;
  264.     END;
  265.  
  266.   BEGIN                           {initialize_part2}
  267.     REPEAT                        {until (sentence = 'END OF FILE') or (EOF(datafile))}
  268.       ReadLn(datafile, sentence);
  269.       (* *) TopSen := sentence;
  270.       Capitalize(sentence);
  271.       st := first_word(sentence);
  272.       IF st <> '' THEN
  273.         IF (st = 'ROOM') THEN
  274.           BEGIN
  275.             i := Value(sentence);
  276.             (* *) TestParameter(i, '', TopSen, RoomTest);
  277.             (* *) TestForFatalError(i, First_Room, Last_Room);
  278.             IF i > MaxRoom THEN MaxRoom := i; {new upper limit defined}
  279.             ReadLn(datafile, Room[i]^.name); {get room name}
  280.             WHILE ((Room[i]^.name[1] = ' ') AND (Length(Room[i]^.name) > 0)) DO
  281.               Room[i]^.name := Copy(Room[i]^.name, 2, Length(Room[i]^.name));
  282.             REPEAT
  283.               ReadLn(datafile, sentence);
  284.               Capitalize(sentence);
  285.               st := first_word(sentence);
  286.               IF (st = 'N') OR (st = 'NORTH') THEN
  287.                 Room[i]^.Path[NORTH] := Value(sentence)
  288.               ELSE IF (st = 'S') OR (st = 'SOUTH') THEN
  289.                 Room[i]^.Path[SOUTH] := Value(sentence)
  290.               ELSE IF (st = 'E') OR (st = 'EAST') THEN
  291.                 Room[i]^.Path[EAST] := Value(sentence)
  292.               ELSE IF (st = 'W') OR (st = 'WEST') THEN
  293.                 Room[i]^.Path[WEST] := Value(sentence)
  294.               ELSE IF (st = 'NE') OR (st = 'NORTHEAST') THEN
  295.                 Room[i]^.Path[northeast] := Value(sentence)
  296.               ELSE IF (st = 'NW') OR (st = 'NORTHWEST') THEN
  297.                 Room[i]^.Path[northwest] := Value(sentence)
  298.               ELSE IF (st = 'SE') OR (st = 'SOUTHEAST') THEN
  299.                 Room[i]^.Path[southeast] := Value(sentence)
  300.               ELSE IF (st = 'SW') OR (st = 'SOUTHWEST') THEN
  301.                 Room[i]^.Path[southwest] := Value(sentence)
  302.               ELSE IF (st = 'U') OR (st = 'UP') THEN
  303.                 Room[i]^.Path[up] := Value(sentence)
  304.               ELSE IF (st = 'D') OR (st = 'DOWN') THEN
  305.                 Room[i]^.Path[down] := Value(sentence)
  306.               ELSE IF (st = 'ENTER') THEN
  307.                 Room[i]^.Path[enter] := Value(sentence)
  308.               ELSE IF (st = 'EXIT') THEN
  309.                 Room[i]^.Path[Exit] := Value(sentence)
  310.               ELSE IF (st = 'SPECIAL') THEN
  311.                 Room[i]^.special := Value(sentence)
  312.               ELSE IF (st = 'KEY') THEN
  313.                 Room[i]^.key := Value(sentence)
  314.               ELSE IF (st = 'LOCKED_DOOR') THEN
  315.                 Room[i]^.locked_door := True
  316.               ELSE IF (st = 'ROOM_SYNONYMS') THEN
  317.                 BEGIN
  318.                   st2 := second_word(sentence);
  319.                   IF st2 = 'CHANGE_LOCATION' THEN st2 := 'CHANGE_LOCATIONS';
  320.                   IF NOT Is_Verb(st2)
  321.                   THEN WriteLn('ERROR: "', st2, '" is not a valid verb!');
  322.                   Room[i]^.Replaced_Word := st2;
  323.                   zz := POS(st2, sentence)+Length(st2);
  324.                   st := Copy(sentence, zz, 255)+' ';
  325.                   {has leading and trailing space}
  326.                   Room[i]^.Replacing_Words := ' '+st+' ';
  327.                 END               {Room Synonyms}
  328.               ELSE IF (st = 'PLAYER_DEAD') OR (sentence = 'KILLPLAYER') THEN
  329.                 Room[i]^.player_dead := True
  330.               ELSE IF (st = 'GAME_END') OR (sentence = 'GAME-END') THEN
  331.                 Room[i]^.game_end := True
  332.               ELSE IF (st = 'GAME_WIN') OR (st = 'GAME_WON')
  333.               OR (sentence = 'GAME-WIN') OR (sentence = 'GAME-WON') THEN
  334.                 Room[i]^.game_win := True
  335.               ELSE IF (st = 'LIGHT') THEN
  336.                 Room[i]^.light := Value(sentence)
  337.               ELSE IF (st = 'POINTS') OR (st = 'SCORE') THEN
  338.                 Room[i]^.points := Value(sentence); {last statement in IF}
  339.             UNTIL (st = 'END_ROOM');
  340.           END                     {if ROOM}
  341.  
  342.         ELSE IF (st = 'NOUN') THEN
  343.           BEGIN
  344.             i := Value(sentence);
  345.             (* *) TestParameter(i, '', TopSen, NounTest);
  346.             (* *) TestForFatalError(i, First_noun, Last_noun);
  347.             IF i > MaxNoun THEN MaxNoun := i; {new upper limit defined}
  348.             ReadLn(datafile, sentence);
  349.             Capitalize(sentence);
  350.             N[i]^.name := sentence; {get noun name}
  351.             N[i]^.synonyms := ' '+sentence+' ';
  352.             {create synonym list containing Name to begin with}
  353.             ReadLn(datafile, sentence);
  354.             Capitalize(sentence);
  355.             N[i]^.adj := sentence;
  356.             ReadLn(datafile, N[i]^.short);
  357.             REPEAT
  358.               ReadLn(datafile, sentence);
  359.               (* *) InSen := sentence;
  360.               Capitalize(sentence);
  361.               st := first_word(sentence);
  362.               IF (st = 'WEIGHT') THEN
  363.                 N[i]^.weight := Value(sentence)
  364.               ELSE
  365.                 IF (st = 'SIZE') THEN
  366.                   N[i]^.size := Value(sentence)
  367.                 ELSE
  368.                   IF (st = 'LOCATION') THEN
  369.                     BEGIN
  370.                       N[i]^.location := Value(sentence);
  371.                       (* *) TestParameter(Value(sentence), TopSen, InSen, LocationTest);
  372.                   END ELSE
  373.                     IF (st = 'KEY') THEN
  374.                       BEGIN
  375.                         N[i]^.key := Value(sentence);
  376.                         (* *) TestParameter(Value(sentence), TopSen, InSen, ZNounTest);
  377.                       END
  378.                     ELSE IF (st = 'POINTS') OR (st = 'SCORE') THEN
  379.                       N[i]^.points := Value(sentence)
  380.                     ELSE IF (st = 'CAN_SHOOT') OR (st = 'IS_GUN') THEN
  381.                       N[i]^.can_shoot := True
  382.                     ELSE IF (st = 'BULLETS') OR (st = 'NUM_SHOTS') THEN
  383.                       N[i]^.num_shots := Value(sentence)
  384.                     ELSE IF (st = 'NOUN_SYNONYMS') THEN
  385.                       BEGIN
  386.                         qst2 := But_First(sentence);
  387.                         N[i]^.synonyms := N[i]^.synonyms+' '+qst2+' ';
  388.                         {add synonyms to normal name for this noun}
  389.                         N[i]^.Has_Synonyms := True;
  390.                       END
  391.                     ELSE IF (st = 'POSITION') THEN
  392.                       BEGIN
  393.                         qst2 := But_First(sentence);
  394.                         Normalize(qst2);
  395.                         N[i]^.position := qst2;
  396.                       END
  397.                     ELSE {Position} IF (st = 'READABLE') THEN
  398.                       N[i]^.readable := True
  399.                     ELSE IF (st = 'PUSHABLE') OR (st = 'TOUCHABLE') THEN
  400.                       N[i]^.pushable := True
  401.                     ELSE IF (st = 'TURNABLE') THEN
  402.                       N[i]^.turnable := True
  403.                     ELSE IF (st = 'PLAYABLE') THEN
  404.                       N[i]^.playable := True
  405.                     ELSE IF (st = 'PULLABLE') THEN
  406.                       N[i]^.pullable := True
  407.                     ELSE IF (st = 'PLURAL') THEN
  408.                       N[i]^.SingOrPlur := Plural
  409.                     ELSE IF (st = 'ON') THEN
  410.                       N[i]^.on := True
  411.                     ELSE IF (st = 'OFF') THEN
  412.                       N[i]^.on := False
  413.                     ELSE IF (st = 'UNREADABLE') THEN
  414.                       N[i]^.readable := False
  415.                     ELSE IF (st = 'CLOSABLE') OR (st = 'CLOSEABLE') THEN
  416.                       N[i]^.closable := True
  417.                     ELSE IF (st = 'UNCLOSABLE') OR (st = 'UNCLOSEABLE') THEN
  418.                       N[i]^.closable := False
  419.                     ELSE IF (st = 'WEARABLE') THEN
  420.                       N[i]^.wearable := True
  421.                     ELSE IF (st = 'UNWEARABLE') THEN
  422.                       N[i]^.wearable := False
  423.                     ELSE IF (st = 'OPEN') THEN
  424.                       N[i]^.open := True
  425.                     ELSE IF (st = 'CLOSED') THEN
  426.                       N[i]^.open := False
  427.                     ELSE IF (st = 'LOCKABLE') THEN
  428.                       N[i]^.lockable := True
  429.                     ELSE IF (st = 'UNLOCKABLE') THEN
  430.                       N[i]^.lockable := False
  431.                     ELSE IF (st = 'LOCKED') THEN
  432.                       N[i]^.locked := True
  433.                     ELSE IF (st = 'UNLOCKED') THEN
  434.                       N[i]^.locked := False
  435.                     ELSE IF (st = 'EDIBLE') THEN
  436.                       N[i]^.edible := True
  437.                     ELSE IF (st = 'INEDIBLE') THEN
  438.                       N[i]^.edible := False
  439.                     ELSE IF (st = 'DRINKABLE') THEN
  440.                       N[i]^.drinkable := True
  441.                     ELSE IF (st = 'UNDRINKABLE') THEN
  442.                       N[i]^.drinkable := False
  443.                     ELSE IF (st = 'POISONOUS') THEN
  444.                       N[i]^.poisonous := True
  445.                     ELSE IF (st = 'NON-POISONOUS') OR (st = 'NONPOISONOUS') THEN
  446.                       N[i]^.poisonous := False
  447.                     ELSE IF (st = 'MOVABLE') OR (st = 'MOVEABLE') THEN
  448.                       N[i]^.movable := True
  449.                     ELSE IF (st = 'UNMOVABLE') OR (st = 'UNMOVEABLE') THEN
  450.                       N[i]^.movable := False
  451.                     ELSE IF (st = 'LIGHT') OR (st = 'IS_LIGHT') THEN
  452.                       N[i]^.is_light := True
  453.                     ELSE IF (st = 'GAME_WIN') THEN
  454.                       N[i]^.game_win := True; {last line of IF}
  455.             UNTIL (st = 'END_NOUN');
  456.           END                     {if NOUN}
  457.  
  458.         ELSE IF (st = 'CREATURE') THEN
  459.           BEGIN
  460.             i := Value(sentence);
  461.             (* *) TestParameter(i, '', TopSen, CreatureTest);
  462.             (* *) TestForFatalError(i, First_creature, Last_Creature);
  463.             IF i > MaxCreature THEN MaxCreature := i; {new upper limit defined}
  464.             ReadLn(datafile, sentence);
  465.             Capitalize(sentence);
  466.             M[i]^.name := sentence; {get creature name}
  467.             M[i]^.synonyms := ' '+sentence+' ';
  468.             {create synonym list containing Name to begin with}
  469.             ReadLn(datafile, sentence);
  470.             Capitalize(sentence);
  471.             M[i]^.adj := sentence;
  472.             ReadLn(datafile, M[i]^.short);
  473.             REPEAT
  474.               ReadLn(datafile, sentence);
  475.               Capitalize(sentence);
  476.               (* *) InSen := sentence;
  477.               st := first_word(sentence);
  478.               IF (st = 'LOCATION') THEN
  479.                 BEGIN
  480.                   M[i]^.location := Value(sentence);
  481.                   (* *) TestParameter(Value(sentence), TopSen, InSen, ZRoomTest);
  482.                 END
  483.               ELSE IF (st = 'WEAPON') THEN
  484.                 M[i]^.weapon := Value(sentence)
  485.               ELSE IF (st = 'POINTS') THEN
  486.                 M[i]^.points := Value(sentence)
  487.               ELSE IF (st = 'CREATURE_SYNONYMS') THEN
  488.                 BEGIN
  489.                   qst2 := But_First(sentence);
  490.                   M[i]^.synonyms := M[i]^.synonyms+' '+qst2+' ';
  491.                   {add synonyms to normal name for this creature}
  492.                   M[i]^.Has_Synonyms := True;
  493.                 END
  494.               ELSE IF (st = 'GROUPMEMBER') THEN
  495.                 M[i]^.groupmember := True
  496.               ELSE IF (st = 'HOSTILE') THEN
  497.                 M[i]^.hostile := True
  498.               ELSE IF (st = 'FRIENDLY') THEN
  499.                 M[i]^.hostile := False
  500.               ELSE IF ((st = 'WOMAN') OR (st = 'FEMALE')) THEN
  501.                 M[i]^.gender := Woman
  502.               ELSE IF ((st = 'MAN') OR (st = 'MALE')) THEN
  503.                 M[i]^.gender := Man
  504.               ELSE                { Below handles most common misspellings }
  505.                 IF POS('THRESH', st) <> 0 THEN
  506.                   IF POS('TIME', st) <> 0 THEN
  507.                     M[i]^.timethresh := Value(sentence)
  508.                   ELSE
  509.                     M[i]^.threshhold := Value(sentence); {Last line of IF}
  510.             UNTIL (st = 'END_CREATURE');
  511.           END                     {if Creature}
  512.  
  513.           {else it's a description, set appropriate pointer}
  514.         ELSE IF st = 'TEXT' THEN
  515.           BEGIN
  516.             vv := Value(sentence);
  517.             (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
  518.             Text_Ptr[vv].start := FilePos(descr_file);
  519.             ReadLn(datafile, sentence);
  520.             WHILE NOT_END(sentence) DO
  521.               BEGIN
  522.                 PAD(sentence);    {Pads out sentence with blanks}
  523.                 sentence := Encode(sentence);
  524.                 Write(descr_file, sentence);
  525.                 Text_Ptr[vv].len := Text_Ptr[vv].len+1;
  526.                 ReadLn(datafile, sentence);
  527.               END;
  528.           END
  529.         ELSE IF st = 'QUESTION' THEN
  530.           BEGIN
  531.             sentence := But_First(sentence);
  532.             vv := Value(sentence);
  533.             (* *) TestParameter(Value(sentence), '', TopSen, QuestionTest);
  534.             sentence := But_First(sentence);
  535.             Question[vv] := sentence;
  536.           END
  537.         ELSE IF st = 'ANSWER' THEN
  538.           BEGIN
  539.             sentence := But_First(sentence);
  540.             vv := Value(sentence);
  541.             (* *) TestParameter(Value(sentence), '', TopSen, QuestionTest);
  542.             sentence := But_First(sentence);
  543.             Answer[vv] := sentence;
  544.           END
  545.         ELSE IF st = 'HELP' THEN
  546.           BEGIN
  547.             vv := Value(sentence);
  548.             (* *) TestParameter(Value(sentence), '', TopSen, RoomTest);
  549.             Help_Ptr[vv].start := FilePos(descr_file);
  550.             ReadLn(datafile, sentence);
  551.             WHILE NOT_END(sentence) DO
  552.               BEGIN
  553.                 PAD(sentence);    {Pads out sentence with blanks}
  554.                 sentence := Encode(sentence);
  555.                 Write(descr_file, sentence);
  556.                 Help_Ptr[vv].len := Help_Ptr[vv].len+1;
  557.                 ReadLn(datafile, sentence);
  558.               END;
  559.           END
  560.         ELSE IF st = 'PLAY_DESCR' THEN
  561.           BEGIN
  562.             vv := Value(sentence);
  563.             (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
  564.             Play_Ptr[vv].start := FilePos(descr_file);
  565.             ReadLn(datafile, sentence);
  566.             WHILE NOT_END(sentence) DO
  567.               BEGIN
  568.                 PAD(sentence);    {Pads out sentence with blanks}
  569.                 sentence := Encode(sentence);
  570.                 Write(descr_file, sentence);
  571.                 Play_Ptr[vv].len := Play_Ptr[vv].len+1;
  572.                 ReadLn(datafile, sentence);
  573.               END;
  574.           END
  575.         ELSE IF st = 'PUSH_DESCR' THEN
  576.           BEGIN
  577.             vv := Value(sentence);
  578.             (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
  579.             Push_Ptr[vv].start := FilePos(descr_file);
  580.             ReadLn(datafile, sentence);
  581.             WHILE NOT_END(sentence) DO
  582.               BEGIN
  583.                 PAD(sentence);    {Pads out sentence with blanks}
  584.                 sentence := Encode(sentence);
  585.                 Write(descr_file, sentence);
  586.                 Push_Ptr[vv].len := Push_Ptr[vv].len+1;
  587.                 ReadLn(datafile, sentence);
  588.               END;
  589.           END
  590.         ELSE IF st = 'PULL_DESCR' THEN
  591.           BEGIN
  592.             vv := Value(sentence);
  593.             (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
  594.             Pull_Ptr[vv].start := FilePos(descr_file);
  595.             ReadLn(datafile, sentence);
  596.             WHILE NOT_END(sentence) DO
  597.               BEGIN
  598.                 PAD(sentence);    {Pads out sentence with blanks}
  599.                 sentence := Encode(sentence);
  600.                 Write(descr_file, sentence);
  601.                 Pull_Ptr[vv].len := Pull_Ptr[vv].len+1;
  602.                 ReadLn(datafile, sentence);
  603.               END;
  604.           END
  605.         ELSE IF st = 'TURN_DESCR' THEN
  606.           BEGIN
  607.             vv := Value(sentence);
  608.             (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
  609.             Turn_Ptr[vv].start := FilePos(descr_file);
  610.             ReadLn(datafile, sentence);
  611.             WHILE NOT_END(sentence) DO
  612.               BEGIN
  613.                 PAD(sentence);    {Pads out sentence with blanks}
  614.                 sentence := Encode(sentence);
  615.                 Write(descr_file, sentence);
  616.                 Turn_Ptr[vv].len := Turn_Ptr[vv].len+1;
  617.                 ReadLn(datafile, sentence);
  618.               END;
  619.           END
  620.         ELSE IF st = 'CREATURE_DESCR' THEN
  621.           BEGIN
  622.             vv := Value(sentence);
  623.             (* *) TestParameter(Value(sentence), '', TopSen, CreatureTest);
  624.             Creature_Ptr[vv].start := FilePos(descr_file);
  625.             ReadLn(datafile, sentence);
  626.             WHILE NOT_END(sentence) DO
  627.               BEGIN
  628.                 PAD(sentence);    {Pads out sentence with blanks}
  629.                 sentence := Encode(sentence);
  630.                 Write(descr_file, sentence);
  631.                 Creature_Ptr[vv].len := Creature_Ptr[vv].len+1;
  632.                 ReadLn(datafile, sentence);
  633.               END;
  634.           END
  635.         ELSE IF st = 'ROOM_DESCR' THEN
  636.           BEGIN
  637.             vv := Value(sentence);
  638.             (* *) TestParameter(Value(sentence), '', TopSen, RoomTest);
  639.             Room_Ptr[vv].start := FilePos(descr_file);
  640.             ReadLn(datafile, sentence);
  641.             WHILE NOT_END(sentence) DO
  642.               BEGIN
  643.                 PAD(sentence);    {Pads out sentence with blanks}
  644.                 sentence := Encode(sentence);
  645.                 Write(descr_file, sentence);
  646.                 Room_Ptr[vv].len := Room_Ptr[vv].len+1;
  647.                 ReadLn(datafile, sentence);
  648.               END;
  649.           END
  650.         ELSE IF st = 'SPECIAL' THEN
  651.           BEGIN
  652.             vv := Value(sentence);
  653.             (* *) TestParameter(Value(sentence), '', TopSen, RoomTest);
  654.             Special_Ptr[vv].start := FilePos(descr_file);
  655.             ReadLn(datafile, sentence);
  656.             WHILE NOT_END(sentence) DO
  657.               BEGIN
  658.                 PAD(sentence);    {Pads out sentence with blanks}
  659.                 sentence := Encode(sentence);
  660.                 Write(descr_file, sentence);
  661.                 Special_Ptr[vv].len := Special_Ptr[vv].len+1;
  662.                 ReadLn(datafile, sentence);
  663.               END;
  664.           END
  665.         ELSE IF st = 'RESURRECTION_ROOM' THEN
  666.           BEGIN
  667.             Resurrection_Room := Value(sentence);
  668.             (* *) TestParameter(Value(sentence), '', TopSen, RoomTest);
  669.           END
  670.         ELSE IF st = 'MAX_LIVES' THEN Max_Lives := Value(sentence)
  671.         ELSE IF st = 'TREASURE_ROOM' THEN Treasure_Room := Value(sentence)
  672.         ELSE IF st = 'MAXIMUM_SCORE' THEN Maximum_Score := Value(sentence)
  673.         ELSE IF st = 'STARTING_ROOM' THEN
  674.           BEGIN
  675.             Current_room := Value(sentence);
  676.             (* *) TestParameter(Value(sentence), '', TopSen, RoomTest);
  677.             Starting_room := Current_room;
  678.           END
  679.         ELSE IF st = 'NOUN_DESCR' THEN
  680.           BEGIN
  681.             vv := Value(sentence);
  682.             (* *) TestParameter(Value(sentence), '', TopSen, NounTest);
  683.             Noun_Ptr[vv].start := FilePos(descr_file);
  684.             ReadLn(datafile, sentence);
  685.             WHILE NOT_END(sentence) DO
  686.               BEGIN
  687.                 PAD(sentence);    {Pads out sentence with blanks}
  688.                 sentence := Encode(sentence);
  689.                 Write(descr_file, sentence);
  690.                 Noun_Ptr[vv].len := Noun_Ptr[vv].len+1;
  691.                 ReadLn(datafile, sentence);
  692.               END;
  693.           END
  694.         ELSE IF (st = 'INTRO') OR (st = 'INTRODUCTION') THEN
  695.           BEGIN
  696.             ReadLn(datafile, sentence); {skip past line with 'INTRO' on it}
  697.             IF CreatingFinalVersion THEN Intro_Ptr.start := FilePos(descr_file);
  698.             WHILE NOT_END(sentence) DO
  699.               BEGIN
  700.                 IF CreatingFinalVersion THEN
  701.                   BEGIN
  702.                     PAD(sentence); {Pads out sentence with blanks}
  703.                     sentence := Encode(sentence);
  704.                     Write(descr_file, sentence);
  705.                     Intro_Ptr.len := Intro_Ptr.len+1;
  706.                   END;
  707.                 ReadLn(datafile, sentence);
  708.               END;
  709.           END
  710.         ELSE IF (st = 'VERB') OR (st = 'SYNONYM')
  711.         OR (st = 'VERBS') OR (st = 'SYNONYMS')
  712.         {user-defined verb synonym}
  713.         THEN BEGIN
  714.           ReadLn(datafile, sentence);
  715.           WHILE NOT_END(sentence) DO
  716.             BEGIN
  717.               Capitalize(sentence);
  718.               st := first_word(sentence);
  719.               IF NOT Is_Verb(st)
  720.               THEN WriteLn('ERROR: "', st, '" is not a valid verb!');
  721.               qst2 := ' '+But_First(sentence)+' * ';
  722.               {has leading and trailing space}
  723.               i := 1;
  724.               match := False;
  725.               WHILE (i <= Num_Verbs) AND (NOT match) DO
  726.                 BEGIN
  727.                   IF (V[i] = st) THEN
  728.                     BEGIN
  729.                       SYN[i] := qst2;
  730.                       match := True;
  731.                     END;
  732.                   i := i+1;
  733.                 END;              {while}
  734.               IF NOT match THEN WriteLn(' >>> Ignored: "', sentence, '"');
  735.               ReadLn(datafile, sentence);
  736.             END;                  {while}
  737.         END;                      {'VERB' synonyms}
  738.  
  739.     UNTIL (POS('END OF FILE', sentence) <> 0) OR (EOF(datafile));
  740.     sentence := 'END OF FILE';
  741.     Write(descr_file, sentence);  {mark end of this file}
  742.     Close(descr_file);
  743.     Close(datafile);
  744.     IF (Starting_room <> 2) AND (Resurrection_Room = 2)
  745.     THEN Resurrection_Room := Starting_room; {default condition}
  746.  
  747.     {zero counts of nouns located various places}
  748.     Items_Being_Carried := 0;
  749.     Items_Being_Worn := 0;
  750.     FOR i := First_Room TO MaxRoom DO Room[i]^.nouns_inside := 0;
  751.     FOR i := First_noun TO MaxNoun DO N[i]^.nouns_inside := 0;
  752.     FOR i := First_creature TO MaxCreature DO M[i]^.nouns_inside := 0;
  753.  
  754.     {now count how many are located in various places}
  755.     FOR i := First_noun TO MaxNoun DO Adjust_Count(N[i]^.location, 1);
  756.  
  757.   END;                            {initialize_part2}
  758.  
  759.   { Init_Verbs }
  760.   {Set up the list of valid verbs}
  761.   PROCEDURE Init_verbs;
  762.     {initialize verbs list}
  763.   VAR i : Integer;
  764.   BEGIN
  765.     FOR i := 0 TO Num_Verbs DO V[i] := 'none';
  766.     FOR i := 0 TO Num_Verbs DO SYN[i] := 'none';
  767.     V[0] := 'ANY';
  768.     V[1] := 'NORTH';
  769.     V[2] := 'SOUTH';
  770.     V[3] := 'EAST';
  771.     V[4] := 'WEST';
  772.     V[5] := 'SOUTHEAST';
  773.     V[6] := 'SOUTHWEST';
  774.     V[7] := 'NORTHEAST';
  775.     V[8] := 'NORTHWEST';
  776.     V[9] := 'UP';
  777.     V[10] := 'DOWN';
  778.     V[11] := 'ENTER';
  779.     V[12] := 'EXIT';
  780.     V[13] := 'SPECIAL';
  781.     V[14] := 'THROW';
  782.     V[15] := 'OPEN';
  783.     V[16] := 'CLOSE';
  784.     V[17] := 'LOCK';
  785.     V[18] := 'UNLOCK';
  786.     V[19] := 'LOOK';
  787.     V[20] := 'EXAMINE';
  788.     V[21] := 'CHANGE_LOCATIONS';
  789.     V[22] := 'READ';
  790.     V[23] := 'EAT';
  791.     V[24] := 'DRINK';
  792.     V[25] := 'SCORE';
  793.     V[26] := 'ATTACK';
  794.     V[27] := 'WAIT';
  795.     V[28] := 'YELL';
  796.     V[29] := 'PUT';
  797.     V[30] := 'QUIT';
  798.     V[31] := 'TELL';
  799.     V[32] := 'INVENTORY';
  800.     V[33] := 'GET';
  801.     V[34] := 'ASK';
  802.     V[35] := 'TURN';
  803.     V[36] := 'PUSH';
  804.     V[37] := 'PULL';
  805.     V[38] := 'PLAY';
  806.     V[39] := 'LIST';
  807.     V[40] := 'SHOW';
  808.     V[41] := 'DROP';
  809.     V[42] := 'LIST_EXITS';
  810.     V[43] := 'BRIEF';
  811.     V[44] := 'VERBOSE';
  812.     V[45] := 'SAVE';
  813.     V[46] := 'RESTORE';
  814.     V[47] := 'LIGHT';
  815.     V[48] := 'EXTINGUISH';
  816.     V[49] := 'FIRE';
  817.     V[50] := 'HELP';
  818.     V[51] := 'WEAR';
  819.     V[52] := 'REMOVE';
  820.     V[53] := 'SCRIPT';
  821.     V[54] := 'UNSCRIPT';
  822.     V[55] := 'MAGIC_WORD';
  823.     V[56] := 'DUMMY_VERB1'; V[57] := 'DUMMY_VERB26';
  824.     V[58] := 'DUMMY_VERB2'; V[59] := 'DUMMY_VERB27';
  825.     V[60] := 'DUMMY_VERB3'; V[61] := 'DUMMY_VERB28';
  826.     V[62] := 'DUMMY_VERB4'; V[63] := 'DUMMY_VERB29';
  827.     V[64] := 'DUMMY_VERB5'; V[65] := 'DUMMY_VERB30';
  828.     V[66] := 'DUMMY_VERB6'; V[67] := 'DUMMY_VERB31';
  829.     V[68] := 'DUMMY_VERB7'; V[69] := 'DUMMY_VERB32';
  830.     V[70] := 'DUMMY_VERB8'; V[71] := 'DUMMY_VERB33';
  831.     V[72] := 'DUMMY_VERB9'; V[73] := 'DUMMY_VERB34';
  832.     V[74] := 'DUMMY_VERB10'; V[75] := 'DUMMY_VERB35';
  833.     V[76] := 'DUMMY_VERB11'; V[77] := 'DUMMY_VERB36';
  834.     V[78] := 'DUMMY_VERB12'; V[79] := 'DUMMY_VERB37';
  835.     V[80] := 'DUMMY_VERB13'; V[81] := 'DUMMY_VERB38';
  836.     V[82] := 'DUMMY_VERB14'; V[83] := 'DUMMY_VERB39';
  837.     V[84] := 'DUMMY_VERB15'; V[85] := 'DUMMY_VERB40';
  838.     V[86] := 'DUMMY_VERB16'; V[87] := 'DUMMY_VERB41';
  839.     V[88] := 'DUMMY_VERB17'; V[89] := 'DUMMY_VERB42';
  840.     V[90] := 'DUMMY_VERB18'; V[91] := 'DUMMY_VERB43';
  841.     V[92] := 'DUMMY_VERB19'; V[93] := 'DUMMY_VERB44';
  842.     V[94] := 'DUMMY_VERB20'; V[95] := 'DUMMY_VERB45';
  843.     V[96] := 'DUMMY_VERB21'; V[97] := 'DUMMY_VERB46';
  844.     V[98] := 'DUMMY_VERB22'; V[99] := 'DUMMY_VERB47';
  845.     V[100] := 'DUMMY_VERB23'; V[101] := 'DUMMY_VERB48';
  846.     V[102] := 'DUMMY_VERB24'; V[103] := 'DUMMY_VERB49';
  847.     V[104] := 'DUMMY_VERB25'; V[105] := 'DUMMY_VERB50';
  848.     MaxVerb := 105;
  849.   END;                            {initialize verbs}
  850.  
  851.