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

« back to all changes in this revision

Viewing changes to inform-6.31.1/manual/s17.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<html>
 
3
<head>
 
4
<title>DM4 &#167;17: People and animals</title>
 
5
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 
6
<link rel="stylesheet" type="text/css" href="dm4.css">
 
7
</head>
 
8
<body>
 
9
<p class="navbar">
 
10
 <a href="index.html">home</a> /
 
11
 <a href="contents.html">contents</a> /
 
12
 <a href="ch3.html" title="Chapter III: The Model World">chapter III</a> /
 
13
 <a href="s16.html" title="&#167;16: Reading matter and consultation">prev</a> /
 
14
 <a href="s18.html" title="&#167;18: Making conversation">next</a> /
 
15
 <a href="dm4index.html">index</a>
 
16
</p>
 
17
<div class="page">
 
18
<a id="p144" name="p144"></a>
 
19
<h2>&#167;17 &nbsp; People and animals</h2>
 
20
 
 
21
<blockquote>To know how to live is my trade and my art.<br>
 
22
&#8212; Michel de Montaigne (1533&#8211;1592), <i>Essays</i></blockquote>
 
23
 
 
24
<p class="normal"><span class="atleft"><img src="dm4-144_1.jpg" alt=""></span>
 
25
Living creatures should be given the attribute <code>animate</code> so that the
 
26
library knows such an object can be talked to, given things, woken from 
 
27
sleep and so on. When the player treats an <code>animate</code> object 
 
28
as living in this way, the library calls upon that object's <code>life</code> property.
 
29
This looks like <code>before</code> or <code>after</code>, but only 
 
30
applies to the following actions:</p>
 
31
 
 
32
<div class="inset"><dl>
 
33
<dt><code>Attack</code></dt><dd>The player is making hostile advances&#8230;</dd>
 
34
<dt><code>Kiss</code></dt><dd>&#8230; or amorous ones&#8230;</dd> 
 
35
<dt><code>WakeOther</code></dt><dd>&#8230; or simply trying to rouse the creature from sleep.</dd>
 
36
<dt><code>ThrowAt</code></dt><dd>The player asked to throw <code>noun</code> at the creature.</dd>
 
37
<dt><code>Give</code></dt><dd>The player asked to give <code>noun</code> to the creature&#8230;</dd>
 
38
<dt><code>Show</code></dt><dd>&#8230; or, tantalisingly, just to show it.</dd>
 
39
<dt><code>Ask</code></dt><dd>The player asked about something. Just as with a 
 
40
&#8220;consult&#8221; topic (see <a href="s16.html">&#167;16</a> 
 
41
above), the variables <code>consult_from</code> and <code>consult_words</code>
 
42
are set up to indicate which words the object might like to think
 
43
about. (In addition, <code>second</code> holds the dictionary value 
 
44
for the first word which isn't <tt>'the'</tt>, but this is much 
 
45
cruder.)</dd>
 
46
<dt><code>Tell</code></dt><dd>The player is trying to tell the creature about 
 
47
something. The topic is set up just as for <code>Ask</code> (that 
 
48
is, <code>consult_from</code> and <code>consult_words</code> are 
 
49
set, and <code>second</code> also holds the first interesting
 
50
word).</dd>
 
51
<dt><code>Answer</code></dt><dd>This can happen in two ways. One is if the player 
 
52
types &#8220;answer some text to troll&quot; or &#8220;say some text 
 
53
to troll&#8221;; the other is if an order is given which the parser 
 
54
can't sort out, such as &#8220;troll, og south&quot;, and which the 
 
55
<code>orders</code> property hasn't handled already. Once again, 
 
56
variables are set as if it were a &#8220;consult&#8221; topic. 
 
57
(In addition, <code>noun</code> is set to the first word, and an 
 
58
attempt to read the text as a number is stored in the variable 
 
59
<code>special_number</code>: for instance, &#8220;computer, 143&#8221; 
 
60
will cause <code>special_number</code> to be set to 143.)</dd>
 
61
<dt><code>Order</code></dt><dd>This catches any &#8216;orders&#8217; which 
 
62
aren't handled by the <code>orders</code> property (see the next 
 
63
section); <code>action</code>, <code>noun</code> and <code>second</code> 
 
64
are set up as usual.</dd>
 
65
</dl></div>
 
66
 
 
67
<a id="p145" name="p145"></a>
 
68
<p class="normal">If the <code>life</code> rule isn't given, or 
 
69
returns <code>false</code>, events take their usual course.
 
70
<code>life</code> rules vary dramatically in size. The coiled snake 
 
