-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathancients.lisp
More file actions
365 lines (292 loc) · 12.1 KB
/
ancients.lisp
File metadata and controls
365 lines (292 loc) · 12.1 KB
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
(in-package :cypress)
(defthing sextant :image "sextant.png" :scale 0.8)
(defparameter *megalith-images* (image-set "megalith" 2))
(defthing megalith
:scale 2.0
:image (random-choose *megalith-images*)
:tags '(:fixed)
:description "giant stone block")
(defthing waystone
:scale 2.0
:image (random-choose *megalith-images*)
:tags '(:fixed)
:description "ancient waystone")
(defmethod activate ((waystone waystone))
;; (cue-music (current-scene) "flutism.ogg")
(narrate "You feel a sense of contact with ancient memories.")
(mark-traversed (current-scene))
(discuss waystone :confirm))
(defparameter *waystone-hint*
"You have discovered an
ancient Waystone. Save your
quest progress here.")
(defmethod run :after ((waystone waystone))
(when (< (distance-between waystone (geoffrey))
500)
(show-hint *waystone-hint*)))
(define-topic confirm waystone
"Would you like to save your quest?" :save-progress :cancel)
(define-topic save-progress waystone
"Your progress has been saved." :ok)
(defmethod discuss :before ((waystone waystone) (topic (eql :save-progress)))
;; (destroy-gump waystone)
;; (setf (field-value :gump waystone) nil)
(save-quest))
(defmethod discuss :after ((waystone waystone) (topic (eql :save-progress)))
(with-fields (playtime) (geoffrey)
(let ((seconds (/ playtime 30)))
(narrate "Saved ~$ hours progress to ~A." (/ seconds (* 60 60)) (cypress-save-file)))))
(defthing small-ruin
:tags '(:fixed)
:image "small-ruin.png"
:description "strange stone ruin"
:scale 1.6)
(defthing stone-patio
:tags '(:fixed)
:image "ruined-patio.png"
:description "stone patio"
:scale 1.6)
(defthing stone-of-remembrance
:scale 1.5
:image "curved-stone-1.png"
:tags '(:fixed :solid)
:description "stone of remembrance")
(defun save-file-exists ()
(probe-file (cypress-save-file)))
(defmethod activate ((stone stone-of-remembrance))
(if (save-file-exists)
(progn (narrate "You feel as if Time itself is vibrating.")
(discuss stone :confirm))
(narrate "There are no stored memories here.")))
(defmethod draw :after ((stone stone-of-remembrance))
(when (save-file-exists)
(with-fields (x y) stone
(draw-string "Double-click the Stone of Remembrance to resume your quest."
(- x (units 2)) (- y (units 2))
:color "saddle brown"
:font "oldania-bold"))))
(define-topic confirm stone-of-remembrance
"Continue your saved quest?" :load-saved-quest :load-autosave :cancel)
(define-topic load-saved-quest stone-of-remembrance
"Loading quest...")
(defmethod discuss :after
((stone stone-of-remembrance) (topic (eql :load-saved-quest)))
(load-quest))
(define-topic load-autosave stone-of-remembrance
"Loading autosave file...")
(defmethod discuss :after
((stone stone-of-remembrance) (topic (eql :load-autosave)))
(load-quest (cypress-autosave-file)))
(defparameter *copper-gear-images* (image-set "copper-lock" 5))
(defthing copper-gear
:scale 0.7
:image (random-choose *copper-gear-images*))
(defparameter *copper-seal-images* (image-set "copper-seal" 4))
(defthing copper-seal
:scale 0.8
:image (random-choose *copper-seal-images*)
:tags '(:fixed))
(defthing copper-plate
:tags '(:fixed)
:channel 0
:image (random-choose '("copper-plate-1.png" "copper-plate-2.png")))
(defthing copper-stairwell :tags '(:fixed) :image (random-choose '("copper-stairwell-1.png" "copper-stairwell-2.png")))
(defmethod activate ((self copper-stairwell))
(if *previous-scene*
(restore-excursion-maybe)
(switch-to-map)))
(defparameter *copper-door-closed-images* (image-set "copper-door-closed" 2))
(defparameter *copper-door-opening-images* (image-set "copper-door-opening" 2))
(defparameter *copper-door-open-images* (image-set "copper-door-open" 2))
(defthing copper-wall
:image (random-choose *copper-door-closed-images*)
:tags '(:solid :fixed))
(defmethod collide ((monk geoffrey) (wall copper-wall)) nil)
(defthing copper-door
:image (random-choose *copper-door-closed-images*)
:channel 0
:open nil
:tags '(:solid :fixed)
:timer 0)
(defmethod lock ((door copper-door) (plate copper-plate) channel)
(setf (field-value :channel door) channel)
(setf (field-value :channel plate) channel))
(defmethod door-image ((door copper-door) n)
(cond ((> n 90) "copper-door-open-2.png")
((> n 80) "copper-door-open-1.png")
((> n 60) "copper-door-opening-1.png")
((> n 30) "copper-door-opening-2.png")
((> n 10) "copper-door-closed-1.png")
(t "copper-door-closed-2.png")))
(defmethod release-lock ((door copper-door) (gear copper-gear))
(with-fields (channel open) door
(setf open t)
(destroy gear)
(multiple-value-bind (x y) (at gear)
(let ((seal (new 'copper-seal)))
(drop-object (current-scene) seal x y)
(bark (geoffrey) "It's opening!")
(bring-to-front seal)))))
(defmethod activate ((plate copper-plate))
(block colliding
(dolist (thing (get-objects (current-scene)))
(when (and (colliding-with plate thing)
(typep thing (find-class 'copper-gear)))
(return-from colliding
(dolist (door (find-instances (current-scene) 'copper-door))
(when (= (field-value :channel plate) (field-value :channel door))
(release-lock door thing))))))))
(defmethod activate ((gear copper-gear))
(block colliding
(dolist (thing (find-colliding-objects gear))
(when (typep thing (find-class 'copper-plate))
(activate thing)))))
(defmethod run ((door copper-door))
(with-fields (y timer open image plate) door
(when (not open)
(setf (field-value :barrier-y (current-scene)) y))
(when open
(unless
(block any-locked?
(dolist (door (find-instances (current-scene) 'copper-door))
(when (not (field-value :open door))
(return-from any-locked? t))))
(setf (field-value :barrier-y (current-scene)) nil))
(setf timer
(max 0
(min (+ timer 1)
100)))
(setf image (door-image door timer)))
(if (plusp timer)
(remove-tag door :solid)
(progn (setf open nil)
(add-tag door :solid)))))
;;; Ancient garden
(defthing (garden scene)
:background-image (random-choose *grassy-meadow-images*))
(defmethod find-description ((scene garden)) "forest")
(defmethod map-icon ((scene garden)) (random-choose *forest-icons*))
(defun some-ginseng () (spatter '(ginseng stone twig) :trim t :count (+ 2 (random 4))))
(defun some-snowdrops () (spatter 'snowdrop :trim t :count (+ 1 (random 4))))
(defun ginseng-garden ()
(stacked-up
(spray '(ruin-wall) :trim nil :count (+ 2 (random 3)))
(randomly (some-ginseng)
(with-border (units 5) (singleton (new 'waystone))))
(spray '(ruin-wall ginseng ruin-wall) :trim nil :count (+ 1 (random 4)))))
(defmethod make-terrain ((scene garden))
(with-border (units 15)
(lined-up-randomly
(lined-up-randomly (some-snowdrops) (some-trees))
(lined-up-randomly (some-snowdrops) (ginseng-garden)))))
(defmethod begin-scene :after ((scene garden))
(or (percent-of-time 50 (cue-music scene (random-choose '("believe-me2.ogg" "kosmium.ogg"))) t)
(percent-of-time 20 (cue-music scene (random-choose '("mountain.ogg" "xolaros3.ogg"))))))
;;; Ancient caves
(defparameter *ancient-cave-images* (image-set "ancient-cave" 3))
(defthing (cave scene)
:darkness-image "darkness.png"
:background-image (random-choose *ancient-cave-images*))
(defmethod make-terrain ((scene cave))
(with-border (units 10)
(stacked-up (singleton (new 'crumbling-stairwell))
(spray '(ruin-wall copper-seal stone) :trim nil :count (random-choose '(2 3 4 5))))))
(defmethod initialize :after ((scene cave) &key)
(with-fields (height width) scene
(percent-of-time 80
(dotimes (n (1+ (random 5)))
(drop-object scene (new 'bone-dust) (random width) (random height))))))
(defmethod begin-scene :after ((scene cave))
(mark-traversed scene)
(clear-excursion)
(with-fields (height width) scene
(resize-to-background-image scene)
(percent-of-time 40 (cue-music scene (random-choose '("monks.ogg" "dusk.ogg" "spiritus.ogg"))))
(percent-of-time 20 (drop-object scene (new 'cryptghast) (random width) (random height)))
(percent-of-time 20 (drop-object scene (new 'cryptghast) (random width) (random height)))
(percent-of-time 40 (drop-object scene (make-box) (- width 200) (- height 200)))))
;;; First story cave
(defthing (southern-cave scene)
:darkness-image "darkness.png"
:background-image "ancient-cave-3.png")
(defmethod find-description ((scene southern-cave))
"cave")
(defmethod starting-x ((self southern-cave) direction) (units 14))
(defmethod starting-y ((self southern-cave) direction) (units 8))
(defun wall () (singleton (new 'copper-wall)))
(defmethod make-terrain ((cave southern-cave))
(let ((left-door (new 'copper-door))
(right-door (new 'copper-door))
(left-plate (new 'copper-plate))
(right-plate (new 'copper-plate)))
(lock left-door left-plate 1)
(lock right-door right-plate 2)
(stacked-up
(with-border (units 3) (singleton (new 'copper-stairwell)))
(with-border (units 15) (spatter 'bone-dust))
(lined-up (with-border (units 10) (singleton left-plate))
(with-border (units 10) (singleton right-plate)))
(lined-up (wall) (wall) (wall) (singleton left-door) (wall) (wall) (wall) (wall))
(lined-up (wall) (wall) (wall) (singleton right-door) (wall) (wall) (wall) (wall))
(with-border (units 10)
(lined-up-randomly (singleton (new 'book))
(spatter '(book ruined-book silver-book) :trim t :count 14)
(singleton (new 'alistair)))))))
(defmethod begin-scene :after ((cave southern-cave))
(mark-traversed cave)
(clear-excursion)
(resize-to-background-image cave)
(cue-music cave (random-choose '("monks.ogg" "spiritus.ogg" "dusk.ogg" "3-against-2.ogg"))))
;; (defmethod run :after ((cave southern-cave))
;; (setf (field-value :barrier-y (current-scene)) nil)
;;; Second story cave
(defthing (southeastern-cave scene)
:darkness-image "darkness.png"
:background-image "ancient-cave-2.png")
(defmethod find-description ((scene southeastern-cave))
"cave")
(defmethod starting-x ((self southeastern-cave) direction) (units 14))
(defmethod starting-y ((self southeastern-cave) direction) (units 8))
(defmethod make-terrain ((cave southeastern-cave))
(let ((left-door (new 'copper-door))
(middle-door (new 'copper-door))
(right-door (new 'copper-door))
(left-plate (new 'copper-plate))
(middle-plate (new 'copper-plate))
(right-plate (new 'copper-plate)))
(lock left-door left-plate 1)
(lock right-door right-plate 2)
(lock middle-door middle-plate 3)
(stacked-up
(with-border (units 3) (singleton (new 'copper-stairwell)))
(with-border (units 15) (spatter '(bone-dust skull)))
(lined-up (with-border (units 7) (singleton left-plate))
(with-border (units 8) (singleton middle-plate))
(with-border (units 7) (singleton right-plate)))
(lined-up (wall) (wall) (wall) (singleton left-door) (wall) (wall) (wall) (wall))
(lined-up (wall) (wall) (wall) (singleton middle-door) (wall) (wall) (wall) (wall))
(lined-up (wall) (wall) (wall) (singleton right-door) (wall) (wall) (wall) (wall))
(stacked-up
(with-border (units 10)
(spatter 'bone-dust))
(spatter 'cryptghast :count 3)))))
(defthing (quine-item-box item-box) :description "ornate silver box")
(defmethod activate :after ((box quine-item-box))
(add-event :visited-southern-cave))
(defmethod begin-scene :after ((cave southeastern-cave))
(resize-to-background-image cave)
(let ((box (new 'quine-item-box)))
(drop-object cave box (units 30) (units 140))
(add-inventory-item box (quantity-of 'copper-gear 2))
(add-inventory-item box (quantity-of 'silver-elixir 2))
(add-inventory-item box (quantity-of 'elixir 2))
(add-inventory-item box (quantity-of 'green-elixir 1))
(add-inventory-item box (tome-of 'hold-creature))
(add-inventory-item box (new 'silver-armor))
(add-inventory-item box (make-scroll "crumbling scroll" *wax-cylinder-letter*)))
(clear-excursion)
(cue-music cave (random-choose '("monks.ogg" "spiritus.ogg" "dusk.ogg" "3-against-2.ogg"))))
;;; Third story cave
(defthing (eastern-cave cave))
(defmethod find-description ((scene eastern-cave))
"cave")