home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-12-20 | 57.9 KB | 1,363 lines |
-
- { EXECSUBS.PA2}
-
- FUNCTION Is_Or_Are(num : Integer) : words;
- BEGIN
- IF ((num >= First_noun) AND (num <= MaxNoun))
- THEN Is_Or_Are := IsOrAre[N[num]^.SingOrPlur]
- ELSE Is_Or_Are := 'is';
- END; {Is_Or_Are}
-
- FUNCTION It_Or_Them(num : Integer) : words;
- BEGIN
- IF ((num >= First_noun) AND (num <= MaxNoun))
- THEN It_Or_Them := ItOrThem[N[num]^.SingOrPlur]
- ELSE It_Or_Them := 'it';
- END; {Is_Or_Are}
-
-
- { Procedure List_Exits }
- { Given the room number, lists all obvious exits}
-
- PROCEDURE List_Exits(rm : Integer);
-
- VAR Dir : Direction;
- ValidExit : Boolean;
- TargetRoom : Integer;
- BEGIN
- IF LightIsHere {i.e., can see in current room} THEN
- BEGIN {can see exits - if any here}
- ValidExit := False;
- FOR Dir := NORTH TO Exit DO
- BEGIN
- TargetRoom := Room[rm]^.Path[Dir];
- IF (TargetRoom >= First_Room) AND (TargetRoom <= MaxRoom)
- THEN ValidExit := True;
- END;
- Write(IO, 'Obvious directions: ');
- IF NOT ValidExit THEN WriteLn(IO, 'NONE')
- ELSE WITH Room[rm]^ DO
- BEGIN
- IF ((Path[NORTH] >= First_Room) AND (Path[NORTH] <= MaxRoom))
- THEN Write(IO, 'north ');
- IF ((Path[northwest] >= First_Room) AND (Path[northwest] <= MaxRoom))
- THEN Write(IO, 'northwest ');
- IF ((Path[WEST] >= First_Room) AND (Path[WEST] <= MaxRoom))
- THEN Write(IO, 'west ');
- IF ((Path[southwest] >= First_Room) AND (Path[southwest] <= MaxRoom))
- THEN Write(IO, 'southwest ');
- IF ((Path[SOUTH] >= First_Room) AND (Path[SOUTH] <= MaxRoom))
- THEN Write(IO, 'south ');
- IF ((Path[southeast] >= First_Room) AND (Path[southeast] <= MaxRoom))
- THEN Write(IO, 'southeast ');
- IF ((Path[EAST] >= First_Room) AND (Path[EAST] <= MaxRoom))
- THEN Write(IO, 'east ');
- IF ((Path[northeast] >= First_Room) AND (Path[northeast] <= MaxRoom))
- THEN Write(IO, 'northeast ');
- IF ((Path[up] >= First_Room) AND (Path[up] <= MaxRoom))
- THEN Write(IO, 'up ');
- IF ((Path[down] >= First_Room) AND (Path[down] <= MaxRoom))
- THEN Write(IO, 'down ');
- IF ((Path[enter] >= First_Room) AND (Path[enter] <= MaxRoom))
- THEN Write(IO, 'enter ');
- IF ((Path[Exit] >= First_Room) AND (Path[Exit] <= MaxRoom))
- THEN Write(IO, 'exit ');
- END; { with}
- WriteLn(IO, ' ');
- END {can see exits}
- ELSE WriteLn(IO, 'It is too dark to see any exits!');
- morecount := morecount+1;
- END; { list_exits}
-
- { Procedure Help }
- { (Give appropriate room HELP message)}
-
- PROCEDURE Help;
-
- VAR Help_For_Room : Integer;
- BEGIN
- Help_For_Room := Help_Ptr[Current_room].start;
- IF Help_For_Room <= 0
- THEN WriteLn(IO, 'Sorry, you''re on your own here.')
- ELSE Describe_It('HELP', Current_room);
- END; {HELP}
-
-
- PROCEDURE Detach(num : Integer);
- {Make object num's position = none,
- i.e., it is no longer "in", "near", "on", etc. some other object}
-
- VAR i : Integer;
- BEGIN
- WITH N[num]^ DO
- BEGIN
- position := 'none';
- IF SomethingPositionedNearThisNoun THEN
- BEGIN
- FOR i := First_noun TO MaxNoun DO
- IF N[i]^.ThisNounPositionedNearNounNumber = num THEN
- BEGIN
- N[i]^.ThisNounPositionedNearNounNumber := 0;
- N[i]^.position := 'none';
- END;
- SomethingPositionedNearThisNoun := False;
- END;
- END; {WITH}
- END; {Detach}
-
- { Take (noun) }
- { e.g., take axe or get nugget}
-
- PROCEDURE Take(noun : words);
-
- VAR num, i : Integer;
- Noun_S_Adj : words;
- BEGIN
- num := Noun_Number(noun);
- Normalize(noun);
- Noun_S_Adj := Things_Adjective(num);
- IF noun = 'door'
- THEN IF Room[Current_room]^.locked_door
- THEN WriteLn(IO, 'The door won''t budge.')
- ELSE WriteLn(IO, 'The doorway won''t budge.')
- ELSE IF num < First_creature THEN
- BEGIN { if not a creature}
- IF N[num]^.location = Player
- THEN WriteLn(IO, 'You already have the ', Noun_S_Adj, ' ', noun, '!')
- ELSE IF NOT Is_Visible(num)
- THEN BEGIN
- WriteLn(IO, ' ');
- WriteLn(IO, 'Sorry, but there ', Is_Or_Are(num), ' no ', noun, ' here to ', Original_Verb, '.');
- END
- ELSE
- WITH N[num]^ DO
- IF NOT movable
- THEN WriteLn(IO, 'Sorry, but it is impossible to ', Original_Verb, ' the ', noun, '.')
- ELSE IF (weight > Max_Weight)
- THEN WriteLn(IO, 'Too heavy! You aren''t strong enough to carry the ', noun, '.')
- ELSE IF (size > Max_Size)
- THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' far too bulky to carry.')
- ELSE IF (Load_Weight+weight > Max_Weight)
- THEN BEGIN
- WriteLn(IO, 'You aren''t strong enough to carry your current load ');
- WriteLn(IO, 'plus the ', noun, '.');
- END
- ELSE IF (Load_Size+size > Max_Size)
- THEN WriteLn(IO, 'Your load would be too bulky to manage if you took the '
- , noun, '.')
- ELSE { it can be taken}
- BEGIN
- Adjust_Count(location, -1);
- location := Player;
- Adjust_Count(Player, 1);
- Detach(num); {make 'position' = none}
- WriteLn(IO, 'You are now carrying the ', Noun_S_Adj, ' ', noun, '.');
- IF N[num]^.game_win THEN Room[Current_room]^.game_win := True;
- END;
- END { if not a creature}
- ELSE { if it is a creature}
- BEGIN { if it is a creature}
- WITH M[num]^ DO
- IF hostile
- THEN BEGIN
- WriteLn(IO, 'As you reach out to take the ', noun, ', ', Subject_IT[gender], ' ', Snarls[gender]);
- WriteLn(IO, 'at you. ', Cap_Subject_IT[gender], ' doesn''t seem to want to cooperate.')
- END
- ELSE BEGIN
- WriteLn(IO, 'As you reach for ', Object_IT[gender], ', the ', noun, ' seems happy to be touched');
- WriteLn(IO, 'but as soon as ', Subject_IT[gender], ' realizes that you want to take ');
- WriteLn(IO, Object_IT[gender], ', ', Subject_IT[gender], ' slips from your grasp.');
- END;
- END { if a creature}
- END; { take}
-
- { Wear (noun) }
- { e.g., wear armor or put on hat}
-
- PROCEDURE Wear(noun : words);
-
- VAR num, i : Integer;
- Noun_S_Adj : words;
- BEGIN
- num := Noun_Number(noun);
- Normalize(noun);
- IF num < First_creature THEN
- BEGIN { if not a creature}
- Noun_S_Adj := Things_Adjective(num);
- IF N[num]^.location = Wearing
- THEN WriteLn(IO, 'You are already wearing the ', Noun_S_Adj, ' ', noun, '!')
- ELSE IF NOT Is_Visible(num)
- THEN BEGIN
- WriteLn(IO, ' ');
- Normalize(noun);
- WriteLn(IO, 'Sorry, but there ', Is_Or_Are(num), ' no ', noun, ' here to ', Original_Verb, '.');
- WriteLn(IO, ' ');
- END
- ELSE {is visible}
- WITH N[num]^ DO
- IF (NOT wearable)
- THEN WriteLn(IO, 'Sorry, but the ', Noun_S_Adj, ' ', noun, ' can''t be worn.')
- ELSE IF (NOT movable)
- THEN WriteLn(IO, 'Sorry, but it is impossible to ', Original_Verb, ' the ', noun, '.')
- ELSE IF (weight > Max_Weight)
- THEN WriteLn(IO, 'Too heavy! You aren''t strong enough to wear the ', noun, '.')
- ELSE IF (size > Max_Size)
- THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' far too bulky to wear.')
- ELSE IF (Load_Weight+weight > Max_Weight)
- THEN BEGIN WriteLn(IO, 'You aren''t strong enough to carry your current load ');
- WriteLn(IO, 'plus the ', noun, '.');
- END
- ELSE IF (Load_Size+size > Max_Size)
- THEN WriteLn(IO, 'Your load would be too bulky to manage if you took the '
- , noun, '.')
- ELSE { it can be taken}
- BEGIN
- Adjust_Count(location, -1);
- location := Wearing;
- Adjust_Count(Wearing, 1);
- Detach(num); {make 'position' = none}
- WriteLn(IO, 'You are now wearing the ', Noun_S_Adj, ' ', noun, '.');
- END;
- END { if not a creature}
- ELSE { if it is a creature}
- BEGIN { if it is a creature}
- WITH M[num]^ DO
- IF hostile
- THEN BEGIN
- WriteLn(IO, 'As you reach out to take the ', noun, ', ', Subject_IT[gender], ' ', Snarls[gender]);
- WriteLn(IO, 'at you. ', Cap_Subject_IT[gender], ' doesn''t seem to want to cooperate.')
- END
- ELSE BEGIN
- WriteLn(IO, 'As you reach for ', Object_IT[gender], ', the ', noun, ' seems happy to be touched');
- WriteLn(IO, 'but as soon as ', Subject_IT[gender], ' realizes that you want to take ');
- WriteLn(IO, Object_IT[gender], ', ', Subject_IT[gender], ' slips from your grasp.');
- END;
- END { if a creature}
- END; { wear}
-
- { Throw (something) (at|to|in|into|inside|across something)}
- { throw coin to troll or throw water at door }
- { or throw coin into fountain }
-
- PROCEDURE Throw(noun, prep, object_word : words);
-
- VAR n_num, m_num, o_num : Integer;
- BEGIN {Throw}
- IF (noun = 'ALL') OR (object_word = 'ALL')
- THEN WriteLn(IO, 'Not everything at once - one at a time!')
- ELSE BEGIN
- IF prep = ''
- THEN Drop(noun)
- ELSE
- BEGIN
- IF NOT((prep = 'AT') OR (prep = 'TO') OR (prep = 'ACROSS') OR (prep = 'IN')
- OR (prep = 'INSIDE') OR (prep = 'INTO'))
- THEN WriteLn(IO, ' I don''t understand what you mean.')
- ELSE IF (noun = 'ALL') OR (object_word = 'ALL')
- THEN WriteLn(IO, 'Not everything at once - one at a time!')
- ELSE
- IF Is_Creature(object_word)
- THEN
- BEGIN
- n_num := Noun_Number(noun);
- m_num := Creature_Number(object_word);
- IF (location(n_num) <> Player) AND (location(n_num) <> Wearing)
- THEN BEGIN
- Normalize(noun);
- WriteLn(IO, 'You don''t have the ', noun, '.');
- END
- ELSE
- IF (M[m_num]^.location <> Current_room)
- THEN BEGIN
- Normalize(object_word);
- Normalize(prep);
- WriteLn(IO, 'Sorry, but there is no ', object_word, ' here to ', Original_Verb, ' ', prep, '.');
- END
- ELSE { creature is here, player has noun}
- IF M[m_num]^.hostile
- THEN
- IF (M[m_num]^.weapon = n_num)
- THEN
- BEGIN
- Normalize(noun);
- Normalize(object_word);
- WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, '.');
- WriteLn(IO, 'It''s a direct hit!');
- WriteLn(IO, 'The ', object_word, ' ', Screeches[M[m_num]^.gender],
- ' angrily and writhes in agony as');
- WriteLn(IO, Subject_IT[M[m_num]^.gender], ' fades away in a cloud of green smoke.');
- M[m_num]^.location := 0;
- Adjust_Count(N[n_num]^.location, -1);
- Adjust_Count(Current_room, 1);
- N[n_num]^.location := Current_room;
- Detach(n_num); {make 'position' = none}
- END
- ELSE { wrong weapon thrown at hostile creature}
- BEGIN
- Normalize(noun);
- Normalize(object_word);
- WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, '.');
- WriteLn(IO, 'It''s a direct hit!');
- IF NOT N[n_num]^.drinkable
- THEN
- BEGIN
- WriteLn(IO, 'Unfortunately, the ', noun, ' merely bounces off the ', object_word,
- '''s', ' head,');
- WriteLn(IO, 'and appears to make ', Object_IT[M[m_num]^.gender], ' quite angry.');
- Adjust_Count(N[n_num]^.location, -1);
- Adjust_Count(Current_room, 1);
- N[n_num]^.location := Current_room;
- Detach(n_num); {make 'position' = none}
- M[m_num]^.counter := M[m_num]^.counter+1;
- END
- ELSE
- BEGIN
- WriteLn(IO, 'The ', noun, ' splashes against the ', object_word, ' soaking ',
- Object_IT[M[m_num]^.gender], ' and');
- WriteLn(IO, 'clearly angering ', Object_IT[M[m_num]^.gender], '. Although the ', noun,
- ' evaporates quickly,');
- WriteLn(IO, 'the ', object_word, ' doesn''t seem to like you.');
- Adjust_Count(N[n_num]^.location, -1);
- N[n_num]^.location := Nowhere;
- M[m_num]^.counter := M[m_num]^.counter+1;
- END;
- END
- ELSE { creature isn't hostile}
- IF (M[m_num]^.weapon = n_num)
- THEN
- BEGIN
- Normalize(noun);
- Normalize(object_word);
- WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, '.');
- WriteLn(IO, 'It''s a direct hit!');
- WriteLn(IO, 'The ', object_word, ' ', Screeches[M[m_num]^.gender],
- ' and gives you a puzzled look, as if');
- WriteLn(IO, Subject_IT[M[m_num]^.gender], ' couldn''t understand why you would want to hurt ',
- Object_IT[M[m_num]^.gender], '.');
- WriteLn(IO, Cap_Subject_IT[M[m_num]^.gender],
- ' writhes in agony and fades away in a cloud of white smoke,');
- WriteLn(IO, 'but never seems even a bit angry; only confused, upset, and perhaps betrayed.');
- M[m_num]^.location := 0;
- Adjust_Count(N[n_num]^.location, -1);
- Adjust_Count(Current_room, 1);
- N[n_num]^.location := Current_room;
- Detach(n_num); {make 'position' = none}
- END
- ELSE { wrong weapon thrown at friendly creature}
- IF NOT N[n_num]^.drinkable
- THEN
- BEGIN
- Normalize(noun);
- Normalize(object_word);
- WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, '.');
- WriteLn(IO, 'It''s a direct hit!');
- WriteLn(IO, 'The ', object_word, ' ', Screeches[M[m_num]^.gender],
- ' and gives you a puzzled look,');
- WriteLn(IO, 'clearly confused by your actions. ', Cap_Subject_IT[M[m_num]^.gender],
- ' retreats a');
- WriteLn(IO, 'few inches, watching you more carefully than before, but');
- WriteLn(IO, 'still doesn''t seem hostile.');
- Adjust_Count(N[n_num]^.location, -1);
- Adjust_Count(Current_room, 1);
- N[n_num]^.location := Current_room;
- Detach(n_num); {make 'position' = none}
- END
- ELSE
- BEGIN
- Normalize(noun);
- Normalize(object_word);
- WriteLn(IO, 'The ', noun, ' soars through the air and splashes onto the ', object_word, '.');
- WriteLn(IO, 'The ', object_word, ' shakes off the ', noun, ', which evaporates quickly.');
- WriteLn(IO, 'The ', object_word, ' seems quite puzzled by your actions, but still doesn''t');
- WriteLn(IO, 'seem hostile.');
- Adjust_Count(N[n_num]^.location, -1);
- N[n_num]^.location := Nowhere;
- END;
- END { if Is_Creature}
- ELSE { throw it at another noun}
- BEGIN
- n_num := Noun_Number(noun);
- o_num := Noun_Number(object_word);
- Normalize(noun);
- Normalize(object_word);
- Normalize(prep);
- IF (n_num = o_num) THEN WriteLn(IO, 'Sorry, but it is impossible to ', Original_Verb,
- ' the ', noun, ' ', prep, ' itself!')
- ELSE
- IF (location(n_num) <> Player) AND (location(n_num) <> Wearing)
- THEN WriteLn(IO, 'You don''t have the ', noun, '.')
- ELSE IF location(o_num) <> Current_room
- THEN WriteLn(IO, 'There ', Is_Or_Are(o_num), ' no ', object_word, ' here.')
- ELSE { object is here, player has noun}
- IF N[n_num]^.drinkable { if it's liquid, let it slosh!}
- THEN
- IF NOT N[o_num]^.open
- THEN
- BEGIN
- WriteLn(IO, 'The ', noun, ' soars through the air toward the', object_word, ', and splashes');
- WriteLn(IO, 'against ', It_Or_Them(o_num),
- '. For a moment, everything is soaked with '
- , noun, ',');
- WriteLn(IO, 'but the liquid quickly evaporates.');
- Adjust_Count(N[n_num]^.location, -1);
- N[n_num]^.location := Nowhere;
- END
- ELSE
- BEGIN
- WriteLn(IO, 'The ', noun, ' soars through the air toward the', object_word, ', and sloshes');
- WriteLn(IO, 'into and around ', It_Or_Them(o_num),
- '. For a moment, everything is soaked with ', noun, ',');
- WriteLn(IO, 'but the liquid quickly evaporates.');
- Adjust_Count(N[n_num]^.location, -1);
- N[n_num]^.location := Nowhere;
- END
- ELSE { object is here, player has noun}
- IF NOT N[o_num]^.open
- THEN
- BEGIN
- WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, ', and lands');
- WriteLn(IO, 'with a "thud" next to ', It_Or_Them(o_num), '.');
- Adjust_Count(N[n_num]^.location, -1);
- Adjust_Count(N[o_num]^.location, 1);
- N[n_num]^.location := N[o_num]^.location;
- END
- ELSE
- BEGIN
- WriteLn(IO, 'The ', noun, ' soars through the air toward the ', object_word, ', and lands');
- WriteLn(IO, 'in ', It_Or_Them(o_num), ' with a "thunk."');
- Adjust_Count(N[n_num]^.location, -1);
- Adjust_Count(o_num, 1);
- Detach(n_num); {make 'position' = none}
- N[n_num]^.location := o_num;
- END;
- END; { if is_creature .. else}
- END; { if prep = '' .. else}
- END;
- END; { throw}
-
- { Put or Place (noun, prep, object) }
- { put (something) (in|into|inside|with|near|behind|beside|by|on|under something)}
- { E.G., place book in box or put jewel with treasure}
-
- PROCEDURE Put(noun, prep, object_word : words);
-
- VAR num, l : Integer;
- dest, num2 : Integer;
- st : words;
- BEGIN {PUT}
- IF (noun = 'ALL') OR (object_word = 'ALL')
- THEN WriteLn(IO, 'Not everything at once - one at a time!')
- ELSE
- BEGIN
- num := Noun_Number(noun);
- Normalize(noun);
- Normalize(prep);
- Normalize(verb);
- l := location(num);
- IF NOT Is_Visible(num)
- THEN WriteLn(IO, 'Sorry, but there ', Is_Or_Are(num), ' no ', noun, ' here.')
- ELSE
- IF (num >= First_noun) AND (num <= MaxNoun) AND (NOT N[num]^.movable)
- THEN WriteLn(IO, 'Sorry, but it is impossible to move the ', noun, '.')
- ELSE
- BEGIN
- IF (prep = 'in') OR (prep = 'inside') OR (prep = 'into')
- THEN
- BEGIN
- dest := Noun_Number(object_word);
- l := location(dest);
- Normalize(object_word);
- IF (dest = num) THEN WriteLn(IO, 'Sorry, but it is impossible to ', Original_Verb,
- ' the ', noun, ' ', prep, ' itself!')
- ELSE
- IF NOT Is_Visible(dest)
- THEN WriteLn(IO, 'Sorry, but there ', Is_Or_Are(dest), ' no ', object_word, ' here.')
- ELSE IF (dest >= First_creature) AND (dest <= MaxCreature)
- THEN WriteLn(IO, 'Sorry, but the ', object_word, ' won''t let you.')
- ELSE IF (num >= First_creature) AND (num <= MaxCreature)
- THEN WriteLn(IO, 'Sorry, but the ', noun, ' won''t let you.')
- ELSE IF NOT(N[dest]^.open)
- THEN
- IF NOT(N[dest]^.closable)
- THEN WriteLn(IO, 'It is impossible to ', verb, ' the ', noun, ' ', prep, ' the ', object_word)
- ELSE WriteLn(IO, 'The ', object_word, ' isn''t open!')
- ELSE { it's open & here }
- IF N[num]^.size >= N[dest]^.size
- THEN WriteLn(IO, 'The ', noun, ' won''t fit ', prep, ' the ',
- object_word, '!')
- ELSE
- BEGIN
- Adjust_Count(N[num]^.location, -1);
- Adjust_Count(dest, 1);
- N[num]^.location := dest;
- WriteLn(IO, 'You have put the ', noun, ' ', prep, ' the ', object_word, '.');
- END;
- END
- ELSE IF (prep = 'with')
- OR (prep = 'near')
- OR (prep = 'behind')
- OR (prep = 'beside')
- OR (prep = 'on')
- OR (prep = 'by')
- OR (prep = 'under')
- THEN
- BEGIN
- num2 := Noun_Number(object_word);
- Normalize(object_word);
- l := location(num2);
- IF (num2 = num) THEN WriteLn(IO, 'Sorry, but it is impossible to ', Original_Verb,
- ' the ', noun, ' ', prep, ' itself!')
- ELSE
- IF l = Player THEN WriteLn(IO, 'You are carrying the ', object_word, '.')
- ELSE IF l = Wearing THEN WriteLn(IO, 'You are wearing the ', object_word, '.')
- ELSE IF NOT Is_Visible(num2)
- THEN WriteLn(IO, 'There ', Is_Or_Are(num2), ' no ', object_word, ' here!')
- ELSE IF (num2 >= First_creature) AND (num2 <= MaxCreature)
- THEN WriteLn(IO, 'Sorry, but the ', object_word, ' won''t let you.')
- ELSE IF (num >= First_creature) AND (num <= MaxCreature)
- THEN WriteLn(IO, 'Sorry, but the ', noun, ' won''t let you.')
- ELSE
- IF (N[num]^.location > MaxRoom)
- THEN
- IF (N[num]^.size+N[num2]^.size
- >= N[N[num2]^.location]^.size)
- THEN
- BEGIN
- Write(IO, 'The ', noun, ' won''t fit in the ');
- st := N[N[num2]^.location]^.name;
- Normalize(st);
- WriteLn(IO, st, ' ', prep, ' the ', object_word, '.');
- END
- ELSE
- BEGIN
- Adjust_Count(N[num]^.location, -1);
- Adjust_Count(N[num2]^.location, 1);
- N[num]^.location := N[num2]^.location;
- st := N[N[num2]^.location]^.name;
- Normalize(st);
- Write(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now');
- IF (N[num2]^.location > MaxRoom)
- THEN Write(IO, ' in the ', st);
- WriteLn(IO, ' ', prep, ' the ', object_word, '.');
- END
- ELSE
- BEGIN
- Adjust_Count(N[num]^.location, -1);
- Adjust_Count(N[num2]^.location, 1);
- N[num]^.location := N[num2]^.location;
- Write(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now');
- WriteLn(IO, ' ', prep, ' the ', object_word, '.');
- N[num]^.position := prep+' the '+object_word;
- N[num2]^.SomethingPositionedNearThisNoun := True;
- N[num]^.ThisNounPositionedNearNounNumber := num2;
- END;
- END
- ELSE
- BEGIN
- syntax_error := True;
- WriteLn(IO, 'Sorry, I don''t understand what you mean.');
- WriteLn(IO, 'You need to "', Original_Verb, '" the "', noun, '" some place.');
- END;
- END;
- END;
- END; { put}
-
- { Open_Noun (noun,prep,object_word) }
- { open box or open chest with gold key}
-
- PROCEDURE Open_Noun(noun, prep, object_word : words);
-
- VAR n_num, o_num : Integer;
- i : Integer; match : Boolean;
- Noun_S_Adj : words;
- BEGIN
- IF ((noun = 'DOOR') OR (noun = 'DOORS'))
- { allows user defined DOOR nouns in room}
- AND (location(NounNumber) <> Current_room) THEN
- BEGIN
- IF NOT Room[Current_room]^.locked_door
- THEN WriteLn(IO, 'Open what door? There isn''t any closed door here!')
- ELSE WriteLn(IO, 'You try your best, but the door won''t open!')
- END
- ELSE IF (noun = 'ALL') THEN
- BEGIN
- match := False;
- FOR i := First_noun TO MaxNoun DO
- IF Is_Visible(i) AND N[i]^.closable
- THEN
- BEGIN
- Open_Noun(N[i]^.name, prep, object_word); { Recursive}
- match := True;
- END;
- IF NOT match THEN WriteLn(IO, 'There''s nothing here to open!');
- END
- ELSE { open a regular noun}
- BEGIN
- n_num := Noun_Number(noun);
- o_num := Noun_Number(object_word);
- Normalize(noun);
- Normalize(object_word);
- Noun_S_Adj := Things_Adjective(n_num);
- IF (prep <> '') AND (prep <> 'WITH')
- THEN WriteLn(IO, 'I''m not sure what you mean by that.')
- ELSE
- BEGIN
- IF (NOT Is_Visible(n_num))
- THEN WriteLn(IO, 'There ', Is_Or_Are(n_num), ' no ', Noun_S_Adj, ' ', noun, ' here.')
- ELSE
- BEGIN
- IF ((NOT Is_Visible(o_num)) AND (object_word <> ''))
- THEN WriteLn(IO, 'There ', Is_Or_Are(o_num), ' no ', object_word, ' here.')
- ELSE { everything is here}
- IF NOT N[n_num]^.closable
- THEN
- WriteLn(IO, 'There doesn''t seem to be any way to open the ', noun, '.')
- ELSE
- IF N[n_num]^.open
- THEN WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' already open!')
- ELSE
- IF N[n_num]^.locked
- THEN
- IF prep = ''
- THEN WriteLn(IO, 'You need to unlock ', It_Or_Them(n_num), ' first!')
- ELSE
- BEGIN
- IF N[n_num]^.key <> o_num
- THEN WriteLn(IO, 'You can''t open the ', noun,
- ' with the ', object_word, '!')
- ELSE
- BEGIN
- N[n_num]^.locked := False;
- N[n_num]^.open := True;
- WriteLn(IO, 'You have opened the ', Noun_S_Adj, ' ', noun,
- ' with the ', object_word, '.');
- END;
- END
- ELSE { it's unlocked and openable!}
- BEGIN
- N[n_num]^.open := True;
- WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' now open.');
- END;
- END;
- END;
- END;
- END;
-
- { Close_Noun (noun)}
- { e.g., close box }
-
- PROCEDURE Close_Noun(noun : words);
-
- VAR n_num : Integer;
- i : Integer;
- match : Boolean;
- Noun_S_Adj : words;
- BEGIN
- IF (noun = 'ALL') THEN
- BEGIN
- match := False;
- FOR i := First_noun TO MaxNoun DO
- IF Is_Visible(i) AND N[i]^.closable
- THEN
- BEGIN
- Close_Noun(N[i]^.name); { Recursive}
- match := True;
- END;
- IF NOT match THEN WriteLn(IO, 'There''s nothing here to close!');
- END
- ELSE
- BEGIN
- n_num := Noun_Number(noun);
- Noun_S_Adj := Things_Adjective(n_num);
- Normalize(noun);
- IF NOT Is_Visible(n_num)
- THEN IF ((noun = 'door') OR (noun = 'doors'))
- { allows user defined DOOR nouns in room}
- AND (location(NounNumber) <> Current_room) THEN
- IF (Room[Current_room]^.locked_door)
- THEN WriteLn(IO, 'The door is already closed!')
- ELSE WriteLn(IO, 'None of the doors here seem to be closable!')
- ELSE WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' not here!')
- ELSE IF NOT N[n_num]^.closable
- THEN WriteLn(IO, 'The ', noun, ' can''t be closed!')
- ELSE IF NOT N[n_num]^.open
- THEN WriteLn(IO, 'The ', noun, ' isn''t open!')
- ELSE { it's open, closable, and here -- so close it}
- BEGIN
- N[n_num]^.open := False;
- WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' now closed.');
- END;
- END;
- END;
-
- { Shoot (noun,prep,object) }
- { (attack, fight, kill) }
- { kill troll with laser or shoot laser at troll}
-
- PROCEDURE Shoot(noun, prep, object_word : words);
-
- VAR m_num, o_num : Integer;
- w : words;
- BEGIN
- IF (noun = 'ALL') OR (object_word = 'ALL')
- THEN WriteLn(IO, 'Not everything at once - one at a time!')
- ELSE
- BEGIN
- IF prep = 'AT' THEN BEGIN
- w := noun;
- noun := object_word;
- object_word := w;
- prep := 'WITH';
- END;
- IF NOT Is_Creature(noun)
- THEN
- BEGIN
- WriteLn(IO, 'It would really make more sense to specify some living');
- WriteLn(IO, 'creature. Hostility really requires a target of some sort.');
- END
- ELSE IF ((NOT Is_Noun(object_word)) OR (Length(prep) <= 1))
- THEN BEGIN
- Normalize(object_word); Normalize(noun);
- IF ((Length(object_word) <= 1) OR (Length(prep) <= 1))
- THEN WriteLn(IO, 'You need to specify what you want to use to ',
- 'shoot at the ', noun, '!')
- ELSE WriteLn(IO, 'Using the ', object_word, ' to kill the ', noun,
- ' doesn''t make much sense!');
- END
- ELSE { shoot creature with noun}
- BEGIN
- m_num := Creature_Number(noun);
- o_num := Noun_Number(object_word);
- Normalize(noun); Normalize(object_word);
- IF ((Length(object_word) <= 1) OR (Length(prep) <= 1))
- THEN WriteLn(IO, 'You need to specify what you want to use to ',
- 'shoot at the ', noun, '!')
- ELSE IF ((location(o_num) <> Player) AND (location(o_num) <> Current_room))
- THEN WriteLn(IO, 'Sorry, but there is no ', object_word, ' here.')
- ELSE IF NOT N[o_num]^.can_shoot
- THEN WriteLn(IO, 'You can''t seem to get the ', object_word, ' to shoot!')
- ELSE IF N[o_num]^.num_shots < 1
- THEN WriteLn(IO, 'The ', object_word, ' seems to be empty!')
- ELSE IF (M[m_num]^.location <> Current_room)
- THEN BEGIN
- WriteLn(IO, 'There is no ', noun, ' here.');
- END
- ELSE { creature is here, player has noun}
- BEGIN
- IF (location(o_num) = Current_room)
- THEN BEGIN
- WriteLn(IO, 'You reach down to get the ', object_word, '. You fumble and almost drop it.');
- N[o_num]^.location := Player;
- END;
- IF M[m_num]^.hostile
- THEN
- IF (M[m_num]^.weapon = o_num)
- THEN
- BEGIN
- WriteLn(IO, 'You aim the ', object_word, ' at the ', noun, ' and pull the trigger.');
- WriteLn(IO, 'It''s a direct hit!');
- WriteLn(IO, 'The ', noun, ' ', Screeches[M[m_num]^.gender], ' angrily, and writhes in agony and ');
- WriteLn(IO, 'fades away in a cloud of green smoke.');
- M[m_num]^.location := 0;
- N[o_num]^.num_shots := N[o_num]^.num_shots-1;
- END
- ELSE { wrong weapon shot at hostile creature}
- BEGIN
- Normalize(noun);
- Normalize(object_word);
- WriteLn(IO, 'You aim the ', object_word, ' at the ', noun, ' and pull the trigger.');
- WriteLn(IO, 'It''s a direct hit!');
- WriteLn(IO, 'The ', noun, ' ', Screeches[M[m_num]^.gender], ' angrily, and falls to the floor');
- WriteLn(IO, 'for a moment. Then ', Subject_IT[M[m_num]^.gender], ' leaps up and eyes you quite');
- WriteLn(IO, 'angrily. Though wounded, ', Subject_IT[M[m_num]^.gender], ' seems no less dangerous');
- WriteLn(IO, 'or hostile.');
- N[o_num]^.num_shots := N[o_num]^.num_shots-1;
- M[m_num]^.counter := M[m_num]^.counter+1;
- END
- ELSE { creature isn't hostile}
- IF (M[m_num]^.weapon = o_num)
- THEN
- BEGIN
- WriteLn(IO, 'You aim the ', object_word, ' at the ', noun, ' and pull the trigger.');
- WriteLn(IO, 'It''s a direct hit!');
- WriteLn(IO, 'The ', noun, ' ', Screeches[M[m_num]^.gender], ' and gives you a puzzled look');
- WriteLn(IO, 'as if ', Subject_IT[M[m_num]^.gender], ' couldn''t understand why you would want');
- WriteLn(IO, 'to hurt ', Object_IT[M[m_num]^.gender], '. ', Cap_Subject_IT[M[m_num]^.gender],
- ' writhes in agony and fades away in a cloud ');
- WriteLn(IO, 'of white smoke, but never seems even a bit angry; only confused, upset,');
- WriteLn(IO, 'and perhaps betrayed.');
- M[m_num]^.location := 0;
- N[o_num]^.num_shots := N[o_num]^.num_shots-1;
- END
- ELSE { wrong weapon shot at friendly creature}
- BEGIN
- Normalize(noun);
- Normalize(object_word);
- WriteLn(IO, 'You aim the ', object_word, ' at the ', noun, ' and pull the trigger.');
- WriteLn(IO, 'It''s a direct hit!');
- WriteLn(IO, 'The ', noun, ' is knocked back by the force of the shot, and ', Screeches[M[m_num]^.
- gender]
- );
- WriteLn(IO, 'as ', Subject_IT[M[m_num]^.gender], ' falls to the floor. After a moment,');
- WriteLn(IO, Subject_IT[M[m_num]^.gender], ' rises, wounded and confused by your unexpected actions.');
- WriteLn(IO, Cap_Subject_IT[M[m_num]^.gender],
- ' retreats a few inches, watching you more carefully than ');
- WriteLn(IO, 'before, but still doesn''t seem hostile.');
- N[o_num]^.num_shots := N[o_num]^.num_shots-1;
- END;
- END;
- END;
- END; { else begin...}
- END; { Procedure shoot}
-
- { Unlock (noun,prep,object) }
- { unlock box with key, unlock door}
-
- PROCEDURE Unlock(noun, prep, object_word : words);
-
- VAR n_num, o_num : Integer;
- i : Integer;
- match : Boolean;
- Noun_S_Adj : words;
- BEGIN
- IF (noun = 'ALL') THEN
- BEGIN
- match := False;
- FOR i := First_noun TO MaxNoun DO
- IF Is_Visible(i) AND N[i]^.lockable
- THEN
- BEGIN
- Unlock(N[i]^.name, prep, object_word); { recursive}
- match := True;
- END;
- IF NOT match THEN WriteLn(IO, 'There''s nothing here to unlock!');
- END
- ELSE
- BEGIN
- n_num := Noun_Number(noun);
- o_num := Noun_Number(object_word);
- Normalize(noun);
- Normalize(object_word);
- IF ((noun = 'door') OR (noun = 'doors'))
- { allows user defined DOOR nouns in room}
- AND (location(NounNumber) <> Current_room) THEN
- IF Room[Current_room]^.locked_door
- THEN WriteLn(IO, 'Nice try, but you can''t seem to unlock the door.')
- ELSE WriteLn(IO, 'All the doors here are already open!')
- ELSE IF (prep = '') OR (prep <> 'WITH') THEN
- BEGIN
- WriteLn(IO, 'What a strange request! I really can''t figure out what you mean by that.');
- WriteLn(IO, 'Perhaps, you need to specify a tool to unlock the ', noun, ' with.');
- syntax_error := True;
- END
- ELSE
- BEGIN
- Noun_S_Adj := Things_Adjective(n_num);
- IF (NOT Is_Visible(n_num))
- THEN WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' not here.')
- ELSE
- IF (location(o_num) <> Player)
- THEN WriteLn(IO, 'You aren''t carrying the ', object_word, '!')
- ELSE { everything is here}
- IF NOT N[n_num]^.lockable
- THEN WriteLn(IO, 'The ', noun, ' can''t be locked or unlocked!')
- ELSE
- IF NOT N[n_num]^.locked
- THEN WriteLn(IO, 'The ', noun, ' isn''t locked!')
- ELSE
- IF N[n_num]^.open
- THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(n_num), ' open. Why unlock ', It_Or_Them(n_num), '?')
- ELSE
- IF (N[n_num]^.key <> o_num)
- THEN WriteLn(IO, 'You can''t seem to unlock the ', noun,
- ' with the ', object_word, '.')
- ELSE { all is here, correct key}
- BEGIN
- N[n_num]^.locked := False;
- WriteLn(IO, 'You have now unlocked the ', Noun_S_Adj, ' ', noun,
- ', using the ', object_word, '.');
- END;
- END;
- END;
- END; { unlock}
-
- { lock (noun,prep,object) }
- { lock box with brass key or lock door}
-
- PROCEDURE Lock(noun, prep, object_word : words);
-
- VAR n_num, o_num : Integer;
- i : Integer;
- match : Boolean;
- Noun_S_Adj : words;
- BEGIN
- IF (noun = 'ALL') THEN
- BEGIN
- match := False;
- FOR i := First_noun TO MaxNoun DO
- IF Is_Visible(i) AND N[i]^.lockable
- THEN
- BEGIN
- Lock(N[i]^.name, prep, object_word); { Recursive}
- match := True;
- END;
- IF NOT match THEN WriteLn(IO, 'There''s nothing here to lock!');
- END
- ELSE
- BEGIN
- n_num := Noun_Number(noun);
- o_num := Noun_Number(object_word);
- Normalize(noun);
- Normalize(object_word);
- IF ((noun = 'door') OR (noun = 'doors'))
- { allows user defined DOOR nouns in room}
- AND (location(NounNumber) <> Current_room) THEN
- IF Room[Current_room]^.locked_door
- THEN WriteLn(IO, 'The door is already locked!')
- ELSE WriteLn(IO, 'You can''t lock these doors!')
- ELSE IF (prep = '') OR (prep <> 'WITH') THEN
- BEGIN
- WriteLn(IO, 'What a strange request! I really can''t figure out what you mean by that.');
- WriteLn(IO, 'Perhaps, you need to specify a tool to lock the ', noun, ' with.');
- syntax_error := True;
- END
- ELSE
- BEGIN
- Noun_S_Adj := Things_Adjective(n_num);
- IF (NOT Is_Visible(n_num))
- THEN WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun, ' ', Is_Or_Are(n_num), ' not here.')
- ELSE
- IF (location(o_num) <> Player)
- THEN WriteLn(IO, 'You aren''t carrying the ', object_word, '!')
- ELSE { everything is here}
- IF NOT N[n_num]^.lockable
- THEN WriteLn(IO, 'The ', noun, ' can''t be locked!')
- ELSE
- IF N[n_num]^.locked
- THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(n_num), ' already locked!')
- ELSE
- IF N[n_num]^.open
- THEN WriteLn(IO, 'The ', Noun_S_Adj, ' ', noun,
- ' has to be closed before you can lock ', It_Or_Them(n_num), '!')
- ELSE
- IF (N[n_num]^.key <> o_num)
- THEN WriteLn(IO, 'You can''t seem to lock the ', noun,
- ' with the ', object_word, '.')
- ELSE { all is here, correct key}
- BEGIN
- N[n_num]^.locked := True;
- WriteLn(IO, 'You have now locked the ', Noun_S_Adj, ' ', noun,
- ' securely with the ', object_word, '.');
- END;
- END;
- END;
- END; { lock}
-
- { Eat (noun) }
- { eat the apple pie or eat all of the food}
-
- PROCEDURE Eat(noun : words);
-
- VAR n_num : Integer;
- i : Integer;
- match : Boolean;
- BEGIN
- IF (noun = 'ALL') THEN
- BEGIN
- match := False;
- FOR i := First_noun TO MaxNoun DO
- IF Is_Visible(i) AND N[i]^.edible
- THEN
- BEGIN
- Eat(N[i]^.name); { Recursive}
- match := True;
- END;
- IF NOT match THEN WriteLn(IO, 'There''s nothing here to eat!');
- END
- ELSE
- BEGIN
- n_num := Noun_Number(noun);
- Normalize(noun);
- IF (NOT Is_Visible(n_num))
- THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(n_num), ' not here to eat!')
- ELSE IF ((n_num < First_noun) OR (n_num > MaxNoun))
- THEN WriteLn(IO, 'Eat the ', noun, '? You must be kidding!')
- ELSE IF NOT N[n_num]^.edible
- THEN WriteLn(IO, 'Eat the ', noun, '? You must be kidding!')
- ELSE Consume(noun);
- END;
- END;
-
- { Drink (noun) }
- { drink the red wine, or drink all of the water}
-
- PROCEDURE Drink(noun : words);
-
- VAR n_num : Integer;
- i : Integer;
- match : Boolean;
- BEGIN
- IF (noun = 'ALL') THEN
- BEGIN
- match := False;
- FOR i := First_noun TO MaxNoun DO
- IF Is_Visible(i) AND N[i]^.drinkable
- THEN
- BEGIN
- Drink(N[i]^.name); { RECURSIVE}
- match := True;
- END;
- IF NOT match THEN WriteLn(IO, 'There''s nothing here to drink!');
- END
- ELSE
- BEGIN
- n_num := Noun_Number(noun);
- Normalize(noun);
- IF (NOT Is_Visible(n_num))
- THEN WriteLn(IO, 'The ', noun, 'is not here to drink.')
- ELSE IF ((n_num < First_noun) OR (n_num > MaxNoun))
- THEN WriteLn(IO, 'You must be joking about drinking the ', noun, '!')
- ELSE IF NOT N[n_num]^.drinkable
- THEN WriteLn(IO, 'You must be joking about drinking the ', noun, '!')
- ELSE Consume(noun);
- END;
- END;
-
- { Inventory }
- { displays items being carried and items being worn (if any)}
-
- PROCEDURE Inventory;
-
- VAR i : Integer;
- st : words;
- BEGIN
- IF Items_Being_Carried > 0
- THEN BEGIN
- WriteLn(IO, 'You are carrying the following:');
- FOR i := First_noun TO MaxNoun DO
- IF N[i]^.location = Player THEN
- BEGIN
- st := ' ';
- IF (N[i]^.adj <> 'NO_ADJ') THEN st := st+N[i]^.adj+' ';
- st := st+N[i]^.name;
- Normalize(st);
- WriteLn(IO, st);
- IF N[i]^.open THEN List_Contents(i, 2);
- END;
- END {something being carried}
- ELSE WriteLn(IO, 'You aren''t carrying anything.');
- IF Items_Being_Worn > 0
- THEN BEGIN
- WriteLn(IO, 'You are wearing the following:');
- FOR i := First_noun TO MaxNoun DO
- IF N[i]^.location = Wearing THEN
- BEGIN
- st := ' ';
- IF (N[i]^.adj <> 'NO_ADJ') THEN st := st+N[i]^.adj+' ';
- st := st+N[i]^.name;
- Normalize(st);
- WriteLn(IO, st);
- IF N[i]^.open THEN List_Contents(i, 2);
- END;
- END; {something being worn}
- {ELSE -- don't print anything if nothing being worn}
- END; { inventory}
-
- { Read (noun) }
- { read the scroll or read the cereal box}
-
- PROCEDURE Read_Noun(noun : words);
-
- VAR num : Integer;
- BEGIN
- IF (noun = 'ALL')
- THEN WriteLn(IO, 'Not everything at once - one at a time!')
- ELSE
- BEGIN
- num := Noun_Number(noun);
- IF (NOT Is_Visible(num))
- THEN
- BEGIN
- Normalize(noun);
- Write(IO, 'The ', noun, ' ', Is_Or_Are(num), ' not here --');
- WriteLn(IO, ' which makes ', It_Or_Them(num), ' difficult to read!');
- END
- ELSE
- IF NOT N[num]^.readable
- THEN BEGIN
- Normalize(noun);
- WriteLn(IO, 'It is somewhat difficult to read the ', noun,
- '...let me try to describe ', It_Or_Them(num), '.');
- Describe(noun);
- END
- ELSE Describe_It('TEXT', num);
- END; { if all..else}
- END; { read}
-
- { Light (noun) }
- { turn on the flashlight or light the fire}
-
- PROCEDURE light(noun : words);
-
- VAR num : Integer;
- BEGIN
- {$V-} Capitalize(noun);
- num := Noun_Number(noun);
- Normalize(noun);
- {$V+} IF (num < First_noun) OR (num > MaxNoun)
- THEN WriteLn(IO, 'Sorry, I don''t know how to do that with the ', noun)
- ELSE IF NOT N[num]^.is_light
- THEN WriteLn(IO, 'Sorry, I don''t know how to do that with the ', noun)
- ELSE IF N[num]^.on
- THEN IF verb = 'LIGHT'
- THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' already lit!')
- ELSE WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' already on!')
- ELSE BEGIN
- N[num]^.on := True;
- IF verb = 'LIGHT'
- THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now lit!')
- ELSE WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now on!');
- END;
- END; { light}
-
- { Extinguish (noun) }
- { turn off the flashlight or extingusih the fire}
-
- PROCEDURE Extinguish(noun : words);
-
- VAR num : Integer;
- BEGIN
- {$V-} Capitalize(noun);
- num := Noun_Number(noun);
- Normalize(noun);
- {V$+} IF (num < First_noun) OR (num > MaxNoun)
- THEN WriteLn(IO, 'Sorry, I don''t know how to do that with the ', noun)
- ELSE IF NOT N[num]^.is_light
- THEN WriteLn(IO, 'Sorry, I don''t know how to do that with the ', noun)
- ELSE IF NOT N[num]^.on
- THEN IF verb = 'EXTINGUISH'
- THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' not even lit!')
- ELSE WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' not even on!')
- ELSE BEGIN
- N[num]^.on := False;
- IF verb = 'EXTINGUISH'
- THEN WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now extinguished!')
- ELSE WriteLn(IO, 'The ', noun, ' ', Is_Or_Are(num), ' now off!');
- END;
- END; { light}
-
- { Quit }
- { e.g., quit the game}
-
- PROCEDURE Quit;
-
- VAR reply : s;
- BEGIN
- Write(IO, 'Are you sure you want to quit now? (y/n) ');
- reply := GetInputString;
- IF (reply = 'Y') OR (reply = 'YES')
- THEN WriteLn(IO, 'OK - quitting game.')
- ELSE verb := 'qwerty';
- END; { quit}
-
- { Show_score }
- { e.g., display the score}
-
- PROCEDURE show_score;
-
- VAR i, r, J, P, t : Integer;
- BEGIN
- IF player_dead THEN
- BEGIN
- WriteLn(IO, ' ');
- WriteLn(IO, '*** You are dead. ***');
- WriteLn(IO, ' ');
- END;
- IF game_won THEN
- BEGIN
- WriteLn(IO, ' ');
- WriteLn(IO, '*** Congratulations. You have won the game. ***');
- WriteLn(IO, ' ');
- END;
- i := 0; { number of rooms seen}
- r := 0; { number of defined rooms}
- FOR J := First_Room TO MaxRoom DO
- BEGIN
- IF Room[J]^.has_seen THEN i := i+1;
- IF (Room[J]^.name <> 'none') THEN r := r+1;
- END;
- WriteLn(IO, 'You have seen ', i, ' locations (out of ', r, '), in ', Num_turns, ' turns.');
- P := ScoreAdjustment; { player's points scored -- adjusted}
- t := 0; { total points possible}
- FOR i := First_Room TO MaxRoom DO
- BEGIN
- IF Room[i]^.has_seen THEN P := P+Room[i]^.points;
- IF (Room[i]^.name <> 'none') THEN t := t+Room[i]^.points;
- END;
- FOR i := First_noun TO MaxNoun DO
- BEGIN { give points for items carried, worn, in room, or in Treasure_Room}
- IF (Is_Visible(i)) OR (location(i) = Treasure_Room) THEN P := P+N[i]^.points;
- IF (N[i]^.name <> 'none') THEN t := t+N[i]^.points;
- END;
- IF MaxCreature > 0 THEN FOR i := First_creature TO MaxCreature DO
- BEGIN { give points for creatures in room}
- IF Is_Visible(i) THEN P := P+M[i]^.points;
- IF (M[i]^.name <> 'none') THEN t := t+M[i]^.points;
- END;
- IF Maximum_Score > 0 THEN t := Maximum_Score; {If max score -- use it}
- WriteLn(IO, 'Your score is ', P, ' out of a possible ', t, ' points.');
- WriteLn(IO, '(This game was saved ', Num_saves, ' times and restored ',
- num_restores, ' times.)');
- END;
-
- { Function ScoreValue }
- { e.g., calculate and return the score}
-
- FUNCTION ScoreValue : Integer;
-
- VAR i, P : Integer;
- BEGIN
- P := ScoreAdjustment; { player's points scored -- adjusted}
- FOR i := First_Room TO MaxRoom DO
- IF Room[i]^.has_seen THEN P := P+Room[i]^.points;
- FOR i := First_noun TO MaxNoun DO
- { give points for items carried, worn, in room, or in Treasure_Room}
- IF (Is_Visible(i)) OR (location(i) = Treasure_Room) THEN P := P+N[i]^.points;
- IF MaxCreature > 0 THEN FOR i := First_creature TO MaxCreature DO
- { give points for creatures in room}
- IF Is_Visible(i) THEN P := P+M[i]^.points;
- ScoreValue := P;
- END; {ScoreValue}
-
- { Do_Nothing}
- { i.e., wait }
-
- PROCEDURE Do_Nothing;
-
- BEGIN
- WriteLn(IO, 'Time passes...');
- END;
-
- { Scream!}
-
- PROCEDURE Scream;
-
- BEGIN
- WriteLn(IO, ' ');
- WriteLn(IO, 'YYYYAAAAAAAUUUUUUGGGGGGGHHHHHHH YAI YAI YOW! AAAAUUUUGGGHHHH!!');
- WriteLn(IO, ' ');
- WriteLn(IO, 'Your voice echoes loudly through the area, and the volume of ');
- WriteLn(IO, 'your shriek causes the very ground to vibrate. You feel much ');
- WriteLn(IO, 'better having let out some steam, but nothing else has changed.');
- WriteLn(IO, ' ');
- END;
-
- { SCRIPT }
- { Causes all output to go to both screen and printer}
-
- PROCEDURE Script;
-
- { PRTEST }
- { Turbo Pascal routines to read printer status}
-
- FUNCTION PrTest(WhichPrt : Integer) : Boolean;
- VAR reg : registers;
- i : Word;
- BEGIN
- reg.ax := $0200;
- reg.dx := WhichPrt AND $0002; { Don't Allow Greater than 2}
- INTR($17, Dos.registers(reg)); { 0 = 1st Ptr, 1 = 2nd Ptr }
- i := ((reg.ax AND $ff00) SHR 8);
- { prtest returns 8 Printer Deselected
- 40 Out of Paper
- 136 Printer off line
- 144 All OK
- Bit Test is
- 0 = Timeout
- 1,2 = Unused
- 3 = I/O Error
- 4 = Selected
- 5 = Out of Paper
- 6 = Acknowledge
- 7 = Not Busy}
- IF (i = 144) THEN PrTest := True
- ELSE PrTest := False;
- END; {PrTest}
-
- BEGIN {SCRIPT}
- IF PrTest(0) THEN
- BEGIN
- Scripting := True;
- WriteLn(IO, 'OK.');
- END
- ELSE WriteLn(IO, ' *** Printer is not ready to Print ***');
- END; {SCRIPT}
-
- { UNSCRIPT }
- { Causes all output to go to only the screen}
-
- PROCEDURE UNScript;
-
- BEGIN
- Scripting := False;
- WriteLn(IO, 'OK.');
- END;
-
- { RESURRECT }
- { Give player another chance after moving}
- { him back to the starting room }
-
- PROCEDURE Resurrect;
-
- VAR
- Answer : s;
- BEGIN
- ResurrectedFlag := False;
- WriteLn(IO, ' ');
- player_dead := False; {resurrect player except if all lives used}
- DoingCompoundCommands := False;
- IF Current_Life = 1 THEN
- BEGIN
- WriteLn(IO, 'Oh dear, you seem to have gotten yourself killed.');
- WriteLn(IO, ' ');
- Write(IO, 'Would you like me to try to get you resurrected?.... ');
- END;
- IF (Current_Life > 1) AND (Current_Life <= Max_Lives) THEN
- BEGIN
- WriteLn(IO, 'Oh you clumsy oaf, you''ve gone and done it again!');
- WriteLn(IO, 'I don''t know how long I can keep patching you up....');
- Write(IO, 'Would you like me to try to get you resurrected again?.... ');
- END;
- IF Current_Life > Max_Lives THEN
- BEGIN
- player_dead := True; {resurrection no longer possible}
- WriteLn(IO, 'I''m all out of orange smoke, and you''ve used all of');
- WriteLn(IO, 'your available lives. Better luck next time!');
- END
- ELSE BEGIN
- Answer := GetInputString;
- WriteLn(IO, ' ');
- IF Answer[1] IN ['Y', 'y']
- THEN BEGIN
- ResurrectedFlag := True;
- Current_Life := Current_Life+1; {used up one life}
- Current_room := Resurrection_Room; {send back to Resurrection (Starting) room}
- WriteLn(IO, 'I''ll try...but don''t blame me if something goes wr@#%&&');
- WriteLn(IO, ' ');
- WriteLn(IO, ' ---- POOF----');
- WriteLn(IO, ' ');
- WriteLn(IO, 'You are engulfed in a cloud of thick orange smoke, and');
- WriteLn(IO, 'you emerge coughing and gasping, and find that');
- WriteLn(IO, 'you must start all over ...');
- WriteLn(IO, ' ');
- morecount := 9;
- Describe_It('ROOM_DESCR', Current_room);
- END
- ELSE BEGIN
- player_dead := True; {resurrection no longer wanted}
- WriteLn(IO, 'OKay. If you''re so smart, do it yourself! I''m leaving!');
- END;
- END;
- END; {resurrent}
-