-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHOW-TO.TXT
1254 lines (788 loc) · 47.9 KB
/
HOW-TO.TXT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
How To Quickly Write An Adventure Game
by Derek T. Jones
This document describes how to write your own adventure game
quickly and easily, and also how to take advantage of more
advanced features when your game becomes more complex. You
should already be familiar with what playing an adventure game is
like. If you aren't, try the adventures that came with this
package to understand the "feel" of moving through an artificial
universe by text and imagination alone.
Archetype is more than just a language for writing adventures.
It is a more general-purpose language that was designed with the
writing of adventure games in mind. For this reason, there is a
good deal of existing Archetype code that must be combined with
your own adventure's objects and rooms in order for them to
behave like a text adventure. Here's an example of the simplest
adventure possible:
include "standard"
room first_room
methods
'INITIAL' : 'START HERE' -> player
end
Try it. Type that into a text file; name it TEST1.ACH . You can
create a text file by using a text editor such as vi, SLED,
QEDIT, or the DOS 6.2 EDIT command, among others. You can also
create a text file on a word processor, as long as you make sure
that you don't save the file in the word processor's native
format. For example, using WordPerfect to create your adventure,
you would have to use Text Out to save the file. Using Microsoft
Works, you would use the Save As option and check the "Text" box.
Most word processors have an option for storing your file without
any special formatting codes.
Now create the adventure. Before the adventure can actually be
played, it has to be translated into a binary format so that it
can be loaded and executed quickly. During this translation the
program you wrote is also checked for any syntax errors, meaning
errors in Archetype grammar (not English grammar!). Throughout
this document, anything in an example typed in boldface indicates
something you have to type; plain text indicates program output
or prompts. So now create your adventure:
C:\>create test1
This may take about a minute, if you're using a 10MHz 8088 with
floppy drives, like I have. Probably it runs much faster on your
more advanced machine. If you get the error "Cannot open
STANDARD.ACH", simply make sure that all the .ACH files that came
with the package are in the same directory as the CREATE.EXE
program.
To play the adventure, type:
C:\>perform test1
Not much to do, is there? Find out just what you can do:
What should I do now? help
You will see a list of some of the verbs that the program will
understand. Synonyms for verbs will not appear in this list. In
other words, if "shoot" and "kill" are defined simply as synonyms
for "attack", only the verb "attack" will show up in this list.
Notice that the system verbs - help, save, load, quit - and the
direction verbs - north, south, east, west, northeast, northwest,
southeast, southwest, up, and down - are all in this list. These
verbs were defined in the STANDARD.ACH Archetype file that you
included when you typed include "standard" at the top of your
program.
Other things were defined as well, for example, the "room" type.
When you typed room first_room, it created a room object named
"first_room". The properties of this room were defined in
STANDARD.ACH: the ability to have exits in the cardinal
directions (north, south, northwest, etc.); the ability to
contain any objects dropped in it, descriptions that vary based
on whether or not this is the player's first visit to it, and so
forth.
The 'INITIAL' message and its significance were also defined in
STANDARD.ACH . Before anything else starts in the game, this
message is broadcast to every object defined - objects you
created as well as those created in STANDARD.ACH . By putting
this message in the methods section and following it with a colon
and a statement, you indicated that "first_room" had some
specific action to take when it received the 'INITIAL' message.
In this case, the action is to send the message 'START HERE' to
the player object. The player object is also defined in
STANDARD.ACH; it contains attributes having to do with the
player's location, how much they can carry, etc. The player
object defines the 'START HERE' message, and has a method for it
which causes it to move into the room which sent the message.
The "->" symbol, meaning "send this message to that object", is
not defined in STANDARD.ACH . Neither is the word "include", the
word "methods" or "end", or even the general structure of your
room definition. Those are defined by Archetype itself1.
However, it is important to remember that much of what you will
come to think of as "Archetype" is actually STANDARD.ACH, and
especially INTRPTR.ACH, which are themselves written in
Archetype! Once you know more about writing adventure games, you
might want to go in yourself and make your own modifications.
HOWEVER IT IS AN EXTREMELY BAD PLAN TO MAKE CHANGES TO
INTRPTR.ACH UNLESS YOU ARE VERY CERTAIN YOU KNOW WHAT YOU ARE
DOING. In fact you should never actually change INTRPTR.ACH.
You should make a copy with a different name which you use
yourself. If you screw up INTRPTR.ACH, adventure games you make
with it will work erratically or not at all. Beware!
But enough with the alarmist injunctions. On to more and greater
things. First of all, how about giving your room an interesting
description. Right now it's just "a nondescript room." The
room's description is one of its attributes, named "desc".
Attributes are listed before the word methods when an object is
described. You might change your object definition as followed:
room first_room
desc : "room with the word START painted on the ceiling"
methods
'INITIAL' : 'START HERE' -> player
end
The "desc" attribute is actually defined to "nondescript room" in
the "room" type defined in INTRPTR.ACH; if you don't redefine it
yourself, your room object will inherit the "desc" attribute's
value just by virtue of being based on the "room" type. The
interesting attributes and methods of the room type are shown
below:
type room
IsAroom : TRUE
desc : "nondescript room"
intro : "I can see"
empty_intro : "There is nothing of interest here."
methods
'FIRSTDESC' : UNDEFINED
'BRIEF' : write "In the ", desc, "."
'LONGDESC' : write "I'm in the ", desc, "."
end
Attributes:
IsAroom Always TRUE. It should not be changed. If every
type defines an attribute called "IsA<type name>",
it makes it easy to test for the type of an
unknown object with a test such as "if obj.IsAroom
then..."
desc A short description of the room. It should not
contain any detailed description; just the name of
the room. It should also not contain any article
at the front such as "a", "an", or "the".
intro As can be seen from its default value, this is
what is written at the beginning of the room's
inventory list when the player types "look" at the
prompt. If the room is dark, you might want to
define it as "I can barely make out" or something.
But you will usually want to leave it alone.
empty_intro What is written when the room is empty. Again,
you will usually want to leave this one alone.
Methods:
'FIRSTDESC' This method is invoked whenever the player first
enters the room, and never again. A good place to
put description that causes your story to unfold;
or to put first-time traps or surprises. It is
important to remember that more than just written
output statements can appear in a method.
'LONGDESC' Invoked whenever the room is first entered or when
the player types "look" at the prompt.
'BRIEF' Invoked whenever the player re-enters a previously
entered room. Usually this is just a brief
reminder of what the room is. The fact that this
method is invoked on subsequent visits helps your
adventure feel like a book that is "unfolding";
'FIRSTDESC' is reactions the character has
initially and never again; 'LONGDESC' is the
result of a long slow look, and 'BRIEF' is when
the character is just passing through.
The methods section also contains the exits out of the room. The
name of the message should be the name of the exit. It should
return a single value - the room into which it exits. For
example, a room with the following methods:
'east' : kitchen
'west' : if door.open then bedroom
will have an exit to the east leading into the kitchen, and, if
the open attribute of the door object is TRUE, an exit to the
west. Methods always return a value to the sender: the last
expression executed within them. The 'east' method will always
return the "kitchen" object; the 'west' method returns the value
of an if statement, which in turn returns its last executed
expression. Suppose we fill out our example room a little more:
room first_room
desc : "room with the word START painted on the ceiling"
methods
'INITIAL' : 'START HERE' -> player
'LONGDESC' :
write "I'm standing in a small bare room with ",
"the word \"START\" "painted on the ceiling in neon ",
"green paint. The plaster is chipped a little and ",
"the dirty white linoleum floor is something I ",
"wouldn't want to have to touch with anything ",
"but my shoes."
'FIRSTDESC' :
write "Welcome to my first adventure! Hope you enjoy it. ",
"I was walking innocently along the sidewalk on my ",
"way to the store one day when a flash of light just ",
"to my left blinded me. When my vision cleared I ",
"found myself... somewhere else... without ",
"explanation..."
# Exits
'north' : hallway # no other obvious way
end
There are a few new things here:
The pound sign (#), the comment, causes itself and everything to
the end of the line to be ignored by the CREATE.EXE program. You
can use this operator to make notes to yourself or to someone
else who might need to read it later.
Note the usage of the write statement. No string (characters
surrounded by double quotes) can be longer than 256 characters,
and usually they're easier to see and use if they're not longer
than one line. But the write statement takes any number of
comma-separated strings and writes them out to the screen in such
a way that they "wrap" at the end of a line, like a word
processor. This way you don't have to worry about fitting them
carefully to screen margins yourself. Furthermore, if you have a
very long description that goes beyond the screen, Archetype will
pause and give the player a "Hit any key to continue" message, so
that none of the text is lost off the top.
Also notice the \" used in the 'FIRSTDESC' method. We want
double quotes within double quotes, but of course the presence of
(") means the end of a string. Putting a backslash (\) in front
of a double quote means that the double quote is part of the
ongoing string.
More About Exits
An exit usually goes both ways. Take a look at the north exit in
your first room. It points to the hallway, which we have not yet
defined. Define it as follows:
room hallway
desc : "long north-south hallway"
methods
'LONGDESC' : >>I'm standing in a narrow hallway north of the
START room.
'south' : first_room
end
Before any other exits you might define for the hallway, you
should first make an exit going south back to the original room.
Otherwise, the north exit from the start_room will be a one-way
exit. This is something to watch out for, since no room has any
exits other than the ones you define for it. Of course,
sometimes you might do this on purpose: a trapdoor or hole, for
example.
Objects
How about putting some objects in your adventure? Objects that
you can pick up and carry around? Try the following:
object necklace
desc : "diamond necklace"
location : start_room
end
Be sure that all your room and object definitions are in the same
TEST1.ACH file. CREATE it again and PERFORM it. Notice that
without any other information about the diamond necklace, you can
pick it up, look at it, drop it, and so forth, referring to it as
"the diamond necklace", "a diamond necklace", "the necklace", "a
necklace", or just "necklace". Of course, the necklace itself
isn't very interesting yet since you didn't define anything
special for it. It merely inherited the attributes of an object
type (defined in STANDARD.ACH), enough structure to allow it to
behave like an object. These inherited attributes are shown
below:
type object
IsAobject : TRUE
desc : "nondescript object"
visible : TRUE
location : UNDEFINED
pronoun : "it"
full : UNDEFINED
syn : UNDEFINED
size : 1
capacity : UNDEFINED
methods
'look' :
write "Nothing strikes me as unusual about ", 'DEF' -> self,
"."
'get' :
if location = player then
write "I've already got ", 'DEF' -> self, "."
else if size > player.capacity then
>>I can't carry that much.
else {
location := player; 'MOVE'
write "I picked up ", 'DEF' -> self, "."
}
'pick up' : 'get'
'pick_up' : 'get'
'take' : 'get'
'drop' :
if location ~= player then
write "I don't have ", 'DEF' -> self, "."
else {
location := player.location; 'MOVE'
write "I put down ", 'DEF' -> self, "."
}
'put down' : 'drop'
'put_down' : 'drop'
end
Attributes:
IsAobject Serves the same function as IsAroom in the room
type above. However it is even more important
since the interpreter depends on it.
desc A very important attribute; it must almost always
be defined. It is the full name of your object
the way it appears on screen, and, if full is not
defined, indicates how the player can talk about
it as well. The interpreter assumes that you have
defined desc in the form "adjective adjective ...
adjective noun", so that if desc was "great big
red ball", the player could refer to it as "ball",
"red ball", "big red ball", or "great big red
ball", but not "great ball", "red big ball", or
any other combination.
full The full name of your object; the way the player
would talk about it at the prompt. For example,
with the diamond necklace this would be "diamond
necklace". You need to use this attribute if you
don't want to allow some of the names that the
interpreter might generate, given your particular
desc attribute, since its presence prevents the
interpreter from using the desc attribute to
generate vocabulary names. One example might be
"ball of wax", where the interpreter will accept
"of wax" as a valid name for the object. You
might then set full to "ball of wax" and set syn
to "ball|wax" (see below).
syn Synonyms for your object. If there is more than
one synonym you can put them all in the same
string, separated by vertical bars. You can use
this attribute whether or not you define the full
attribute. For example, if you have an object
whose desc attribute is "scientific calculator",
and you want the player to be able to refer to it
as "calc" as well as "scientific calculator" and
"calculator" (which the interpreter will generate
if full is not defined), just set syn to "calc".
visible Whether or not the object will show up in an
inventory of the room. Usually TRUE; you might
make it FALSE if the object is not really what the
player might think of as an object, like a magic
word or something. If your adventure required
that the player type "say sesame" at some point,
there would actually have to be an object named
"sesame" to handle the action. This object would
have visible set to FALSE and probably 'ACCESS'
set to return TRUE. (See Methods below.)
location Another very important attribute. It is set to
the location of the object and indicates the
object's physical position. NOTE: just setting
this attribute equal to some other object is not
enough to actually change its position. It must
be set and then the 'MOVE' method must be invoked.
(See Methods below.)
pronoun Indicates what pronoun should be used for the
object. Although usually "it", it can be any
pronoun, such as "them", "him", "her", etc. If
the player has just mentioned this object, they
can continue to refer to it by this pronoun, until
they refer to another object with the same
pronoun.
size The size of the object. Size in what? Cubic
inches? Square feet? Well, you decide. It is
used to determine how much more the player can
carry. If it is zero, or UNDEFINED, it means that
it has no significant weight; the player can carry
as many of these kinds of objects as he wants. If
it is larger than one, the player will be able to
carry fewer. When the total of all the sizes of
the objects the player is carrying exceeds
player.capacity, the player gets the message "I
can't carry any more." Thus, if the weight of
objects is important in your game, you might need
to set player.capacity yourself in the 'INITIAL'
method of your starting room.
capacity How many objects can be put inside this object (if
all sizes are equal to 1). When the total of all
the sizes of the objects whose location attribute
points to this object exceeds capacity, no more
objects can be put "inside".
NOTICE that the most important attributes, the attributes without
which you would not be able to see or mention the object, are the
desc and location attributes. Without desc, the interpreter
cannot put its name on screen or know what names can be used by
the player to describe it. Without location, the object is not
actually anywhere within your game. All the others default to
"reasonable" values.
Methods
There are no methods which are mandatory in order to make your
object accessible. Note that the necklace defined above only
required two attributes in order to be part of the game. But the
methods section of an object contains three kinds of messages:
1. System messages, like 'DEF', 'INDEF', 'BEFORE', 'AFTER',
etc. These messages are in all uppercase letters. It is a
bad idea to define your own messages which are in all
capital letters; it only increases the possibility of
colliding with the system messages.
2. Verb messages, like 'get', 'north', 'kill...with', etc.
These are in all lowercase letters. How to define your own
verbs will be covered below, in "Parsing and Verb Messages".
3. General purpose messages. Any other message you put in the
methods section of an object, just to group certain commonly
invoked actions together. In order to conflict neither with
system messages or verbs, these are usually lowercase with
the first letters capitalized, like 'Wake Up' or 'Begin'.
Parsing and Verb Messages
When the player enters a command, the interpreter puts the
subject of the sentence in main.subj and the direct object into
main.dobj. It then creates a single verb message that
incorporates both the main verb and prepositional phrases, and
sends the message to main.subj. (For completeness, the verb is
put into main.verb and the prepositional phrase into verb.prep.)
The message is constructed as follows:
* If there is just one main verb phrase and a subject, then
the message is simply the verb phrase, words separated by
one space. Examples: "get object" sends the 'get' message
to <object>. "put down the object" sends the 'put down'
message to <object>.
* If there is a verb phrase, a subject, and a prepositional
phrase, then the message is the verb phrase followed by an
underscore (_) and then the prepositional phrase. Examples:
"pick the object up" sends 'pick_up' to <object>; "take the
coat off" sends 'take_off' to <coat>.
* If there is a verb phrase, a subject, a prepositional
phrase, and a direct object, then the message is the verb
phrase followed by an ellipsis (...) and the prepositional
phrase. Examples: "take the uniform off of the dead guard"
sends 'take...off of' to <dead guard>; "pick up the key with
the wad of chewing gum" sends 'pick up...with' to
<chewing gum>. Methods tied to messages with ellipses can
count on main.dobj being defined.
* If there is a verb phrase but no subject or direct object,
then it is sent to the object that the player is "in". This
is how hollow objects handle verbs like "leave" or "get
out".
Moving Things Around
One of the very first things that you will probably want to do is
to move some object from one place to another. This involves
doing two things: changing the object's location, and then
sending it the 'MOVE' message. If you forget the 'MOVE' message,
the adventure will behave strangely. Somtimes the object will
act like it's there, and sometimes it won't. Even if an object
changes its own location, it still must send the 'MOVE' message
to itself. (Where the definition of the 'MOVE' method comes from
is covered in "Inheritance" below.)
The first example here is from an object which is a rock. When
this rock is thrown at a glass vase, we want the glass vase to
shatter and disappear. The player would type "Throw the rock at
the vase" causing the message 'throw...at' to be sent to "rock",
with main.dobj set to glass_vase. The object definitions are
shown below:
object glass_vase
location : start_room
desc : "glass vase"
end
object rock
location : start_room
desc : "big ugly rock"
methods
'throw...at' : {
if main.dobj = glass_vase then {
write "It shatters into miniscule pieces! It's gone!"
glass_vase.location = UNDEFINED # Nowheresville
'MOVE' -> glass_vase
}
else
write "It bounces off of ", 'DEF' -> main.dobj, "."
} # throw...at
end
Note the 'DEF' message sent to main.dobj. It means the
"definite" name of the object. 'INDEF' means the "indefinite"
name. For the glass vase, the 'DEF' method returns "the glass
vase" and 'INDEF' returns "a glass vase". There is also the
message 'NEG INDEF', for "Negative Indefinite". It is used for
the message "I don't see ... here". For most objects it is
usually the same as 'INDEF', but for an object where 'INDEF' is
"some apples", 'NEG INDEF' would be "any apples".
Inheritance
How can the glass_vase object above respond to messages like
'DEF', 'INDEF', and 'MOVE' since they aren't defined in the
methods section of glass_vase? Because they were inherited from
the "object" type. All of the attributes and methods of the
"object" type are part of glass_vase unless glass_vase redefines
them.
Doing Things Up Front
There are some actions that have to be taken before the game even
gets underway, before the player has a chance to type the first
command. Many of these can be done just by initializing an
attribute to the right value, like setting the initial locations
of all the objects. But sometimes the action taken needs to be
several statements. In this case, simply define an 'INITIAL'
method for your object. Every object in the game receives the
'INITIAL' method before the player ever begins the game.
Doing Things Periodically
Sometimes there are actions that an object should take once per
turn, or things that should happen every so often. There is a
'BEFORE' message sent out before the player is asked for input
and an 'AFTER' message which is sent out after the player's
actions have taken effect.
To receive these messages, however, an object has to ask up front
to be on the list of objects which will be sent such a message,
by sending the message 'REGISTER' to the correct event handler:
the object "before" for the 'BEFORE' message, and the object
"after" for the 'AFTER' message. Registering is usually done in
the 'INITIAL' method. The object in the example below puts out a
random scary message about once out of every ten turns that the
player takes:
object scary_sounds
methods
'INITIAL' : 'REGISTER' -> before
'BEFORE' : {
if ?10 = 1 then
case ?5 of {
1 : write "I hear a far-off groan..."
2 : write "A bat flaps by close overhead!"
3 : write "I seem to hear a shuffling step behind me...!"
4 : write "A sense of dread weighs on me..."
5 : write "There is a clammy draft of air on the back ",
"of my neck..."
} # case
} # if
end
In the example above, the scary_sounds object has no desc or
location attribute since it isn't a tangible object. It only
writes things to the screen.
However, for tangible objects with a 'BEFORE' or 'AFTER' method,
it's important to know whether the object is accessible to the
player before doing anything. Otherwise the object acts "out of
nowhere". The 'ACCESS' method, inherited from the "object" type,
returns TRUE if the object is accessible to the player and FALSE
if it is not. An object is "accessible" if: the player has the
object, the player and the object are in the same location, or
the player is "in" the object. The example below is a monster
that will roar in protest, and snatch away the Wand of Power if
the player is carrying it:
object monster
location : dungeon
desc : "monster"
methods
'INITIAL' : 'REGISTER' -> after
'AFTER' :
if 'ACCESS' -> self and wand.location = player then {
write "The monster lets out a roar of protest and ",
"snatches ", 'DEF' -> wand, " from me."
wand.location := self
'MOVE' -> wand
}
end
If the 'AFTER' method didn't check for 'ACCESS' -> self to be
true, the monster would roar and take the wand the moment the
player acquired it, even if the player was nowhere near the
monster.
Did I Happen to Mention...? (The 'MENTION' Message)
The pronouns in Archetype usually refer to the last time an
object with that pronoun was referred to in a player command.
Sometimes it may appropriate, however, to cause a different
object to become the object of interest. Take, for example, the
following exchange:
What should I do now? pick up the wallet
I picked up the wallet.
What should I do now? open it
I opened the wallet. A driver's license fell out!
What should I do now? get it
I already have the wallet.
At that point, the player probably expected "it" to refer to the
most interesting object just mentioned. This can be done by
having the driver's license object send the 'MENTION' message to
the "main" object ('MENTION' -> main). Additionally, an object
can be directed to mention itself by sending it the
'MENTION SELF' message. The code below implements the situation
above, with the difference that when the user finally types
"get it", they will pick up the license, not the wallet.
object wallet
location: dresser
desc: "wallet"
methods
'open' : {
writes "I opened the wallet. "
if license.location <> self then
write "Nothing happened."
else {
write "A driver's license fell out!"
license.location = player.location
'MOVE' -> license
'MENTION SELF' -> license
}
end
Customizing the Game Environment
The interpreter is comprised of several objects, such as "main",
"player", and the various basic verbs ("get", "drop"). You can
change certain default attributes of these objects to different
values to give your adventure a different "look and feel".
main.prompt, for example, is the string that is printed just
before asking the player for input. It defaults to the string
"\nWhat should I do now? ". The \n means a new line, so that the
prompt will print a blank line and then the words.
main.wait_message is the string that is printed when the player
simply types a RETURN in response to main.prompt. It defaults to
"I wait patiently."
compass.intro is the string printed out before giving the list of
visible exits. Defaults to "I can exit".
compass.empty_intro is the string printed if there are no visible
exits. Defaults to "There are no visible exits."
player.intro is printed before listing the player's inventory.
Defaults to "I am carrying".
player.empty_intro is printed when the player is carrying
nothing. Defaults to "I am empty-handed."
player.capacity is generally the number of objects that the
player can carry before getting the message "I can't carry that
much." It is actually, however, the upper limit of the sum of
the size attributes of the player's objects. In other words, if
any object has a size attribute that is greater than one,
player.capacity will be reached more quickly. Defaults to 8.
Some other parts of the environment, like the strings that are
printed out when a room is entered, cannot be changed by direct
assignment, since they are part of a type definition. But you
can define your own type based on the interpreter's type and
modify anything you want about it. As an example, below, suppose
that when the player enters a room you want the game to say, "You
can see" before giving a list of visible objects or "Nothing
here." if there aren't any:
type my_room based on room
intro : "You can see"
empty_intro : "Nothing here."
end
After this, of course, make sure that all your rooms are of type
"my_room" and not of type "room".
Remember that the entire main interpreter, INTRPTR.ACH, is
written in Archetype. Once you read the Archetype manual you may
be able to understand the code in there better and modify it to
suit your taste.
Disabling Verbs
As in the previous examples, the handling of a verb is usually
left up to the main subject of the sentence. If there is some
universal sense to a verb (like 'get'), then it is usually
defined in a type on which objects are based, so that all objects
inherited from that type appear to handle that verb the same way.
Once in awhile, however, it may make more sense to disable the
verb "at the source", before the subject of the sentence gets a
chance at it. You can do this by setting the disabled attribute
of the verb you wish to disable to a string which should be
printed instead of passing the message to the main subject.
One verb in particular, "lookV" (the verb 'look'), will affect
the interpreter when disabled. No room descriptions will be
printed upon entering a room and 'i' (inventory) will not respond
either. Instead, lookV.disabled will be written. This is a
convenient way to make the player blind if the "lights" should go
out in the adventure.
Defining Your Own Verbs
Normally, the only verbs and prepositions that Archetype will
parse and process are those defined in LEXICON.ACH . If you want