71
from &#8216;Balances&#8217; shows that even the tiniest <code>life</code> 
 
72
routine can be adequate for an animal:</p>
 
73
 
 
74
<p class="lynxonly"></p>
 
75
<pre class="code">
 
76
Object -&gt; snake &quot;hissing snake&quot;
 
77
  with name 'hissing' 'snake',
 
78
       initial &quot;Tightly coiled at the edge of the chasm is a
 
79
           hissing snake.&quot;,
 
80
       life &quot;The snake hisses angrily!&quot;,
 
81
  has  animate;
 
82
</pre>
 
83
 
 
84
<p class="normal">It's far from unknown for people in interactive 
 
85
fiction to be almost as simplistic as that, but in most games even 
 
86
relatively passive characters have some ability to speak or react. 
 
87
Here is the funerary priest standing in the &#8216;Ruins&#8217; Shrine:</p>
 
88
 
 
89
<p class="lynxonly"></p>
 
90
<pre class="code">
 
91
Object priest &quot;mummified priest&quot;
 
92
  with name 'mummified' 'priest',
 
93
       description
 
94
           &quot;He is desiccated and hangs together only by will-power.
 
95
           Though his first language is presumably local Mayan,
 
96
           you have the curious instinct that he will understand
 
97
           your speech.&quot;,
 
98
       initial &quot;Behind the slab, a mummified priest stands waiting,
 
99
           barely alive at best, impossibly venerable.&quot;,
 
100
       life [;
 
101
           Answer: &quot;The priest coughs, and almost falls apart.&quot;;
 
102
           Ask: switch (second) {
 
103
               'dictionary', 'book':
 
104
                   if (dictionary.correct == false)
 
105
                       &quot;~The ~bird~ glyph... very funny.~&quot;;
 
106
                   &quot;~A dictionary? Really?~&quot;;
 
107
               'glyph', 'glyphs', 'mayan', 'dialect':
 
108
                   &quot;~In our culture, the Priests are ever
 
109
                   literate.~&quot;;
 
110
               'lord', 'tomb', 'shrine', 'temple':
 
111
                   &quot;~This is a private matter.~&quot;;
 
112
               'ruins': &quot;~The ruins will ever defeat thieves.
 
113
                   In the underworld, looters are tortured
 
114
                   throughout eternity.~ A pause. ~As are
 
115
                   archaeologists.~&quot;;<a id="p146" name="p146"></a>
 
116
               'web', 'wormcast':
 
117
                   &quot;~No man can pass the Wormcast.~&quot;;
 
118
               'xibalba': if (Shrine.sw_to == Junction)
 
119
                       &quot;The priest shakes his bony finger.&quot;;
 
120
                   Shrine.sw_to = Junction;
 
121
                   &quot;The priest extends one bony finger
 
122
                   southwest toward the icicles, which
 
123
                   vanish like frost as he speaks.
 
124
                   ~Xibalb@'a, the Underworld.~&quot;;
 
125
               }
 
126
               &quot;~You must find your own answer.~&quot;;
 
127
           Tell: &quot;The priest has no interest in your sordid life.&quot;;
 
128
           Attack, Kiss:
 
129
               remove self;
 
130
               &quot;The priest desiccates away into dust until nothing
 
131
               remains, not a breeze nor a bone.&quot;;
 
132
           ThrowAt: move noun to location; &lt;&lt;Attack self&gt;&gt;;
 
133
           Show, Give:
 
134
               if (noun == dictionary &amp;&amp; dictionary.correct == false) {
 
135
                   dictionary.correct = true;
 
136
                   &quot;The priest reads a little of the book, laughing
 
137
                   in a hollow, whispering way. Unable to restrain
 
138
                   his mirth, he scratches in a correction somewhere
 
139
                   before returning the book.&quot;;
 
140
               }
 
141
               &quot;The priest is not interested in earthly things.&quot;;
 
142
       ],
 
143
  has  animate;
 
144
</pre>
 
145
 
 
146
<p class="normal">The Priest only stands and waits, but some 
 
147
characters need to move around, or to appear and reappear throughout 
 
148
a game, changing in their responses and what they know. This makes 
 
149
for a verbose object definition full of cross-references to 
 
150
items and places scattered across the source code. An 
 
151
alternative is to use different objects to represent the character 
 
152
at different times or places: in &#8216;Jigsaw&#8217;, for instance, 
 
153
the person called &#8220;Black&#8221; is seven different objects.</p>
 
154
 
 
155
<p class="dotbreak">� � � � �</p>
 
156
 
 
157
<p class="normal">Animate objects representing people with proper 
 
