~ubuntu-branches/ubuntu/vivid/inform/vivid

« back to all changes in this revision

Viewing changes to html/section20.html

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-05-26 22:09:44 UTC
  • mfrom: (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080526220944-ba7phz0d1k4vo7wx
Tags: 6.31.1+dfsg-1
* Remove a considerable number of files from the package
  due to unacceptable licensing terms.
* Repair library symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<HTML><HEAD><TITLE>Section 20: Miscellaneous constants and scoring</TITLE></HEAD>
2
 
<BODY BGCOLOR="#FFFFFF">
3
 
<TABLE><P>
4
 
<TR><TD Valign="top"><A HREF="contents.html">Contents</A><BR><A HREF="section19.html">Back</A><BR><A HREF="section21.html">Forward</A><TD bgcolor="#F5DEB3"><BLOCKQUOTE><H3>20. Miscellaneous constants and scoring</H3></BLOCKQUOTE><TR><TD><TD>
5
 
<P>
6
 
 
7
 
<BLOCKQUOTE>
8
 
<BR>For when the One Great Scorer comes
9
 
<BR>To write against your name,
10
 
<BR>He marks -- not that you won or lost --
11
 
<BR>But how you played the game.
12
 
<BR><P>...Grantland Rice (<B>1880</B>--<B>1954</B>), <I>Alumnus Football</I></BLOCKQUOTE>
13
 
<P>
14
 
 
15
 
 
16
 
Some game rules can be altered by defining 'constants' at the start of
17
 
the program.  Two constants you <I> must</I> provide (and before including
18
 
any of the library files) are the strings <TT>Story</TT> and <TT>Headline</TT>:
19
 
<PRE>
20
 
Constant Story "ZORK II";
21
 
Constant Headline "^An Interactive Plagiarism^
22
 
             Copyright (c) 1995 by Ivan O. Ideas.^";
23
 
</PRE>
24
 
 
25
 
All the rest are optional, but should be defined before <TT>Verblib</TT>
26
 
is included if they're to take effect.
27
 
<P>
28
 
 
29
 
<P>
30
 
The library won't allow the player to carry an indefinite number of
31
 
objects: the limit allowed is the constant <TT>MAX_CARRIED</TT>, which you
32
 
may define if you wish.  If you don't define it, it's 100, which
33
 
nearly removes the rule.  In fact you can change this during play,
34
 
since it is actually the <TT>capacity</TT> of the <TT>player</TT> which is
35
 
consulted; the only use of <TT>MAX_CARRIED</TT> is to set this up to
36
 
an initial value.
37
 
<P>
38
 
 
39
 
If you define <TT>SACK_OBJECT</TT> to be some container, then the player will
40
 
automatically put old, least-used objects away in it as the game
41
 
progresses, provided it is being carried.  This is a feature which
42
 
endears the designer greatly to players.  For instance,
43
 
the following code appears (in between inclusion of <TT>Parser</TT>
44
 
and <TT>Verblib</TT>) in 'Toyshop':
45
 
<PRE>
46
 
Object satchel "satchel"
47
 
  with description "Big and with a smile painted on it.",
48
 
       name "satchel", article "your",
49
 
       when_closed "Your satchel lies on the floor.",
50
 
       when_open "Your satchel lies open on the floor.",
51
 
  has  container open openable;
52
 
Constant SACK_OBJECT satchel;
53
 
</PRE>
54
 
 
55
 
'Ruins' isn't going to provide this feature, because there
56
 
are few portable objects and those there are would be incongruous
57
 
if described as being in a rucksack.
58
 
<P>
59
 
 
60
 
<P>
61
 
Another constant is <TT>AMUSING_PROVIDED</TT>.  If you define this, the library
62
 
knows to put an "amusing" option on the menu after the game is won.
63
 
It will then call <TT>Amusing</TT> from your code when needed.  You can
64
 
use this to roll closing credits, or tell the player various strange
65
 
things about the game, now that there's no surprise left to spoil.
66
 
 
67
 
<P>
68
 
 
69
 
<P>
70
 
The other constants you are allowed to define help the score routines
71
 
along.  There are two scoring systems provided by the library, side by
72
 
side: you can use both or neither.  You can always do what you like to
73
 
the <TT>score</TT> variable in any case, though the "fullscore'' verb might
74
 
then not fully account for what's happened.
75
 
One scores points for getting certain
76
 
items or reaching certain places; the other for completing certain
77
 
actions.  These constants are:
78
 
 
79
 
<BR><TABLE Border><TR><TD><TT>MAX_SCORE</TT> <TD> the maximum game score (by default 0);
80
 
<TR><TD><TT>NUMBER_TASKS</TT> <TD> number of individual "tasks" to perform (1);
81
 
<TR><TD><TT>OBJECT_SCORE</TT> <TD> bonus for first picking up a <TT>scored</TT> object (4);
82
 
<TR><TD><TT>ROOM_SCORE</TT> <TD> bonus for first entering a <TT>scored</TT> room (5)
83
 
</TABLE>
84
 
and then the individual tasks have scores, as follows:
85
 
<PRE>
86
 
Array task_scores -&#62; t1 t2 ... tn;
87
 
</PRE>
88
 
 
89
 
As this is a byte array, the task scores must be between 0 and 255.
90
 
Within your code, when a player achieves something, call <TT>Achieved(task)</TT>
91
 
to mark that the task has been completed.  It will only award points if
92
 
this task has not been completed before.  There do not have to be any
93
 
"tasks": there's no need to use the scoring system provided.  Tasks
94
 
(and the verb "full" for full score) will only work at all if you define
95
 
the constant <TT>TASKS_PROVIDED</TT>.
96
 
The entry point <TT>PrintTaskName</TT> prints the name of a game task (but, of
97
 
course, is only ever called in a game with <TT>TASKS_PROVIDED</TT> defined).
98
 
For instance, ('Toyshop' again)
99
 
<PRE>
100
 
[ PrintTaskName ach;
101
 
  switch(ach)
102
 
  {   0: "eating a sweet";
103
 
      1: "driving the car";
104
 
      2: "shutting out the draught";
105
 
      3: "building a tower of four";
106
 
      4: "seeing which way the mantelpiece leans";
107
 
  }
108
 
];
109
 
</PRE>
110
 
 
111
 
 
112
 
Another entry point, called <TT>PrintRank</TT>, gets the chance to print
113
 
something additional to the score (traditionally, though not
114
 
necessarily, rankings).  For instance, we bid farewell to the
115
 
'Ruins' with the following:
116
 
<PRE>
117
 
[ PrintRank;
118
 
  print ", earning you the rank of ";
119
 
  switch(score)
120
 
  {   0 to 9:   "humble rainforest Tourist.";
121
 
      10 to 19: "Investigator.";
122
 
      20 to 29: "Acquisitor.";
123
 
      30 to 49: "Archaeologist.";
124
 
      50:       "Master Archaeologist.";
125
 
  }
126
 
];
127
 
</PRE>
128
 
<P>
129
 
 
130
 
<P>
131
 
 
132
 
Normally, an Inform game will print messages like
133
 
<BLOCKQUOTE>
134
 
[Your score has gone up by three points.]
135
 
</BLOCKQUOTE>
136
 
 
137
 
when the score changes (by whatever means).  The player can turn this on and
138
 
off with the "notify'' verb; by default it is on.  (You can alter the flag
139
 
<TT>notify_mode</TT> yourself to control this.)
140
 
