-
Notifications
You must be signed in to change notification settings - Fork 0
/
dunnet.el
3359 lines (3064 loc) · 111 KB
/
dunnet.el
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
;;; dunnet.el --- text adventure for Emacs
;; Copyright (C) 1992-1993, 2001-2014 Free Software Foundation, Inc.
;; Author: Ron Schnell <[email protected]>
;; Created: 25 Jul 1992
;; Version: 2.01
;; Keywords: games
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This game can be run in batch mode. To do this, use:
;; emacs -batch -l dunnet
;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;;; The log file should be set for your system, and it must
;;; be writable by all.
;;; Code:
(defgroup dunnet nil
"Text adventure for Emacs."
:prefix "dun-"
:group 'games)
(defcustom dun-log-file "/usr/local/dunnet.score"
"Name of file to store score information for dunnet."
:type 'file
:group 'dunnet)
;;;; Mode definitions for interactive mode
(define-derived-mode dun-mode text-mode "Dungeon"
"Major mode for running dunnet."
(make-local-variable 'scroll-step)
(setq scroll-step 2))
(defun dun-parse (arg)
"Function called when return is pressed in interactive mode to parse line."
(interactive "*p")
(beginning-of-line)
(let ((beg (1+ (point)))
line)
(end-of-line)
(if (and (not (= beg (point))) (not (< (point) beg))
(string= ">" (buffer-substring (- beg 1) beg)))
(progn
(setq line (downcase (buffer-substring beg (point))))
(princ line)
(if (eq (dun-vparse dun-ignore dun-verblist line) -1)
(dun-mprinc "I don't understand that.\n")))
(goto-char (point-max))
(dun-mprinc "\n")))
(dun-messages))
(defun dun-messages ()
(if dun-dead
(text-mode)
(if (eq dungeon-mode 'dungeon)
(progn
(if (not (= room dun-current-room))
(progn
(dun-describe-room dun-current-room)
(setq room dun-current-room)))
(dun-fix-screen)
(dun-mprinc ">")))))
;;;###autoload
(defun dunnet ()
"Switch to *dungeon* buffer and start game."
(interactive)
(switch-to-buffer "*dungeon*")
(dun-mode)
(setq dun-dead nil)
(setq room 0)
(dun-messages))
;;;;
;;;; This section contains all of the verbs and commands.
;;;;
;;; Give long description of room if haven't been there yet. Otherwise
;;; short. Also give long if we were called with negative room number.
(defun dun-describe-room (room)
(if (and (not (member (abs room) dun-light-rooms))
(not (member obj-lamp dun-inventory)))
(dun-mprincl "It is pitch dark. You are likely to be eaten by a grue.")
(dun-mprincl (cadr (nth (abs room) dun-rooms)))
(if (and (and (or (member room dun-visited)
(string= dun-mode "dun-superb")) (> room 0))
(not (string= dun-mode "long")))
nil
(dun-mprinc (car (nth (abs room) dun-rooms)))
(dun-mprinc "\n"))
(if (not (string= dun-mode "long"))
(if (not (member (abs room) dun-visited))
(setq dun-visited (append (list (abs room)) dun-visited))))
(dolist (xobjs (nth dun-current-room dun-room-objects))
(if (= xobjs obj-special)
(dun-special-object)
(if (>= xobjs 0)
(dun-mprincl (car (nth xobjs dun-objects)))
(if (not (and (= xobjs obj-bus) dun-inbus))
(progn
(dun-mprincl (car (nth (abs xobjs) dun-perm-objects)))))))
(if (and (= xobjs obj-jar) dun-jar)
(progn
(dun-mprincl "The jar contains:")
(dolist (x dun-jar)
(dun-mprinc " ")
(dun-mprincl (car (nth x dun-objects)))))))
(if (and (member obj-bus (nth dun-current-room dun-room-objects)) dun-inbus)
(dun-mprincl "You are on the bus."))))
;;; There is a special object in the room. This object's description,
;;; or lack thereof, depends on certain conditions.
(defun dun-special-object ()
(if (= dun-current-room computer-room)
(if dun-computer
(dun-mprincl
"The panel lights are flashing in a seemingly organized pattern.")
(dun-mprincl "The panel lights are steady and motionless.")))
(if (and (= dun-current-room red-room)
(not (member obj-towel (nth red-room dun-room-objects))))
(dun-mprincl "There is a hole in the floor here."))
(if (and (= dun-current-room marine-life-area) dun-black)
(dun-mprincl
"The room is lit by a black light, causing the fish, and some of
your objects, to give off an eerie glow."))
(if (and (= dun-current-room fourth-vermont-intersection) dun-hole)
(progn
(if (not dun-inbus)
(progn
(dun-mprincl"You fall into a hole in the ground.")
(setq dun-current-room vermont-station)
(dun-describe-room vermont-station))
(progn
(dun-mprincl
"The bus falls down a hole in the ground and explodes.")
(dun-die "burning")))))
(if (> dun-current-room endgame-computer-room)
(progn
(if (not dun-correct-answer)
(dun-endgame-question)
(dun-mprincl "Your question is:")
(dun-mprincl dun-endgame-question))))
(if (= dun-current-room sauna)
(progn
(dun-mprincl (nth dun-sauna-level '(
"It is normal room temperature in here."
"It is luke warm in here."
"It is comfortably hot in here."
"It is refreshingly hot in here."
"You are dead now.")))
(if (= dun-sauna-level 3)
(progn
(if (or (member obj-rms dun-inventory)
(member obj-rms (nth dun-current-room dun-room-objects)))
(progn
(dun-mprincl
"You notice the wax on your statuette beginning to melt, until it completely
melts off. You are left with a beautiful diamond!")
(if (member obj-rms dun-inventory)
(progn
(dun-remove-obj-from-inven obj-rms)
(setq dun-inventory (append dun-inventory
(list obj-diamond))))
(dun-remove-obj-from-room dun-current-room obj-rms)
(dun-replace dun-room-objects dun-current-room
(append (nth dun-current-room dun-room-objects)
(list obj-diamond))))))
(if (or (member obj-floppy dun-inventory)
(member obj-floppy (nth dun-current-room dun-room-objects)))
(progn
(dun-mprincl
"You notice your floppy disk beginning to melt. As you grab for it, the
disk bursts into flames, and disintegrates.")
(dun-remove-obj-from-inven obj-floppy)
(dun-remove-obj-from-room dun-current-room obj-floppy))))))))
(defun dun-die (murderer)
(dun-mprinc "\n")
(if murderer
(dun-mprincl "You are dead."))
(dun-do-logfile 'dun-die murderer)
(dun-score nil)
(setq dun-dead t))
(defun dun-quit (args)
(dun-die nil))
;;; Print every object in player's inventory. Special case for the jar,
;;; as we must also print what is in it.
(defun dun-inven (args)
(dun-mprinc "You currently have:")
(dun-mprinc "\n")
(dolist (curobj dun-inventory)
(if curobj
(progn
(dun-mprincl (cadr (nth curobj dun-objects)))
(if (and (= curobj obj-jar) dun-jar)
(progn
(dun-mprincl "The jar contains:")
(dolist (x dun-jar)
(dun-mprinc " ")
(dun-mprincl (cadr (nth x dun-objects))))))))))
(defun dun-shake (obj)
(let (objnum)
(when (setq objnum (dun-objnum-from-args-std obj))
(if (member objnum dun-inventory)
(progn
;;; If shaking anything will do anything, put here.
(dun-mprinc "Shaking ")
(dun-mprinc (downcase (cadr (nth objnum dun-objects))))
(dun-mprinc " seems to have no effect.")
(dun-mprinc "\n")
)
(if (and (not (member objnum (nth dun-current-room dun-room-silents)))
(not (member objnum (nth dun-current-room dun-room-objects))))
(dun-mprincl "I don't see that here.")
;;; Shaking trees can be deadly
(if (= objnum obj-tree)
(progn
(dun-mprinc
"You begin to shake a tree, and notice a coconut begin to fall from the air.
As you try to get your hand up to block it, you feel the impact as it lands
on your head.")
(dun-die "a coconut"))
(if (= objnum obj-bear)
(progn
(dun-mprinc
"As you go up to the bear, it removes your head and places it on the ground.")
(dun-die "a bear"))
(if (< objnum 0)
(dun-mprincl "You cannot shake that.")
(dun-mprincl "You don't have that.")))))))))
(defun dun-drop (obj)
(if dun-inbus
(dun-mprincl "You can't drop anything while on the bus.")
(let (objnum ptr)
(when (setq objnum (dun-objnum-from-args-std obj))
(if (not (setq ptr (member objnum dun-inventory)))
(dun-mprincl "You don't have that.")
(progn
(dun-remove-obj-from-inven objnum)
(dun-replace dun-room-objects dun-current-room
(append (nth dun-current-room dun-room-objects)
(list objnum)))
(dun-mprincl "Done.")
(if (member objnum (list obj-food obj-weight obj-jar))
(dun-drop-check objnum))))))))
;;; Dropping certain things causes things to happen.
(defun dun-drop-check (objnum)
(if (and (= objnum obj-food) (= room bear-hangout)
(member obj-bear (nth bear-hangout dun-room-objects)))
(progn
(dun-mprincl
"The bear takes the food and runs away with it. He left something behind.")
(dun-remove-obj-from-room dun-current-room obj-bear)
(dun-remove-obj-from-room dun-current-room obj-food)
(dun-replace dun-room-objects dun-current-room
(append (nth dun-current-room dun-room-objects)
(list obj-key)))))
(if (and (= objnum obj-jar) (member obj-nitric dun-jar)
(member obj-glycerine dun-jar))
(progn
(dun-mprincl
"As the jar impacts the ground it explodes into many pieces.")
(setq dun-jar nil)
(dun-remove-obj-from-room dun-current-room obj-jar)
(if (= dun-current-room fourth-vermont-intersection)
(progn
(setq dun-hole t)
(setq dun-current-room vermont-station)
(dun-mprincl
"The explosion causes a hole to open up in the ground, which you fall
through.")))))
(if (and (= objnum obj-weight) (= dun-current-room maze-button-room))
(dun-mprincl "A passageway opens.")))
;;; Give long description of current room, or an object.
(defun dun-examine (obj)
(let (objnum)
(setq objnum (dun-objnum-from-args obj))
(if (eq objnum obj-special)
(dun-describe-room (* dun-current-room -1))
(if (and (eq objnum obj-computer)
(member obj-pc (nth dun-current-room dun-room-silents)))
(dun-examine '("pc"))
(if (eq objnum nil)
(dun-mprincl "I don't know what that is.")
(if (and (not (member objnum
(nth dun-current-room dun-room-objects)))
(not (and (member obj-jar dun-inventory)
(member objnum dun-jar)))
(not (member objnum
(nth dun-current-room dun-room-silents)))
(not (member objnum dun-inventory)))
(dun-mprincl "I don't see that here.")
(if (>= objnum 0)
(if (and (= objnum obj-bone)
(= dun-current-room marine-life-area) dun-black)
(dun-mprincl
"In this light you can see some writing on the bone. It says:
For an explosive time, go to Fourth St. and Vermont.")
(if (nth objnum dun-physobj-desc)
(dun-mprincl (nth objnum dun-physobj-desc))
(dun-mprincl "I see nothing special about that.")))
(if (nth (abs objnum) dun-permobj-desc)
(progn
(dun-mprincl (nth (abs objnum) dun-permobj-desc)))
(dun-mprincl "I see nothing special about that.")))))))))
(defun dun-take (obj)
(setq obj (dun-firstword obj))
(if (not obj)
(dun-mprincl "You must supply an object.")
(if (string= obj "all")
(let (gotsome)
(if dun-inbus
(dun-mprincl "You can't take anything while on the bus.")
(setq gotsome nil)
(dolist (x (nth dun-current-room dun-room-objects))
(if (and (>= x 0) (not (= x obj-special)))
(progn
(setq gotsome t)
(dun-mprinc (cadr (nth x dun-objects)))
(dun-mprinc ": ")
(dun-take-object x))))
(if (not gotsome)
(dun-mprincl "Nothing to take."))))
(let (objnum)
(setq objnum (cdr (assq (intern obj) dun-objnames)))
(if (eq objnum nil)
(progn
(dun-mprinc "I don't know what that is.")
(dun-mprinc "\n"))
(if (and dun-inbus (not (and (member objnum dun-jar)
(member obj-jar dun-inventory))))
(dun-mprincl "You can't take anything while on the bus.")
(dun-take-object objnum)))))))
(defun dun-take-object (objnum)
(if (and (member objnum dun-jar) (member obj-jar dun-inventory))
(let (newjar)
(dun-mprincl "You remove it from the jar.")
(setq newjar nil)
(dolist (x dun-jar)
(if (not (= x objnum))
(setq newjar (append newjar (list x)))))
(setq dun-jar newjar)
(setq dun-inventory (append dun-inventory (list objnum))))
(if (not (member objnum (nth dun-current-room dun-room-objects)))
(if (not (member objnum (nth dun-current-room dun-room-silents)))
(dun-mprinc "I do not see that here.")
(dun-try-take objnum))
(if (>= objnum 0)
(progn
(if (and (car dun-inventory)
(> (+ (dun-inven-weight) (nth objnum dun-object-lbs)) 11))
(dun-mprinc "Your load would be too heavy.")
(setq dun-inventory (append dun-inventory (list objnum)))
(dun-remove-obj-from-room dun-current-room objnum)
(dun-mprinc "Taken. ")
(if (and (= objnum obj-towel) (= dun-current-room red-room))
(dun-mprinc
"Taking the towel reveals a hole in the floor."))))
(dun-try-take objnum)))
(dun-mprinc "\n")))
(defun dun-inven-weight ()
(let (total)
(setq total 0)
(dolist (x dun-jar)
(setq total (+ total (nth x dun-object-lbs))))
(dolist (x dun-inventory)
(setq total (+ total (nth x dun-object-lbs)))) total))
;;; We try to take an object that is untakable. Print a message
;;; depending on what it is.
(defun dun-try-take (obj)
(dun-mprinc "You cannot take that."))
(defun dun-dig (args)
(if dun-inbus
(dun-mprincl "Digging here reveals nothing.")
(if (not (member 0 dun-inventory))
(dun-mprincl "You have nothing with which to dig.")
(if (not (nth dun-current-room dun-diggables))
(dun-mprincl "Digging here reveals nothing.")
(dun-mprincl "I think you found something.")
(dun-replace dun-room-objects dun-current-room
(append (nth dun-current-room dun-room-objects)
(nth dun-current-room dun-diggables)))
(dun-replace dun-diggables dun-current-room nil)))))
(defun dun-climb (obj)
(let (objnum)
(setq objnum (dun-objnum-from-args obj))
(cond ((not objnum)
(dun-mprincl "I don't know what that object is."))
((and (not (eq objnum obj-special))
(not (member objnum (nth dun-current-room dun-room-objects)))
(not (member objnum (nth dun-current-room dun-room-silents)))
(not (and (member objnum dun-jar) (member obj-jar dun-inventory)))
(not (member objnum dun-inventory)))
(dun-mprincl "I don't see that here."))
((and (eq objnum obj-special)
(not (member obj-tree (nth dun-current-room dun-room-silents))))
(dun-mprincl "There is nothing here to climb."))
((and (not (eq objnum obj-tree)) (not (eq objnum obj-special)))
(dun-mprincl "You can't climb that."))
(t
(dun-mprincl
"You manage to get about two feet up the tree and fall back down. You
notice that the tree is very unsteady.")))))
(defun dun-eat (obj)
(let (objnum)
(when (setq objnum (dun-objnum-from-args-std obj))
(if (not (member objnum dun-inventory))
(dun-mprincl "You don't have that.")
(if (not (= objnum obj-food))
(progn
(dun-mprinc "You forcefully shove ")
(dun-mprinc (downcase (cadr (nth objnum dun-objects))))
(dun-mprincl " down your throat, and start choking.")
(dun-die "choking"))
(dun-mprincl "That tasted horrible.")
(dun-remove-obj-from-inven obj-food))))))
(defun dun-put (args)
(let (newargs objnum objnum2 obj)
(setq newargs (dun-firstwordl args))
(if (not newargs)
(dun-mprincl "You must supply an object")
(setq obj (intern (car newargs)))
(setq objnum (cdr (assq obj dun-objnames)))
(if (not objnum)
(dun-mprincl "I don't know what that object is.")
(if (not (member objnum dun-inventory))
(dun-mprincl "You don't have that.")
(setq newargs (dun-firstwordl (cdr newargs)))
(setq newargs (dun-firstwordl (cdr newargs)))
(if (not newargs)
(dun-mprincl "You must supply an indirect object.")
(setq objnum2 (cdr (assq (intern (car newargs)) dun-objnames)))
(if (and (eq objnum2 obj-computer) (= dun-current-room pc-area))
(setq objnum2 obj-pc))
(if (not objnum2)
(dun-mprincl "I don't know what that indirect object is.")
(if (and (not (member objnum2
(nth dun-current-room dun-room-objects)))
(not (member objnum2
(nth dun-current-room dun-room-silents)))
(not (member objnum2 dun-inventory)))
(dun-mprincl "That indirect object is not here.")
(dun-put-objs objnum objnum2)))))))))
(defun dun-put-objs (obj1 obj2)
(if (and (= obj2 obj-drop) (not dun-nomail))
(setq obj2 obj-chute))
(if (= obj2 obj-disposal) (setq obj2 obj-chute))
(if (and (= obj1 obj-cpu) (= obj2 obj-computer))
(progn
(dun-remove-obj-from-inven obj-cpu)
(setq dun-computer t)
(dun-mprincl
"As you put the CPU board in the computer, it immediately springs to life.
The lights start flashing, and the fans seem to startup."))
(if (and (= obj1 obj-weight) (= obj2 obj-button))
(dun-drop '("weight"))
(if (= obj2 obj-jar) ;; Put something in jar
(if (not (member obj1 (list obj-paper obj-diamond obj-emerald
obj-license obj-coins obj-egg
obj-nitric obj-glycerine)))
(dun-mprincl "That will not fit in the jar.")
(dun-remove-obj-from-inven obj1)
(setq dun-jar (append dun-jar (list obj1)))
(dun-mprincl "Done."))
(if (= obj2 obj-chute) ;; Put something in chute
(progn
(dun-remove-obj-from-inven obj1)
(dun-mprincl
"You hear it slide down the chute and off into the distance.")
(dun-put-objs-in-treas (list obj1)))
(if (= obj2 obj-box) ;; Put key in key box
(if (= obj1 obj-key)
(progn
(dun-mprincl
"As you drop the key, the box begins to shake. Finally it explodes
with a bang. The key seems to have vanished!")
(dun-remove-obj-from-inven obj1)
(dun-replace dun-room-objects computer-room (append
(nth computer-room
dun-room-objects)
(list obj1)))
(dun-remove-obj-from-room dun-current-room obj-box)
(setq dun-key-level (1+ dun-key-level)))
(dun-mprincl "You can't put that in the key box!"))
(if (and (= obj1 obj-floppy) (= obj2 obj-pc))
(progn
(setq dun-floppy t)
(dun-remove-obj-from-inven obj1)
(dun-mprincl "Done."))
(if (= obj2 obj-urinal) ;; Put object in urinal
(progn
(dun-remove-obj-from-inven obj1)
(dun-replace dun-room-objects urinal (append
(nth urinal dun-room-objects)
(list obj1)))
(dun-mprincl
"You hear it plop down in some water below."))
(if (= obj2 obj-mail)
(dun-mprincl "The mail chute is locked.")
(if (member obj1 dun-inventory)
(dun-mprincl
"I don't know how to combine those objects. Perhaps you should
just try dropping it.")
(dun-mprincl"You can't put that there.")))))))))))
(defun dun-type (args)
(if (not (= dun-current-room computer-room))
(dun-mprincl "There is nothing here on which you could type.")
(if (not dun-computer)
(dun-mprincl
"You type on the keyboard, but your characters do not even echo.")
(dun-unix-interface))))
;;; Various movement directions
(defun dun-n (args)
(dun-move north))
(defun dun-s (args)
(dun-move south))
(defun dun-e (args)
(dun-move east))
(defun dun-w (args)
(dun-move west))
(defun dun-ne (args)
(dun-move northeast))
(defun dun-se (args)
(dun-move southeast))
(defun dun-nw (args)
(dun-move northwest))
(defun dun-sw (args)
(dun-move southwest))
(defun dun-up (args)
(dun-move up))
(defun dun-down (args)
(dun-move down))
(defun dun-in (args)
(dun-move in))
(defun dun-out (args)
(dun-move out))
(defun dun-go (args)
(if (or (not (car args))
(eq (dun-doverb dun-ignore dun-verblist (car args)
(cdr (cdr args))) -1))
(dun-mprinc "I don't understand where you want me to go.\n")))
;;; Uses the dungeon-map to figure out where we are going. If the
;;; requested direction yields 255, we know something special is
;;; supposed to happen, or perhaps you can't go that way unless
;;; certain conditions are met.
(defun dun-move (dir)
(if (and (not (member dun-current-room dun-light-rooms))
(not (member obj-lamp dun-inventory)))
(progn
(dun-mprinc
"You trip over a grue and fall into a pit and break every bone in your
body.")
(dun-die "a grue"))
(let (newroom)
(setq newroom (nth dir (nth dun-current-room dungeon-map)))
(if (eq newroom -1)
(dun-mprinc "You can't go that way.\n")
(if (eq newroom 255)
(dun-special-move dir)
(setq room -1)
(setq dun-lastdir dir)
(if dun-inbus
(progn
(if (or (< newroom 58) (> newroom 83))
(dun-mprincl "The bus cannot go this way.")
(dun-mprincl
"The bus lurches ahead and comes to a screeching halt.")
(dun-remove-obj-from-room dun-current-room obj-bus)
(setq dun-current-room newroom)
(dun-replace dun-room-objects newroom
(append (nth newroom dun-room-objects)
(list obj-bus)))))
(setq dun-current-room newroom)))))))
;;; Movement in this direction causes something special to happen if the
;;; right conditions exist. It may be that you can't go this way unless
;;; you have a key, or a passage has been opened.
;;; coding note: Each check of the current room is on the same 'if' level,
;;; i.e. there aren't else's. If two rooms next to each other have
;;; specials, and they are connected by specials, this could cause
;;; a problem. Be careful when adding them to consider this, and
;;; perhaps use else's.
(defun dun-special-move (dir)
(if (= dun-current-room building-front)
(if (not (member obj-key dun-inventory))
(dun-mprincl "You don't have a key that can open this door.")
(setq dun-current-room old-building-hallway))
(if (= dun-current-room north-end-of-cave-passage)
(let (combo)
(dun-mprincl
"You must type a 3 digit combination code to enter this room.")
(dun-mprinc "Enter it here: ")
(setq combo (dun-read-line))
(if (not dun-batch-mode)
(dun-mprinc "\n"))
(if (string= combo dun-combination)
(setq dun-current-room gamma-computing-center)
(dun-mprincl "Sorry, that combination is incorrect."))))
(if (= dun-current-room bear-hangout)
(if (member obj-bear (nth bear-hangout dun-room-objects))
(progn
(dun-mprinc
"The bear is very annoyed that you would be so presumptuous as to try
and walk right by it. He tells you so by tearing your head off.
")
(dun-die "a bear"))
(dun-mprincl "You can't go that way.")))
(if (= dun-current-room vermont-station)
(progn
(dun-mprincl
"As you board the train it immediately leaves the station. It is a very
bumpy ride. It is shaking from side to side, and up and down. You
sit down in one of the chairs in order to be more comfortable.")
(dun-mprincl
"\nFinally the train comes to a sudden stop, and the doors open, and some
force throws you out. The train speeds away.\n")
(setq dun-current-room museum-station)))
(if (= dun-current-room old-building-hallway)
(if (and (member obj-key dun-inventory)
(> dun-key-level 0))
(setq dun-current-room meadow)
(dun-mprincl "You don't have a key that can open this door.")))
(if (and (= dun-current-room maze-button-room) (= dir northwest))
(if (member obj-weight (nth maze-button-room dun-room-objects))
(setq dun-current-room 18)
(dun-mprincl "You can't go that way.")))
(if (and (= dun-current-room maze-button-room) (= dir up))
(if (member obj-weight (nth maze-button-room dun-room-objects))
(dun-mprincl "You can't go that way.")
(setq dun-current-room weight-room)))
(if (= dun-current-room classroom)
(dun-mprincl "The door is locked."))
(if (or (= dun-current-room lakefront-north)
(= dun-current-room lakefront-south))
(dun-swim nil))
(if (= dun-current-room reception-area)
(if (not (= dun-sauna-level 3))
(setq dun-current-room health-club-front)
(dun-mprincl
"As you exit the building, you notice some flames coming out of one of the
windows. Suddenly, the building explodes in a huge ball of fire. The flames
engulf you, and you burn to death.")
(dun-die "burning")))
(if (= dun-current-room red-room)
(if (not (member obj-towel (nth red-room dun-room-objects)))
(setq dun-current-room long-n-s-hallway)
(dun-mprincl "You can't go that way.")))
(if (and (> dir down) (> dun-current-room gamma-computing-center)
(< dun-current-room museum-lobby))
(if (not (member obj-bus (nth dun-current-room dun-room-objects)))
(dun-mprincl "You can't go that way.")
(if (= dir in)
(if dun-inbus
(dun-mprincl
"You are already in the bus!")
(if (member obj-license dun-inventory)
(progn
(dun-mprincl
"You board the bus and get in the driver's seat.")
(setq dun-nomail t)
(setq dun-inbus t))
(dun-mprincl "You are not licensed for this type of vehicle.")))
(if (not dun-inbus)
(dun-mprincl "You are already off the bus!")
(dun-mprincl "You hop off the bus.")
(setq dun-inbus nil))))
(if (= dun-current-room fifth-oaktree-intersection)
(if (not dun-inbus)
(progn
(dun-mprincl "You fall down the cliff and land on your head.")
(dun-die "a cliff"))
(dun-mprincl
"The bus flies off the cliff, and plunges to the bottom, where it explodes.")
(dun-die "a bus accident")))
(if (= dun-current-room main-maple-intersection)
(progn
(if (not dun-inbus)
(dun-mprincl "The gate will not open.")
(dun-mprincl
"As the bus approaches, the gate opens and you drive through.")
(dun-remove-obj-from-room main-maple-intersection obj-bus)
(dun-replace dun-room-objects museum-entrance
(append (nth museum-entrance dun-room-objects)
(list obj-bus)))
(setq dun-current-room museum-entrance)))))
(if (= dun-current-room cave-entrance)
(progn
(dun-mprincl
"As you enter the room you hear a rumbling noise. You look back to see
huge rocks sliding down from the ceiling, and blocking your way out.\n")
(setq dun-current-room misty-room)))))
(defun dun-long (args)
(setq dun-mode "long"))
(defun dun-turn (obj)
(let (objnum direction)
(when (setq objnum (dun-objnum-from-args-std obj))
(if (not (or (member objnum (nth dun-current-room dun-room-objects))
(member objnum (nth dun-current-room dun-room-silents))))
(dun-mprincl "I don't see that here.")
(if (not (= objnum obj-dial))
(dun-mprincl "You can't turn that.")
(setq direction (dun-firstword (cdr obj)))
(if (or (not direction)
(not (or (string= direction "clockwise")
(string= direction "counterclockwise"))))
(dun-mprincl "You must indicate clockwise or counterclockwise.")
(if (string= direction "clockwise")
(setq dun-sauna-level (+ dun-sauna-level 1))
(setq dun-sauna-level (- dun-sauna-level 1)))
(if (< dun-sauna-level 0)
(progn
(dun-mprincl
"The dial will not turn further in that direction.")
(setq dun-sauna-level 0))
(dun-sauna-heat))))))))
(defun dun-sauna-heat ()
(if (= dun-sauna-level 0)
(dun-mprincl
"The temperature has returned to normal room temperature."))
(if (= dun-sauna-level 1)
(dun-mprincl "It is now luke warm in here. You are perspiring."))
(if (= dun-sauna-level 2)
(dun-mprincl "It is pretty hot in here. It is still very comfortable."))
(if (= dun-sauna-level 3)
(progn
(dun-mprincl
"It is now very hot. There is something very refreshing about this.")
(if (or (member obj-rms dun-inventory)
(member obj-rms (nth dun-current-room dun-room-objects)))
(progn
(dun-mprincl
"You notice the wax on your statuette beginning to melt, until it completely
melts off. You are left with a beautiful diamond!")
(if (member obj-rms dun-inventory)
(progn
(dun-remove-obj-from-inven obj-rms)
(setq dun-inventory (append dun-inventory
(list obj-diamond))))
(dun-remove-obj-from-room dun-current-room obj-rms)
(dun-replace dun-room-objects dun-current-room
(append (nth dun-current-room dun-room-objects)
(list obj-diamond))))))
(if (or (member obj-floppy dun-inventory)
(member obj-floppy (nth dun-current-room dun-room-objects)))
(progn
(dun-mprincl
"You notice your floppy disk beginning to melt. As you grab for it, the
disk bursts into flames, and disintegrates.")
(if (member obj-floppy dun-inventory)
(dun-remove-obj-from-inven obj-floppy)
(dun-remove-obj-from-room dun-current-room obj-floppy))))))
(if (= dun-sauna-level 4)
(progn
(dun-mprincl
"As the dial clicks into place, you immediately burst into flames.")
(dun-die "burning"))))
(defun dun-press (obj)
(let (objnum)
(when (setq objnum (dun-objnum-from-args-std obj))
(if (not (or (member objnum (nth dun-current-room dun-room-objects))
(member objnum (nth dun-current-room dun-room-silents))))
(dun-mprincl "I don't see that here.")
(if (not (member objnum (list obj-button obj-switch)))
(progn
(dun-mprinc "You can't ")
(dun-mprinc (car line-list))
(dun-mprincl " that."))
(if (= objnum obj-button)
(dun-mprincl
"As you press the button, you notice a passageway open up, but
as you release it, the passageway closes."))
(if (= objnum obj-switch)
(if dun-black
(progn
(dun-mprincl "The button is now in the off position.")
(setq dun-black nil))
(dun-mprincl "The button is now in the on position.")
(setq dun-black t))))))))
(defun dun-swim (args)
(if (not (member dun-current-room (list lakefront-north lakefront-south)))
(dun-mprincl "I see no water!")
(if (not (member obj-life dun-inventory))
(progn
(dun-mprincl
"You dive in the water, and at first notice it is quite cold. You then
start to get used to it as you realize that you never really learned how
to swim.")
(dun-die "drowning"))
(if (= dun-current-room lakefront-north)
(setq dun-current-room lakefront-south)
(setq dun-current-room lakefront-north)))))
(defun dun-score (args)
(if (not dun-endgame)
(let (total)
(setq total (dun-reg-score))
(dun-mprinc "You have scored ")
(dun-mprinc total)
(dun-mprincl " out of a possible 90 points.") total)
(dun-mprinc "You have scored ")
(dun-mprinc (dun-endgame-score))
(dun-mprincl " endgame points out of a possible 110.")
(if (= (dun-endgame-score) 110)
(dun-mprincl
"\n\nCongratulations. You have won. The wizard password is 'moby'"))))
(defun dun-help (args)
(dun-mprincl
"Welcome to dunnet (2.01), by Ron Schnell ([email protected]).
Here is some useful information (read carefully because there are one
or more clues in here):
- If you have a key that can open a door, you do not need to explicitly
open it. You may just use 'in' or walk in the direction of the door.
- If you have a lamp, it is always lit.
- You will not get any points until you manage to get treasures to a certain
place. Simply finding the treasures is not good enough. There is more
than one way to get a treasure to the special place. It is also
important that the objects get to the special place *unharmed* and
*untarnished*. You can tell if you have successfully transported the
object by looking at your score, as it changes immediately. Note that
an object can become harmed even after you have received points for it.
If this happens, your score will decrease, and in many cases you can never
get credit for it again.
- You can save your game with the 'save' command, and use restore it
with the 'restore' command.
- There are no limits on lengths of object names.
- Directions are: north,south,east,west,northeast,southeast,northwest,
southwest,up,down,in,out.
- These can be abbreviated: n,s,e,w,ne,se,nw,sw,u,d,in,out.
- If you go down a hole in the floor without an aid such as a ladder,
you probably won't be able to get back up the way you came, if at all.
- To run this game in batch mode (no Emacs window), use:
emacs -batch -l dunnet
NOTE: This game *should* be run in batch mode!
If you have questions or comments, please contact [email protected]
My home page is http://www.driver-aces.com/ronnie.html
"))
(defun dun-flush (args)
(if (not (= dun-current-room bathroom))
(dun-mprincl "I see nothing to flush.")
(dun-mprincl "Whoooosh!!")
(dun-put-objs-in-treas (nth urinal dun-room-objects))
(dun-replace dun-room-objects urinal nil)))
(defun dun-piss (args)
(if (not (= dun-current-room bathroom))
(dun-mprincl "You can't do that here, don't even bother trying.")
(if (not dun-gottago)
(dun-mprincl "I'm afraid you don't have to go now.")
(dun-mprincl "That was refreshing.")
(setq dun-gottago nil)
(dun-replace dun-room-objects urinal (append
(nth urinal dun-room-objects)
(list obj-URINE))))))
(defun dun-sleep (args)
(if (not (= dun-current-room bedroom))
(dun-mprincl
"You try to go to sleep while standing up here, but can't seem to do it.")
(setq dun-gottago t)
(dun-mprincl
"As soon as you start to doze off you begin dreaming. You see images of
workers digging caves, slaving in the humid heat. Then you see yourself
as one of these workers. While no one is looking, you leave the group
and walk into a room. The room is bare except for a horseshoe
shaped piece of stone in the center. You see yourself digging a hole in
the ground, then putting some kind of treasure in it, and filling the hole
with dirt again. After this, you immediately wake up.")))
(defun dun-break (obj)
(let (objnum)
(if (not (member obj-axe dun-inventory))
(dun-mprincl "You have nothing you can use to break things.")
(when (setq objnum (dun-objnum-from-args-std obj))
(if (member objnum dun-inventory)
(progn
(dun-mprincl
"You take the object in your hands and swing the axe. Unfortunately, you miss
the object and slice off your hand. You bleed to death.")
(dun-die "an axe"))
(if (not (or (member objnum (nth dun-current-room dun-room-objects))
(member objnum
(nth dun-current-room dun-room-silents))))
(dun-mprincl "I don't see that here.")
(if (= objnum obj-cable)
(progn
(dun-mprincl
"As you break the ethernet cable, everything starts to blur. You collapse
for a moment, then straighten yourself up.
")
(dun-replace dun-room-objects gamma-computing-center
(append
(nth gamma-computing-center dun-room-objects)
dun-inventory))
(if (member obj-key dun-inventory)
(progn
(setq dun-inventory (list obj-key))
(dun-remove-obj-from-room
gamma-computing-center obj-key))