1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4
<title>DM4 §8: Places and scenery</title>
5
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6
<link rel="stylesheet" type="text/css" href="dm4.css">
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="ch3.html" title="Chapter III: The Model World">prev</a> /
14
<a href="s9.html" title="§9: Directions and the map">next</a> /
15
<a href="dm4index.html">index</a>
18
<a id="p116" name="p116"></a>
19
<h2>§8 Places and scenery</h2>
21
<p class="normal"><span class="atleft"><img src="dm4-116_1.jpg" alt=""></span>
22
In this longer chapter the model world of an Inform game will be
23
explored and examples will gradually complete the ‘Ruins’
24
begun in Chapter II. So far, ‘Ruins’ contains just a
25
location of rainforest together with some rules about photography.
26
The immediate need is for a more substantial map, beginning with a
27
sunken chamber. Like the Forest, this too has <code>light</code>, however dim. If
28
it didn't, the player would never see it: in Inform's world darkness
29
prevails unless the designer provides some kind of lamp or, as in this
30
case, ambient light.</p>
32
<p class="lynxonly"></p>
34
Object Square_Chamber "Square Chamber"
35
with name 'lintelled' 'lintel' 'lintels' 'east' 'south' 'doorways',
37
"A sunken, gloomy stone chamber, ten yards across. A shaft
38
of sunlight cuts in from the steps above, giving the
39
chamber a diffuse light, but in the shadows low lintelled
40
doorways to east and south lead into the deeper darkness
45
<p class="normal">This room has a <code>name</code> property even
46
though rooms are not usually referred to by players. The nouns given
47
are words which Inform knows “you don't need to refer to”,
48
and it's a convention of the genre that the designer should signpost
49
the game in this way. For the game to talk about something and later
50
deny all knowledge – “I can't see any such thing”
51
– is not merely rude but harmful to the player's illusion of
52
holding a conversation about a real world. Better to parry with:</p>
54
<p class="output">><tt>examine lintel</tt><br><a id="p117" name="p117"></a>
55
That's not something you need to refer to in the course of this game.</p>
57
<p class="dotbreak">� � � � �</p>
59
<p class="normal">Not all of the Square Chamber's décor is so
62
<p class="lynxonly"></p>
64
Object -> "carved inscriptions"
65
with name 'carved' 'inscriptions' 'carvings' 'marks' 'markings'
66
'symbols' 'moving' 'scuttling' 'crowd' 'of',
68
"Carved inscriptions crowd the walls, floor and ceiling.",
70
"Each time you look at the carvings closely, they seem
71
to be still. But you have the uneasy feeling when you
72
look away that they're scuttling, moving about. Two
73
glyphs are prominent: Arrow and Circle.",
74
has static pluralname;
77
<p class="normal">The <code>static</code> attribute means that the inscriptions
78
can't be taken or moved. As we went out of our way to describe a shaft
79
of sunlight, we'll include that as well:</p>
81
<p class="lynxonly"></p>
83
Object -> sunlight "shaft of sunlight"
84
with name 'shaft' 'of' 'sunlight' 'sun' 'light' 'beam' 'sunbeam'
85
'ray' 'rays' 'sun^s' 'sunlit' 'air' 'motes' 'dust',
87
"Motes of dust glimmer in the shaft of sunlit air, so
88
that it seems almost solid.",
92
<p class="normal">The <code>^</code> symbol in <code>"sun^s"</code>
93
means an apostrophe, so the word is “sun's”. This
94
object has been given the constant name <code>sunlight</code> because
95
other parts of the ‘Ruins’ source code will need to refer
96
to it later on. Being <code>scenery</code> means that the object is
97
not only static but also not described by the game unless actually
98
examined by the player. A perfectionist might add a <code>before</code>
101
<p class="lynxonly"></p>
105
default: "It's only an insubstantial shaft of sunlight.";
109
<p class="normal">so that the player can look at or through the sunlight,
110
but any other request involving them will be turned down. Note that
111
a <code>default</code> rule, if given, means “any action except
112
those already mentioned”.</p>
114
<a id="p118" name="p118"></a>
115
<p class="aside"><span class="warning">▲</span>
116
Objects having <code>scenery</code> are assumed to be mentioned in
117
the description text of the room, just as the “shaft of sunlight”
118
is mentioned in that of the Square Chamber. Giving an object <code>concealed</code>
119
marks it as something which is present to a player who knows about it,
120
but hidden from the casual eye. It will not be cited in lists of objects
121
present in the room, and “take all” will not take it, but
122
“take secret dossier”, or whatever, will work. (Designers
123
seldom need <code>concealed</code>, but the library uses it all the
124
time, because the player-object is concealed.)</p>
126
<p class="dotbreak">� � � � �</p>
128
<p class="normal">Some scenery must spread across several rooms. The
129
‘Ruins’, for instance, are misty, and although we <em>could</em>
130
design them with a different “mist” object in every misty
131
location, this would become tiresome. In ‘Advent’,
132
for instance, a stream runs through seven locations, while mist which
133
(we are told) is “frequently a sign of a deep pit leading down
134
to water” can be found in ten different caves. Here is a
137
<p class="lynxonly"></p>
139
Object low_mist "low mist"
140
with name 'low' 'swirling' 'mist',
141
description "The mist has an aroma reminiscent of tortilla.",
142
found_in Square_Chamber Forest,
145
Smell: <<Examine self>>;
146
default: "The mist is too insubstantial.";
151
<p class="normal">The <code>found_in</code> property gives a list
152
of places in which the mist is found: so far, just the Square Chamber
155
<p class="aside"><span class="warning">▲</span>
156
This allows for up to 32 misty locations. If scenery has to be visible
157
even more widely than that, or if it has to change with circumstances
158
(for instance, if the mist drifts) then it is simpler to give a routine
159
instead of a list. This can look at the current location and say whether
160
or not the object should be present, as in the following example from
161
a game taking place at night:</p>
163
<p class="lynxonly"></p>
165
Object Procyon "Procyon",
166
with name 'procyon' 'alpha' 'canis' 'minoris' 'star',
167
description "A double-star eleven light years distant.",
169
return (location ofclass OutsideRoom);
174
<a id="p119" name="p119"></a>
175
<p class="aside"><code>found_in</code> is only consulted when the player's
176
location changes, and works by moving objects around to give the illusion
177
that they are in several places at once: thus, if the player walks from
178
a dark field to a hilltop, Procyon will be moved ahead to the hilltop
179
just in advance of the player's move. This illusion is good enough for
180
most practical purposes, but sometimes needs a little extra work to maintain,
181
for instance if the sky must suddenly cloud over, concealing the stars.
182
Since it often happens that an object must be removed from all the
183
places in which it would otherwise appear, an attribute called
184
<code>absent</code> is provided which overrides <code>found_in</code>
185
and declares that the object is found nowhere. Whatever change is made
186
to <code>found_in</code>, or in giving or removing <code>absent</code>,
187
the Inform library needs also to be notified that changes have taken
188
place. For instance, if you need to occult Procyon behind the moon
189
for a while, then:</p>
191
<p class="lynxonly"></p>
192
<pre class="code">give Procyon absent; MoveFloatingObjects();</pre>
194
<p class="aside">The library routine <code>MoveFloatingObjects</code>
195
keeps the books straight after a change of state of <code>found_in</code>
196
or <code>absent</code>.</p>
198
<p class="dotbreak">� � � � �</p>
200
<p class="normal">Whereas Procyon is entirely visual, some scenery
201
items may afflict the other four senses. In ‘Ruins’,
202
the <code>Forest</code> contains the rule:</p>
204
<p class="lynxonly"></p>
207
Listen: "Howler monkeys, bats, parrots, macaw.";
211
<p class="normal">Besides which, we have already said that the mist
212
smells of tortilla, which means that if the player types “smell”
213
in a place where the mist is, there should clearly be some reaction.
214
For this, a <code>react_before</code> rule attached to the mist is
217
<p class="lynxonly"></p>
220
Smell: if (noun == nothing) <<Smell self>>;
224
<p class="normal">This is called a “react” rule because
225
the mist is reacting to the fact that a <code>Smell</code> action is
226
taking place nearby. <code>noun</code> is compared with <code>nothing</code>
227
to see if the player has indeed just typed “smell” and
228
not, say, “smell crocus”. Thus, when the action
229
<code>Smell</code> takes place near the mist, it is converted into
230
<code>Smell low_mist</code>, whereas the action <code>Smell
231
crocus</code> would be left alone.
233
<p class="indent">The five senses all have actions in Inform:
234
<code>Look</code>, <code>Listen</code>, <code>Smell</code>,
235
<code>Taste</code> and <code>Touch</code>. Of these, <code>Look</code>
236
never has a noun attached (because <code>Examine</code>,
237
<code>LookUnder</code> and <code>Search</code> are provided for
238
close-up views), <code>Smell</code> and <code>Listen</code> may or
239
may not have while <code>Taste</code> and <code>Touch</code> always
242
<a id="p120" name="p120"></a>
244
<p class="aside"><span class="warning"><b>•</b>
245
<b><a href="sa6.html#ans6">EXERCISE 6</a></b></span><br>
246
(Cf. ‘Spellbreaker’.) Make an orange cloud descend on
247
the player, which can't be seen through or walked out of.</p>
249
<p class="dotbreak">� � � � �</p>
251
<p class="normal">Rooms also react to actions that might occur in them
252
and have their own <code>before</code> and <code>after</code> rules.
253
Here's one for the Square Chamber:</p>
255
<p class="lynxonly"></p>
259
if (noun == eggsac && second == sunlight) {
260
remove eggsac; move stone_key to self;
261
"You drop the eggsac into the glare of the shaft of
262
sunlight. It bubbles obscenely, distends and then
263
bursts into a hundred tiny insects which run in all
264
directions into the darkness. Only spatters of slime
265
and a curious yellow-stone key remain on the chamber
271
<p class="normal">(The variables <code>noun</code> and <code>second</code>
272
hold the first and second nouns supplied with an action.) As it happens
273
this rule could as easily have been part of the definition of the eggsac
274
or the sunlight, but <code>before</code> and <code>after</code> rules
275
for rooms are invaluable to code up geographical oddities.</p>
278
<p class="aside"><span class="warning"><b>•</b>
279
<b><a href="sa6.html#ans7">EXERCISE 7</a></b></span><br>
280
Create a room for ‘Ruins’ called the Wormcast, which has
281
the oddity that anything dropped there ends up back in the Square Chamber.</p>
283
<p class="aside"><span class="warning">▲</span>
284
Sometimes the room may be a different one after the action has taken
285
place. The <code>Go</code> action, for instance, is offered to the
286
<code>before</code> routine of the room which is being left, and
287
the <code>after</code> routine of the room being arrived in. For example:</p>
289
<p class="lynxonly"></p>
292
Go: if (noun == w_obj)
293
print "You feel an overwhelming sense of relief.^";
297
<p class="aside">will print the message when its room is entered from
298
the “west" direction. Note that this routine returns <code>false</code>,
299
in the absence of any code telling it to do otherwise, which means
300
that the usual game rules resume after the printing of the message.</p>
302
<a id="p121" name="p121"></a>
303
<p class="aside"><span class="warning"><b>•</b>
304
<b>REFERENCES</b></span><br>
305
‘A Scenic View’ by Richard Barnett demonstrates a system
306
for providing examinable scenery much more concisely (without defining
307
so many objects).
308
<span class="warning"><b>•</b></span><code>found_in</code>
309
can allow a single object to represent many different but similar objects
310
across a game, and a good example is found in Martin Braun's <tt>"elevator.inf"</tt>
311
example game, where every floor of a building has an up-arrow and a
312
down-arrow button to summon an elevator.</p>
316
<a href="index.html">home</a> /
317
<a href="contents.html">contents</a> /
318
<a href="ch3.html" title="Chapter III: The Model World">chapter III</a> /
319
<a href="ch3.html" title="Chapter III: The Model World">prev</a> /
320
<a href="s9.html" title="§9: Directions and the map">next</a> /
321
<a href="dm4index.html">index</a>