<P>
141
 
 
142
 
The verbs "objects'' and "places'' are usually provided, so the player
143
 
can get a list of all handled objects (and where they now are), and all
144
 
places visited.  If you don't want these to be present, define the constant
145
 
<TT>NO_PLACES</TT> before inclusion of the
146
 
library.
147
 
<P>
148
 
 
149
 
<P><TR><TD Valign="top"><IMG SRC="icons/dexercise.gif" ALT="??/\"><TD bgcolor="#FBB9AC"><A NAME="ex46"><B>EXERCISE 46:</B><BR>(link to <A HREF="answers1/answer46.html">the answer</A>)<TR><TD><TD> Suppose one single room object is used internally for the
150
 
64 squares of a gigantic chessboard, each of which is a different location
151
 
to the player.  Then "places'' is likely to result in only the last-visited
152
 
square being listed.  Fix this.
153
 
<P>
154
 
 
155
 
<P><TR><TD Valign="top"><IMG SRC="icons/refs.gif" ALT="*"><TD bgcolor="#EEEEEE"><B>REFERENCES:</B><BR><SMALL>  'Advent' contains ranks and an <TT>Amusing</TT> reward (but doesn't use
156
 
either of these scoring systems, instead working by hand).
157
 
<BR>
158
 
'Balances' uses <TT>scored</TT> objects (for its cubes).
159
 
<BR>
160
 
'Toyshop' has tasks, as above.
161
 
<BR>
162
 
'Adventureland' uses its <TT>TimePasses</TT> entry point to recalculate the
163
 
score every turn (and watch for victory).
164
 
</TABLE>
165
 
<HR><A HREF="contents.html">Contents</A> / <A HREF="section19.html">Back</A> / <A HREF="section21.html">Forward</A> <BR>
166
 
<A HREF="chapter1.html">Chapter I</A> / <A HREF="chapter2.html">Chapter II</A> / <A HREF="chapter3.html">Chapter III</A> / <A HREF="chapter4.html">Chapter IV</A> / <A HREF="chapter5.html">Chapter V</A> / <A HREF="chapter6.html">Chapter VI</A> / <A HREF="chapterA.html">Appendix</A><HR><SMALL><I>Mechanically translated to HTML from third edition as revised 16 May 1997. Copyright &#169; Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.</I></SMALL></BODY></HTML>