158
names, like &#8220;Mark Antony&#8221;, need to be given the <code>proper</code> 
 
159
attribute, and those with feminine names, such as &#8220;Cleopatra&#8221;, 
 
160
need to be both <code>female</code> and <code>proper</code>, 
 
161
though of course history would have been very different if&#8230; 
 
162
Inanimate objects sometimes have proper names, too: Waldeck's 
 
163
Mayan dictionary in <a href="s16.html">&#167;16</a> was given 
 
164
<code>proper</code>. See <a href="s26.html">&#167;26</a> for
 
165
more on naming.</p>
 
166
 
 
167
<a id="p147" name="p147"></a>
 
168
<p class="dotbreak">� � � � �</p>
 
169
 
 
170
<p class="normal">Some objects are not alive as such, but can still 
 
171
be spoken to: microphones, tape recorders and so on. It would be 
 
172
a nuisance to implement these as <code>animate</code>, since 
 
173
they have none of the other characteristics of life. Instead,
 
174
they can be given just the attribute <code>talkable</code>, making 
 
175
them responsive only to conversation. They have a <code>life</code> property 
 
176
to handle <code>Answer</code> and so on, but it will never be asked 
 
177
to deal with, for instance, <code>Kiss</code>. Talkable objects can 
 
178
also receive orders: see the next section.</p>
 
179
 
 
180
<p class="dotbreak">� � � � �</p>
 
181
 
 
182
<p class="normal">Designers often imagine animate objects as 
 
183
being altogether different from things, so it's worth noting that 
 
184
all the usual Inform rules apply equally well to the living. An 
 
185
<code>animate</code> object still has <code>before</code> and 
 
186
<code>after</code> routines like any other, so the short list of 
 
187
possible <code>life</code> rules is not as restrictive as it appears.
 
188
Animate objects can also <code>react_before</code> and 
 
189
<code>react_after</code>, and it's here that these properties really 
 
190
come into their own:</p>
 
191
 
 
192
<p class="lynxonly"></p>
 
193
<pre class="code">
 
194
react_before [;
 
195
    Drop: if (noun == satellite_gadget)
 
196
        print &quot;~I wouldn't do that, Mr Bond,~ says Blofeld.^^&quot;;
 
197
    Shoot: remove beretta;
 
198
        &quot;As you draw, Blofeld snaps his fingers and a giant
 
199
        magnet snatches the gun from your hand. It hits the
 
200
        ceiling with a clang. Blofeld silkily strokes his cat.&quot;;
 
201
];
 
202
</pre>
 
203
 
 
204
<p class="normal">If Blofeld moves from place to place, these rules 
 
205
usefully move with him.</p>
 
206
 
 
207
<p class="indent">Animate objects often have possessions as part 
 
208
of the game design. Two examples, both from &#8216;The Lurking 
 
209
Horror&#8217;:</p>
 
210
 
 
211
<ul>
 
212
<li>an urchin with something bulging inside his jacket pocket;</li>
 
213
<li>a hacker who has a bunch of keys hanging off his belt.</li>
 
214
</ul>
 
215
 
 
216
<p class="normal">Recall from <a href="s12.html">&#167;12</a> 
 
217
that the child-objects of an object which isn't a <code>container</code>
 
218
or <code>supporter</code> are outwardly visible only if the object 
 
219
has the <code>transparent</code> attribute. Here, the hacker should 
 
220
have <code>transparent</code> and the urchin not. The parser then 
 
221
prevents the player from referring to whatever the urchin is hiding,
 
222
even if the player has played the game before and knows what is 
 
223
in there.</p>
 
224
 
 
225
<a id="ex26" name="ex26"></a>
 
226
<p class="aside"><span class="warning"><b>&#8226;</b>
 
227
<b><a href="sa6.html#ans26">EXERCISE 26</a></b></span><br>
 
228
Arrange for a bearded psychiatrist to place the player under observation, 
 
229
occasionally mumbling insights such as &#8220;Subject puts green 
 
230
cone on table. Interesting.&#8221;</p>
 
231
 
 
232
</div>
 
233
<p class="navbar">
 
234
 <a href="index.html">home</a> /
 
235
 <a href="contents.html">contents</a> /
 
236
 <a href="ch3.html" title="Chapter III: The Model World">chapter III</a> /
 
237
 <a href="s16.html" title="&#167;16: Reading matter and consultation">prev</a> /
 
238
 <a href="s18.html" title="&#167;18: Making conversation">next</a> /
 
239
 <a href="dm4index.html">index</a>
 
240
</p>
 
241
</body>
 
242
</html>
 
243
 
 
244