Add appendix F.
[ibg.git] / examples / Tell.inf
1 !% -SD\r
2 \r
3 !============================================================================\r
4 Constant Story "William Tell";\r
5 Constant Headline\r
6             "^A simple Inform example\r
7              ^by Roger Firth and Sonja Kesserich.^";\r
8 !Release 1; Serial "020428";    ! IBG first edition (public beta)\r
9 !Release 2; Serial "020827";    ! IBG second edition\r
10 Release 3;  Serial "040804";    ! for keeping track of public releases\r
11 \r
12 Constant MAX_SCORE = 3;\r
13 \r
14 Include "Parser";\r
15 Include "VerbLib";\r
16 \r
17 !============================================================================\r
18 ! Object classes\r
19 \r
20 Class   Room\r
21   has   light;\r
22 \r
23 Class   Prop\r
24   with  before [;\r
25           Examine:\r
26             return false;\r
27           default:\r
28             print_ret "You don't need to worry about ", (the) self, ".";\r
29         ],\r
30   has   scenery;\r
31 \r
32 Class   Furniture\r
33   with  before [;\r
34           Take,Pull,Push,PushDir:\r
35             print_ret (The) self, " is too heavy for that.";\r
36         ],\r
37   has   static supporter;\r
38 \r
39 Class   Arrow\r
40   with  name 'arrow' 'arrows//p',\r
41         article "an",\r
42         plural "arrows",\r
43         description "Just like all your other arrows -- sharp and true.",\r
44         before [;\r
45           Drop,Give,ThrowAt:\r
46             print_ret "Your arrows are sharp, and you guard them carefully.";\r
47         ];\r
48 \r
49 Class   NPC\r
50   with  life [;\r
51           Answer,Ask,Order,Tell:\r
52             print_ret "Just use T[ALK] [TO ", (the) self, "].";\r
53         ],\r
54   has   animate;\r
55 \r
56 !============================================================================\r
57 ! The game objects\r
58 \r
59 Room    street "A street in Altdorf"\r
60   with  description [;\r
61             print "The narrow street runs north towards the town square.\r
62                 Local folk are pouring into the town through the gate to the\r
63                 south, shouting greetings, offering produce for sale,\r
64                 exchanging news, enquiring with exaggerated disbelief about\r
65                 the prices of the goods displayed by merchants whose stalls\r
66                 make progress even more difficult.^";\r
67             if (self hasnt visited)\r
68                 print "^~Stay close to me, son,~ you say,\r
69                     ~or you'll get lost among all these people.~^";\r
70         ],\r
71         n_to below_square,\r
72         s_to\r
73             "The crowd, pressing north towards the square,\r
74              makes that impossible.";\r
75 \r
76 Prop    "south gate" street\r
77   with  name 'south' 'southern' 'wooden' 'gate',\r
78         description "The large wooden gate in the town walls is wide open.";\r
79 \r
80 Prop    "assorted stalls"\r
81   with  name 'assorted' 'stalls',\r
82         description "Food, clothing, mountain gear; the usual stuff.",\r
83         found_in street below_square,\r
84   has   pluralname;\r
85 \r
86 Prop    "produce"   !! added\r
87   with  name 'goods' 'produce' 'food' 'clothing' 'mountain' 'gear' 'stuff',\r
88         description "Nothing special catches your eye.",\r
89         found_in street below_square,\r
90   has   pluralname;\r
91 \r
92 Prop    "merchants"\r
93   with  name 'merchant' 'merchants' 'trader' 'traders',\r
94         description\r
95             "A few crooks, but mostly decent traders touting their wares\r
96              with raucous overstatement.",\r
97         found_in street below_square,\r
98   has   animate pluralname;\r
99 \r
100 Prop    "local people"\r
101   with  name 'people' 'folk' 'local' 'crowd',\r
102         description "Mountain folk, just like yourself.",\r
103         found_in [; return true; ],\r
104   has   animate pluralname;\r
105 \r
106 !----------------------------------------------------------------------------\r
107 \r
108 Room    below_square "Further along the street"\r
109   with  description\r
110             "People are still pushing and shoving their way from the southern\r
111              gate towards the town square, just a little further north.\r
112              You recognise the owner of a fruit and vegetable stall.",\r
113         n_to south_square,\r
114         s_to street;\r
115 \r
116 Furniture   stall "fruit and vegetable stall" below_square\r
117   with  name 'fruit' 'veg' 'vegetable' 'stall' 'table',\r
118         description\r
119             "It's really only a small table, with a big heap of potatoes,\r
120              some carrots and turnips, and a few apples.",\r
121         before [;\r
122           Search:\r
123             <<Examine self>>;\r
124         ],\r
125   has   scenery;\r
126 \r
127 Prop    "potatoes" below_square\r
128   with  name 'potato' 'potatoes' 'spuds',\r
129         description\r
130             "Must be a particularly early variety... by some 300 years!",\r
131   has   pluralname;\r
132 \r
133 Prop    "fruit and vegetables" below_square\r
134   with  name 'carrot' 'carrots' 'turnip' 'turnips' 'apples' 'vegetables',\r
135         description "Fine locally grown produce.",\r
136   has   pluralname;\r
137 \r
138 NPC     stallholder "Helga" below_square\r
139   with  name 'stallholder' 'greengrocer' 'monger' 'shopkeeper' 'merchant'\r
140             'owner' 'Helga' 'dress' 'scarf' 'headscarf',\r
141         description\r
142             "Helga is a plump, cheerful woman,\r
143              concealed beneath a shapeless dress and a spotted headscarf.",\r
144         initial [;\r
145             print "Helga pauses from sorting potatoes\r
146                 to give you a cheery wave.^";\r
147             if (location hasnt visited) {\r
148                 move apple to player;\r
149                 print "^~Hello, Wilhelm, it's a fine day for trade! Is this\r
150                     young Walter? My, how he's grown. Here's an apple for him\r
151                     -- tell him to mind that scabby part, but the rest's good\r
152                     enough. How's Frau Tell? Give her my best wishes.~^";\r
153             }\r
154         ],\r
155         times_spoken_to 0,       ! for counting the conversation topics\r
156         life [;\r
157           Kiss:\r
158             print_ret "~Ooh, you saucy thing!~";\r
159           Talk:\r
160             self.times_spoken_to = self.times_spoken_to + 1;\r
161             switch (self.times_spoken_to) {\r
162              1: score = score + 1;\r
163                 print_ret "You warmly thank Helga for the apple.";\r
164              2: print_ret "~See you again soon.~";\r
165              default:\r
166                 return false;\r
167             }\r
168         ],\r
169   has   female proper;\r
170 \r
171 !----------------------------------------------------------------------------\r
172 \r
173 Room    south_square "South side of the square"\r
174   with  description\r
175             "The narrow street to the south has opened onto the town square,\r
176              and resumes at the far side of this cobbled meeting place.\r
177              To continue along the street towards your destination --\r
178              Johansson's tannery -- you must walk north across the square,\r
179              in the middle of which you see Gessler's hat set on that\r
180              loathsome pole. If you go on, there's no way you can avoid\r
181              passing it. Imperial soldiers jostle rudely through the throng,\r
182              pushing, kicking and swearing loudly.",\r
183         n_to mid_square,\r
184         s_to below_square;\r
185 \r
186 Prop     "hat on a pole"     !! changed\r
187   with   name 'hat' 'pole',\r
188          before [;\r
189            default:\r
190              print_ret "You're too far away at the moment.";\r
191          ],\r
192          found_in south_square north_square;\r
193 \r
194 Prop    "Gessler's soldiers"\r
195   with  name 'soldier' 'soldiers' 'guard' 'guards',     !! added\r
196         description "They're uncouth, violent men, not from around here.",\r
197         before [;\r
198           FireAt:\r
199             print_ret "You're outnumbered many times.";\r
200           Talk:\r
201             print_ret "Such scum are beneath your contempt.";\r
202         ],\r
203         found_in south_square mid_square north_square marketplace,\r
204   has   animate pluralname proper;\r
205 \r
206 !----------------------------------------------------------------------------\r
207 \r
208 Room    mid_square "Middle of the square"\r
209   with  description\r
210             "There is less of a crush in the middle of the square; most\r
211              people prefer to keep as far away as possible from the pole\r
212              which towers here, topped with that absurd ceremonial hat. A\r
213              group of soldiers stands nearby, watching everyone who passes.",\r
214         n_to north_square,\r
215         s_to south_square,\r
216         warnings_count 0,       ! for counting the soldier's warnings\r
217         before [;\r
218           Go:\r
219             if (noun == s_obj) {\r
220                 self.warnings_count = 0;\r
221                 pole.has_been_saluted = false;\r
222             }\r
223             if (noun == n_obj) {\r
224                 if (pole.has_been_saluted == true) {\r
225                     print "^~Be sure to have a nice day.~^";\r
226                     return false;\r
227                 }   ! end of (pole has_been_saluted)\r
228                 else {\r
229                     self.warnings_count = self.warnings_count + 1;\r
230                     switch (self.warnings_count) {\r
231                      1: print_ret "A soldier bars your way. ^^\r
232                             ~Oi, you, lofty; forgot yer manners, didn't you?\r
233                             How's about a nice salute for the vogt's hat?~";\r
234                      2: print_ret "^~I know you, Tell, yer a troublemaker,\r
235                             ain't you? Well, we don't want no bovver here,\r
236                             so just be a good boy and salute the friggin'\r
237                             hat. Do it now: I ain't gonna ask you again...~";\r
238                      default:\r
239                         print "^~OK, ";\r
240                         style underline; print "Herr"; style roman;\r
241                         print " Tell, now you're in real trouble. I asked you\r
242                             nice, but you was too proud and too stupid. I\r
243                             think it's time that the vogt had a little word\r
244                             with you.~\r
245                             ^^\r
246                             And with that the soldiers seize you and Walter\r
247                             and, while the sergeant hurries off to fetch\r
248                             Gessler, the rest drag you roughly towards the\r
249                             old lime tree growing in the marketplace.^";\r
250                         move apple to son;\r
251                         PlayerTo(marketplace);\r
252                         return true;\r
253                     }   ! end of switch\r
254                 }   ! end of (pole has_NOT_been_saluted)\r
255             }   ! end of (noun == n_obj)\r
256         ];\r
257 \r
258 Furniture   pole "hat on a pole" mid_square   !! changed\r
259   with  name 'wooden' 'pole' 'pine' 'hat' 'black' 'red' 'brim' 'feathers',\r
260         description\r
261             "The pole, the trunk of a small pine some few inches in diameter,\r
262              stands about nine or ten feet high. Set carefully on top is\r
263              Gessler's ludicrous black and red leather hat, with a widely\r
264              curving brim and a cluster of dyed goose feathers.",\r
265         has_been_saluted false,\r
266         before [;\r
267           FireAt:   !! added\r
268             print_ret "Tempting, but you're not looking for trouble.";\r
269           Salute:\r
270             self.has_been_saluted = true;\r
271             print_ret "You salute the hat on the pole. ^^\r
272                 ~Why, thank you, sir,~ sneers the soldier.";\r
273         ],\r
274   has   scenery;\r
275 \r
276 !----------------------------------------------------------------------------\r
277 \r
278 Room    north_square "North side of the square"\r
279   with  description\r
280             "A narrow street leads north from the cobbled square. In its\r
281              centre, a little way south, you catch a last glimpse of the pole\r
282              and hat.",\r
283         n_to [;\r
284             deadflag = 3;\r
285             print_ret "With Walter at your side, you leave the square by the\r
286                 north street, heading for Johansson's tannery.";\r
287         ],\r
288         s_to "You hardly feel like going through all that again.";\r
289 \r
290 !----------------------------------------------------------------------------\r
291 \r
292 Room    marketplace "Marketplace near the square"\r
293   with  description\r
294             "Altdorf's marketplace, close by the town square, has been hastily\r
295              cleared of stalls. A troop of soldiers has pushed back the crowd\r
296              to leave a clear space in front of the lime tree, which has been\r
297              growing here for as long as anybody can remember. Usually it\r
298              provides shade for the old men of the town, who gather below to\r
299              gossip, watch the girls, and play cards. Today, though, it\r
300              stands alone... apart, that is, from Walter, who has been lashed\r
301              to the trunk. About forty yards away, you are restrained by two\r
302              of the vogt's men.",\r
303         cant_go "What? And leave your son tied up here?";\r
304 \r
305 Object  tree "lime tree" marketplace\r
306   with  name 'lime' 'tree',\r
307         description "It's just a large tree.",\r
308         before [;\r
309           FireAt:\r
310             if (BowOrArrow(second) == true) {\r
311                 deadflag = 3;\r
312                 print_ret "Your hand shakes a little, and your arrow flies\r
313                     high, hitting the trunk a few inches above Walter's\r
314                     head.";\r
315             }\r
316             return true;\r
317         ],\r
318   has   scenery;\r
319 \r
320 NPC     governor "governor" marketplace\r
321   with  name 'governor' 'vogt' 'Hermann' 'Gessler',\r
322         description\r
323             "Short, stout but with a thin, mean face, Gessler relishes the\r
324              power he holds over the local community.",\r
325         initial [;\r
326             print "Gessler is watching from a safe distance,\r
327                 a sneer on his face.^";\r
328             if (location hasnt visited)\r
329                 print "^~It appears that you need to be taught a lesson,\r
330                     fool. Nobody shall pass through the square without paying\r
331                     homage to His Imperial Highness Albert; nobody, hear me?\r
332                     I could have you beheaded for treason, but I'm going to\r
333                     be lenient. If you should be so foolish again, you can\r
334                     expect no mercy, but this time, I'll let you go free...\r
335                     just as soon as you demonstrate your archery skills by\r
336                     hitting this apple from where you stand. That shouldn't\r
337                     prove too difficult; here, sergeant, catch. Balance it on\r
338                     the little bastard's head.~^";\r
339         ],\r
340         life [;\r
341           Talk:\r
342             print_ret "You cannot bring yourself to speak to him.";\r
343         ],\r
344         before [;\r
345           FireAt:\r
346             if (BowOrArrow(second) == true) {\r
347                 deadflag = 3;\r
348                 print_ret "Before the startled soldiers can react, you turn\r
349                     and fire at Gessler; your arrow pierces his heart,\r
350                     and he dies messily. A gasp, and then a cheer,\r
351                     goes up from the crowd.";\r
352             }\r
353             return true;\r
354         ],\r
355   has   male;\r
356 \r
357 !============================================================================\r
358 ! The player's possessions\r
359 \r
360 Object  bow "bow"\r
361   with  name 'bow',\r
362         description "Your trusty yew bow, strung with flax.",\r
363         before [;\r
364           Drop,Give,ThrowAt:\r
365             print_ret "You're never without your trusty bow.";\r
366         ]\r
367   has   clothing;\r
368 \r
369 Object  quiver "quiver"\r
370   with  name 'quiver',\r
371         description\r
372             "Made of goatskin, it usually hangs over your left shoulder.",\r
373         before [;\r
374           Drop,Give,ThrowAt:\r
375             print_ret "But it was a present from Hedwig, your wife.";\r
376         ],\r
377   has   container open clothing;\r
378 \r
379 Arrow   "arrow" quiver;\r
380 Arrow   "arrow" quiver;\r
381 Arrow   "arrow" quiver;\r
382 \r
383 NPC     son "your son"\r
384   with  name 'son' 'your' 'boy' 'lad' 'Walter',\r
385         description [;\r
386             if (location == marketplace)\r
387                 print_ret "He stares at you, trying to appear brave and\r
388                     remain still. His arms are pulled back and tied behind\r
389                     the trunk, and the apple nestles amid his blond hair.";\r
390             else\r
391                 print_ret "A quiet, blond lad of eight summers, he's fast\r
392                     learning the ways of mountain folk.";\r
393         ],\r
394         life [;\r
395           Give:\r
396             score = score + 1;\r
397             move noun to self;\r
398             print_ret "~Thank you, Papa.~";\r
399           Talk:\r
400             if (location == marketplace)\r
401                 print_ret "~Stay calm, my son, and trust in God.~";\r
402             else\r
403                 print_ret "You point out a few interesting sights.";\r
404         ],\r
405         before [;\r
406           Examine,Listen,Salute,Talk:\r
407             return false;\r
408           FireAt:\r
409             if (location == marketplace) {\r
410                 if (BowOrArrow(second) == true) {\r
411                     deadflag = 3;\r
412                     print_ret "Oops! Surely you didn't mean to do that?";\r
413                 }\r
414                 return true;\r
415             }\r
416             else\r
417                 return false;\r
418           default:\r
419             if (location == marketplace)\r
420                 print_ret "Your guards won't permit it.";\r
421             else\r
422                 return false;\r
423         ],\r
424         found_in [; return true; ],\r
425   has   male proper scenery transparent;\r
426 \r
427 Object  apple "apple"\r
428   with  name 'apple',\r
429         description [;\r
430             if (location == marketplace)\r
431                 print_ret "At this distance you can barely see it.";\r
432             else\r
433                 print_ret "The apple is blotchy green and brown.";\r
434         ],\r
435         before [;\r
436           Drop:\r
437             print_ret "An apple is worth quite a bit --\r
438                 better hang on to it.";\r
439           Eat:\r
440             print_ret "Helga intended it for Walter...";\r
441           FireAt:\r
442             if (location == marketplace) {\r
443                 if (BowOrArrow(second) == true) {\r
444                     score = score + 1;\r
445                     deadflag = 2;\r
446                     print_ret "Slowly and steadily, you place an arrow in\r
447                         the bow, draw back the string, and take aim with\r
448                         more care than ever in your life. Holding your\r
449                         breath, unblinking, fearful, you release the\r
450                         arrow. It flies across the square towards your\r
451                         son, and drives the apple against the trunk of\r
452                         the tree. The crowd erupts with joy;\r
453                         Gessler looks distinctly disappointed.";\r
454                 }\r
455                 return true;\r
456             }\r
457             else\r
458                 return false;\r
459         ];\r
460 \r
461 !============================================================================\r
462 ! Entry point routines\r
463 \r
464 [ Initialise;\r
465     location = street;\r
466     lookmode = 2;       ! like the VERBOSE command\r
467     move bow to player;\r
468     move quiver to player; give quiver worn;\r
469     player.description =\r
470         "You wear the traditional clothing of a Swiss mountaineer.";\r
471     print_ret "^^\r
472         The place: Altdorf, in the Swiss canton of Uri. The year is 1307,\r
473         at which time Switzerland is under rule by the Emperor Albert of\r
474         Habsburg. His local governor -- the vogt -- is the bullying\r
475         Hermann Gessler, who has placed his hat atop a wooden pole in\r
476         the centre of the town square; everybody who passes through the\r
477         square must bow to this hated symbol of imperial might.\r
478         ^^\r
479         You have come from your cottage high in the mountains,\r
480         accompanied by your younger son, to purchase provisions. You are\r
481         a proud and independent man, a hunter and guide, renowned both\r
482         for your skill as an archer and, perhaps unwisely (for his soldiers\r
483         are everywhere), for failing to hide your dislike of the vogt.\r
484         ^^\r
485         It's market-day: the town is packed with people from the\r
486         surrounding villages and settlements.^";\r
487 ];\r
488 \r
489 [ DeathMessage; print "You have screwed up a favourite folk story"; ];\r
490 \r
491 !============================================================================\r
492 ! Standard and extended grammar\r
493 \r
494 Include "Grammar";\r
495 \r
496 !----------------------------------------------------------------------------\r
497 \r
498 [ TalkSub;\r
499     if (noun == player) print_ret "Nothing you hear surprises you.";\r
500     if (RunLife(noun,##Talk) ~= false) return;  ! consult life[; Talk: ]\r
501     print_ret "At the moment, you can't think of anything to say.";\r
502 ];\r
503 \r
504 Verb 'talk' 't//' 'converse' 'chat' 'gossip'\r
505     * 'to'/'with' creature          -> Talk\r
506     * creature                      -> Talk;\r
507 \r
508 !----------------------------------------------------------------------------\r
509 \r
510 [ BowOrArrow o;\r
511     if (o == bow or nothing || o ofclass Arrow) return true;\r
512     print "That's an unlikely weapon, isn't it?^";\r
513     return false;\r
514 ];\r
515 \r
516 [ FireAtSub;\r
517     if (noun == nothing)\r
518         print_ret "What, just fire off an arrow at random?";\r
519     if (BowOrArrow(second) == true)\r
520         print_ret "Unthinkable!";\r
521 ];\r
522 \r
523 Verb 'fire' 'shoot' 'aim'\r
524     *                               -> FireAt\r
525     * noun                          -> FireAt\r
526     * 'at' noun                     -> FireAt\r
527     * 'at' noun 'with' noun         -> FireAt\r
528     * noun 'with' noun              -> FireAt\r
529     * noun 'at' noun                -> FireAt reverse;\r
530 \r
531 Extend 'attack' replace\r
532     * noun                          -> FireAt;\r
533 \r
534 !----------------------------------------------------------------------------\r
535 \r
536 [ SaluteSub;\r
537     if (noun has animate) print_ret (The) noun, " acknowledges you.";\r
538     print_ret (The) noun, " takes no notice.";\r
539 ];\r
540 \r
541 Verb 'bow' 'nod' 'kowtow' 'genuflect'\r
542     * 'at'/'to'/'towards' noun      -> Salute;\r
543 \r
544 Verb 'salute' 'greet' 'acknowledge'\r
545     * noun                          -> Salute;\r
546 \r
547 Extend 'give'\r
548     * 'homage' 'to' noun            -> Salute;\r
549 \r
550 Extend 'wave'\r
551     * 'at' noun                     -> Salute;\r
552 \r
553 !----------------------------------------------------------------------------\r
554 \r
555 [ UntieSub; print_ret "You really shouldn't try that."; ];\r
556 \r
557 Verb 'untie' 'unfasten' 'unfix' 'free' 'release'\r
558     * noun                          -> Untie;\r
559 \r
560 !============================================================================\r