1;;----------------------------------------------------------------------------
2;; The very first line of any session file should be (load "naz.scm"). This
3;; bootstraps some procedures that we need to continue. This is the only place
4;; you should use 'load'. Every other place you want to load a file you should
5;; user 'kern-load'. 'kern-load' ensures that a saved session will be able to
6;; load the file, too.
7;;----------------------------------------------------------------------------
8(load "naz.scm")
9
10;; clone of game.scm ---------------------------------------------------------
11
12;; Setup progress bar stuff. The number 44 should be the total number of files
13;; we're going to load.
14(kern-progress-bar-start "Loading" 44)
15
16;; Wrap the original definition of (load ...) with one that advances the
17;; progress bar.
18(define original-load load)
19(define (load file)
20  (kern-progress-bar-advance 1)
21  (original-load file)
22  )
23
24;;----------------------------------------------------------------------------
25;; Constants
26;;----------------------------------------------------------------------------
27
28;; Slots
29(define slot-nil              0)
30(define slot-amulet           1)
31(define slot-ring             2)
32(define slot-gazer-helm       4)
33(define slot-weapon           8)
34(define slot-shield           8)
35(define slot-weapon-or-shield 8)
36(define slot-armor            16)
37(define slot-boot             32)
38(define slot-helm             64)
39
40;; Speeds  ;; TODO: move most of these into kern-intvars ?
41
42(define speed-human             50)  ;; typical AP/round for humans
43
44(define base-move-ap		50)  ;; this may not bear a neat relationship to speed-human
45(define default-weapon-rap      50)  ;; this may not bear a neat relationship to speed-human
46(define default-armour-apmod    2)  ;; this may not bear a neat relationship to speed-human
47
48(define base-skill-ap			base-move-ap)  ;; this may not bear a neat relationship to speed-human
49(define base-spell-ap			base-move-ap)  ;; this may not bear a neat relationship to speed-human
50
51;; AP costs of various actions which the kernal needs to know about:
52(kern-set-kern-intvar "AP_TOTAL:normal_human"    speed-human)
53
54(kern-set-kern-intvar "AP_COST:default"           speed-human)
55(kern-set-kern-intvar "AP_COST:search"            (* 3 speed-human))
56(kern-set-kern-intvar "AP_COST:get_item"          (* 0.34 speed-human))
57(kern-set-kern-intvar "AP_COST:drop_item"         (* 0.34 speed-human))
58(kern-set-kern-intvar "AP_COST:open_mechanism"    speed-human)
59(kern-set-kern-intvar "AP_COST:open_container"    speed-human)
60(kern-set-kern-intvar "AP_COST:handle_mechanism"  speed-human)
61(kern-set-kern-intvar "AP_COST:use_item"          speed-human)  ;; may be unused, per comment in cmd.c cmdUse()
62
63;; Normal mixing: 18 + (num_mixed * 12) + (spell_level * 12) AP
64(kern-set-kern-intvar "AP_COST:mix_reagents_base"         (* 3 speed-human))
65(kern-set-kern-intvar "AP_COST:mix_reagents_per_mix"      (* 2 speed-human))
66(kern-set-kern-intvar "AP_COST:mix_reagents_per_level"    (* 2 speed-human))
67;; Attempt at non-existent spell: 3d18+6 AP
68(kern-set-kern-intvar "AP_COST:mix_reagents_nospell_num"   3)
69(kern-set-kern-intvar "AP_COST:mix_reagents_nospell_dice" (* 3 speed-human))
70(kern-set-kern-intvar "AP_COST:mix_reagents_nospell_plus"  speed-human)
71;; Missing or additional ingredients: (2 * spell_level)d18+18 AP
72(kern-set-kern-intvar "AP_COST:mix_reagents_badmix_num"    2)  ;; times spell Level
73(kern-set-kern-intvar "AP_COST:mix_reagents_badmix_dice"  (* 3 speed-human))
74(kern-set-kern-intvar "AP_COST:mix_reagents_badmix_plus"  (* 3 speed-human))
75
76;; These values are used by ctrl.c ctrl_attack_target()
77;; to adjust weapon AP costs in the event of dual wielding.
78;; The dual weapon rules can thus be tweaked here...
79(kern-set-kern-intvar "AP_MULT12:second_wpn_attack"       6)  ;; AP cost * 6/12 for 2nd weapon attack if dual wpns used
80(kern-set-kern-intvar "AP_MULT12:third_plus_wpn_attack"   6)  ;; AP cost * 6/12 for 3rd+ weapon attacks, if 3+ weapons used
81(kern-set-kern-intvar "AP_THRESHOLD:multi_attack_overage" 0)  ;; attack sequence can continue if AP overage is not > 0
82
83(kern-set-kern-intvar "submerged_def_bonus" 10) ;; defense bonus for submerged critters
84
85;; ship speeds are better handled using mmodes/pclasses-
86;; it should only affect actual movement
87(define speed-ship            speed-human)
88
89;; Action Point costs for various basic actions:
90;; are these used anywhere?
91;;(define ap-for-1H-melee-attack   9)
92;;(define ap-for-2H-melee-attack  12)
93
94;;(define ap-for-1H-thrown-attack 12)
95;;(define ap-for-2H-thrown-attack 18)
96
97;;(define ap-for-shooting-attack  12)
98
99;;(define ap-for-combat-spell      9)
100;;(define ap-to-use-scroll        12)
101
102
103;; Difficulty Classes
104(define dc-escape-ensnare  26)
105(define dc-escape-paralyze 16)
106
107;; Pmasks (keep them around until mechs are converted to use passability
108;; classes (see below))
109(define pmask-none   0)
110(define pmask-solid  1)
111(define pmask-land   2)
112(define pmask-water  4)
113(define pmask-shoals 8)
114(define pmask-bridge (+ pmask-land pmask-water pmask-shoals))
115(define pmask-all    (+ pmask-solid pmask-land pmask-water pmask-shoals))
116
117;; Passability Difficulty Levels
118;;   (Note: 255 is well-known to the kernel to mean
119;;   "impassible" in the case of movement costs)
120(define fast        (* 0.66 base-move-ap))  ;; 0.66 (2/3)
121(define s-fast      (* 0.8 base-move-ap))  ;; 'slightly fast' 0.8
122(define norm        base-move-ap)  ;; 1.0
123(define s-hard      (* 1.5 base-move-ap))  ;; 1.5
124(define hard       (* 2 base-move-ap))  ;; 2.0
125(define v-hard     (* 3 base-move-ap))  ;; 3.0
126
127(define no-drop    100)  ;; special, used for dropability (not related to speed-human)
128(define cant      255)  ;; special
129
130;(define norm       50)  ;; 1.0
131;(define s-hard     75)  ;; 1.5
132;(define hard      100)  ;; 2.0
133;(define v-hard    150)  ;; 3.0
134;(define fast       30)  ;; 0.6
135;(define s-fast     40)  ;; 0.4
136;(define no-drop   100)  ;; 2.0
137;(define cant      255)  ;;
138
139
140;; Passability classes
141(define pclass-none          0)
142(define pclass-grass         1)
143(define pclass-deep          2)
144(define pclass-shoals        3)
145(define pclass-mountains     4) ;; no ceiling
146(define pclass-wall          5) ;; has a ceiling
147(define pclass-trees         6)
148(define pclass-forest        7)
149(define pclass-hills         8)
150(define pclass-repel         9) ;; energy shield blocks all
151(define pclass-space         10)
152(define pclass-bridge        pclass-grass)
153(define pclass-road          pclass-grass)
154(define pclass-boulder       11) ;; no ceiling, smaller than mountain
155(define pclass-waterboulder  12) ;; worst case of boulder and water
156(define pclass-sludge        13)
157(define pclass-shallows      14)
158(define pclass-bars          15) ;; portcullis
159(define pclass-window        16) ;; separating from bars for shoot-but-not-crawl-through passability
160(define pclass-vmountains    17)
161(define pclass-canfloat      18) ;; avoids drowning
162(define pclass-canfly        19) ;; avoids ground based issues
163
164;; Movement modes
165(define mmodes
166  (list
167   (list 'mmode-walk      "walking"     0)
168   (list 'mmode-hover     "hovering"    1)
169   (list 'mmode-ship      "sailing"     2)
170   (list 'mmode-phase     "phasing"     3)
171   (list 'mmode-fly       "flying"      4)
172   (list 'mmode-skiff     "rowing"      5)
173   (list 'mmode-fish      "swimming"    6)
174   (list 'mmode-crawl     "crawling"    7) ;; spiders, can cross boulders
175   (list 'mmode-voidship  "sailing"     8)
176   (list 'mmode-ranger    "stalking"    9)
177   (list 'mmode-none      "stationary" 10)
178   (list 'mmode-wriggle   "wriggle"    11) ;; rogue special move
179   (list 'mmode-missile   "missile"    12)
180   (list 'mmode-fastfly   "flying"     13)
181   (list 'mmode-fastrun   "running"    14)
182   (list 'mmode-fastcrawl "crawling"   15)
183   (list 'mmode-smallobj  "smallobj"   16) ;; for determining dropability of small objects
184   (list 'mmode-largeobj  "largeobj"   17) ;; for determining dropability of big objects- basically, stuff that wont fit through bars/windows
185   (list 'mmode-field     "field"      18) ;; for determining dropability of fields
186   (list 'mmode-return    "return"     19) ;; return path for magic axe (for now assume it always returns)
187   (list 'mmode-cannon    "crawling"   20) ;; enhanced missile passibility for cannon shells
188   (list 'mmode-large     "striding"   21) ;; big critters
189))
190(map (lambda (mmode) (apply kern-mk-mmode mmode)) mmodes)
191
192(define mmode-jump mmode-fly)
193
194;; Movement cost table (optimized for cut to/paste from spreadsheet!)
195(kern-mk-ptable
196	;;	walk	hover	ship	phase	fly	skiff	fish	crawl	vship	rangr	none	wrigl	missl	f_fly	f_run	f_crawl	sml_obj	lrg_obj	fields	return	cannon	striding
197	(list	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	)	;; none
198	(list	norm	norm	cant	norm	norm	cant	cant	norm	cant	norm	cant	norm	0	fast	fast	fast	norm	norm	norm	0	0	norm	)	;; grass/paving
199	(list	cant	cant	s-fast	cant	norm	v-hard	norm	cant	cant	cant	cant	cant	0	fast	cant	cant	cant	cant	no-drop	0	0	cant	)	;; deep
200	(list	cant	s-hard	cant	cant	norm	norm	norm	cant	cant	cant	cant	cant	0	fast	cant	cant	cant	cant	no-drop	0	0	s-hard	)	;; shoals
201	(list	cant	cant	cant	cant	s-hard	cant	cant	cant	cant	cant	cant	cant	95	s-fast	cant	cant	no-drop	no-drop	cant	0	90	cant	)	;; mountains
202	(list	cant	cant	cant	s-hard	cant	cant	cant	cant	cant	cant	cant	cant	100	cant	cant	cant	cant	cant	cant	0	100	cant	)	;; wall (w/ ceiling)
203	(list	hard	hard	cant	norm	norm	cant	cant	hard	cant	norm	cant	hard	10	fast	norm	norm	norm	norm	norm	0	7	hard	)	;; trees
204	(list	v-hard	v-hard	cant	norm	norm	cant	cant	v-hard	cant	s-hard	cant	v-hard	30	fast	hard	hard	norm	norm	norm	0	20	v-hard	)	;; forest
205	(list	v-hard	hard	cant	norm	norm	cant	cant	v-hard	cant	s-hard	cant	v-hard	7	fast	hard	hard	norm	norm	norm	0	5	hard	)	;; hills/bog
206	(list	cant	cant	cant	cant	cant	cant	cant	cant	cant	cant	cant	cant	100	cant	cant	cant	no-drop	no-drop	norm	0	100	cant	)	;; energy fields
207	(list	cant	cant	cant	cant	norm	cant	cant	cant	norm	cant	cant	cant	0	fast	cant	cant	cant	cant	no-drop	0	0	cant	)	;; space
208	(list	cant	norm	cant	norm	norm	cant	cant	hard	cant	cant	cant	hard	10	fast	cant	norm	norm	norm	norm	0	4	norm	)	;; boulder
209	(list	cant	hard	cant	cant	norm	cant	cant	hard	cant	cant	cant	hard	10	fast	cant	norm	norm	norm	no-drop	0	4	hard	)	;; waterboulder
210	(list	cant	norm	hard	cant	norm	v-hard	v-hard	cant	cant	cant	cant	cant	0	fast	cant	cant	cant	cant	no-drop	0	0	norm	)	;; sludge
211	(list	s-hard	norm	cant	norm	norm	norm	norm	s-hard	cant	norm	cant	cant	0	fast	norm	norm	cant	cant	no-drop	0	0	norm	)	;; shallow sludge
212	(list	cant	cant	cant	s-hard	cant	cant	cant	cant	cant	cant	cant	v-hard	7	cant	cant	cant	norm	no-drop	norm	0	7	cant	)	;; bars (eg portcullis)
213	(list	cant	cant	cant	s-hard	cant	cant	cant	cant	cant	cant	cant	cant	30	cant	cant	cant	no-drop	no-drop	no-drop	0	25	cant	)	;; window
214	(list	cant	cant	cant	cant	s-hard	cant	cant	cant	cant	cant	cant	cant	30	s-fast	cant	cant	no-drop	no-drop	no-drop	0	10	cant	)	;; passlos mountains
215	(list	cant	v-hard	s-fast	cant	norm	cant	norm	cant	cant	cant	cant	cant	norm	norm	cant	cant	cant	cant	norm	norm	norm	v-hard	)	;; float
216	(list	cant	hard	cant	cant	norm	hard	cant	cant	norm	cant	cant	cant	norm	norm	cant	cant	cant	cant	norm	norm	norm	cant	)	;; fly
217)
218;; Note that pclass 'missl' is using the value as a percentage chance
219;; for a missile to be blocked by obscuring terrain, not as an AP cost
220
221
222;; Factions. The diplomacy table (which defines the relationship between
223;; factions) must be defined in the session file, because it changes over time.
224(define faction-none          0)
225(define faction-player        1)
226(define faction-men           2)
227(define faction-cave-goblin   3)
228(define faction-accursed      4)
229(define faction-monster       5)
230(define faction-troll         6)
231(define faction-spider        7)
232(define faction-outlaw        8)
233(define faction-gint          9)
234(define faction-demon         10)
235(define faction-forest-goblin 11)
236(define faction-num           12)
237(define faction-green-tower   faction-men)
238(define faction-glasdrin      faction-men)
239(define faction-oparine       faction-men)
240(define faction-trigrave      faction-men)
241(define faction-nixie         faction-monster)
242(define faction-prisoner      13)
243
244;; Layers (must match object.h)
245(define layer-none       0)
246(define layer-tfeat      1)
247(define layer-mechanism  2)
248(define layer-portal     3)
249(define layer-vehicle    4)
250(define layer-bed        5)
251(define layer-container  6)
252(define layer-item       7)
253(define layer-field      8)
254(define layer-being      9)
255(define layer-projectile 10)
256(define layer-crosshair  11)
257
258;; Contexts
259(define context-world 1)
260(define context-town  2)
261(define context-any      (+ context-town context-world))
262
263;; Damage/Immunity types (ordinal, not bitmasks)
264(define damage-none   0)
265(define damage-fire   1)
266(define damage-poison 2)
267(define damage-sleep  3)
268
269;; Damage amounts
270(define lava-damage 10)
271
272;; Directions (as returned by kern-ui-get-direction)
273(define northwest 0)
274(define north     1)
275(define northeast 2)
276(define west      3)
277(define here      4)
278(define east      5)
279(define southwest 6)
280(define south     7)
281(define southeast 8)
282(define up        9)
283(define down      10)
284
285(define opposite-dir (vector southeast south southwest
286                             east here west
287                             northeast north northwest
288                             down up))
289
290;; Player character bonuses
291(define pc-hp-off  25)
292(define pc-hp-gain 5)
293(define pc-mp-off  1)
294(define pc-mp-gain 1)
295
296;; NPC activities
297(define (isdrunk? knpc)
298  (string=? "drunk" (kern-obj-get-activity knpc)))
299(define (isworking? knpc)
300  (string=? "working" (kern-obj-get-activity knpc)))
301
302;; Prices
303(define base-scroll-cost 20) ;; gold pieces per level of scroll's spell
304(define reagent-price-mult 1) ;; global reagent price multiplier
305
306;; rather than trying to calculate appropriate hp/mp for
307;; characters, stick in a big number and let Character::new
308;; trim it as needed
309(define max-health 999999999)
310
311;; Some of the following are order-dependent
312(load "loc.scm")
313(load "kobj.scm")
314(load "ifc.scm")
315(load "sprite-sets.scm")
316(load "sprites.scm")
317
318(define s_altar (mk-composite-sprite (list s_grass s_altar_obj)))
319(define s_active_altar (mk-composite-sprite (list s_grass s_active_altar_obj)))
320(define s_overgrown_altar (mk-composite-sprite (list s_trees s_altar_obj)))
321
322(load "sounds.scm")
323(load "effects.scm")
324(load "terrains.scm")
325(load "fields.scm")
326;;(load "combat-maps.scm")
327
328;; Object types
329(load "objs.scm")
330;;(load "traps.scm")
331;;(load "pitfalls.scm")
332;;(load "landslide.scm")
333(load "containers.scm")
334(load "reagents.scm")
335(load "food.scm")
336(load "arms.scm")
337(load "powers.scm")
338(load "ability.scm")
339(load "cast-ui.scm")
340(load "spells.scm")
341(load "items.scm")
342;;(load "vehicles.scm")
343;;(load "beds.scm")
344(load "money.scm")
345(load "skills.scm")
346(load "occs.scm")
347(load "ai.scm")
348(load "species.scm")
349(load "conv.scm") ;; basic conversation
350(load "npc-types.scm")
351(load "spider.scm")
352;;(load "mimic.scm")
353;;(load "parties.scm")
354;;(load "jewelry.scm")
355(load "gate-guard.scm")
356
357;; Mechanism-like things
358(load "bim.scm")
359(load "step.scm")
360(load "monster-generator.scm")
361;;(load "wilderness-manager.scm")
362(load "terrain-to-ptype.scm")
363;;(load "edge-spawn.scm")
364;;(load "door.scm")
365;;(load "portcullis.scm")
366(load "hidden.scm")
367;;(load "lever.scm")
368(load "timer.scm")
369;;(load "tblit.scm")
370(load "portals.scm")
371(load "moongate.scm")
372;;(load "bridge.scm")
373;;(load "drawbridge.scm")
374;;(load "weather-vane.scm")
375;;(load "wind-bridge.scm")
376
377;; Astronomy
378(load "moon.scm")
379
380;; Miscellaneous crap
381(mk-obj-type 't_crosshair "crosshair" s_crosshair layer-crosshair nil)
382(kern-set-crosshair t_crosshair)
383(kern-set-frame s_frame_ulc
384                s_frame_urc
385                s_frame_llc
386                s_frame_lrc
387                s_frame_td
388                s_frame_tu
389                s_frame_tl
390                s_frame_tr
391                s_null
392                s_frame_horz
393                s_frame_vert
394                s_frame_endl
395                s_frame_endr)
396(kern-set-ascii ss_u4_charset 32)
397(kern-set-cursor ls_whirlpool)
398(kern-set-damage-sprite s_hit)
399(kern-add-query 'str_based_attack_query proc-stratt)
400(kern-add-query 'dex_based_attack_query proc-dexatt)
401(kern-add-query 'damage_bonus_query proc-stratt)
402(kern-add-query 'defense_bonus_query proc-dexdef)
403
404;; Setup the global effect sprites
405(kern-set-quicken-sprite s_quicken)
406(kern-set-time-stop-sprite s_time_stop)
407(kern-set-magic-negated-sprite s_magic_negated)
408(kern-set-reveal-sprite s_reveal)
409(kern-set-xray-vision-sprite s_xray_vision)
410
411(kern-init-random)
412
413(kern-progress-bar-finish)
414
415;; end clone of game.scm------------------------------------------------------
416
417
418
419(kern-load "runes.scm")
420
421(define logo-image (kern-image-load "haximatext.png"))
422(define yoff 7)
423(define xoff -3)
424
425;;----------------------------------------------------------------------------
426;; Time -- this needs to be set before loading any dungeon rooms
427;;----------------------------------------------------------------------------
428(define hour 12)
429(define minutes 00)
430(define time-in-minutes (+ (* hour 60) minutes))
431(define game-start-time (time-mk 0 0 0 0 hour minutes))
432
433(kern-set-clock
434 0 ; year
435 0 ; month
436 0 ; week
437 0 ; day
438 hour  ; hour
439 minutes ; minutes
440 )
441
442;;----------------------------------------------------------------------------
443;; Gate Traveler
444;;----------------------------------------------------------------------------
445
446(define flee-gate (list #f))
447
448(define (traveler-goto-dest kchar dest)
449  (let (
450         (loc (kern-obj-get-location kchar))
451         )
452    (if (equal? loc dest)
453        (begin
454          (kern-obj-remove kchar)
455          (kern-map-repaint)
456          #t)
457        (begin
458          (pathfind kchar dest)))))
459
460(define (traveler-dest kchar)
461	(let ((loc (kern-obj-get-location kchar)))
462		(if (car flee-gate)
463			(loc-mk (loc-place loc) (+ xoff 20) (+ yoff  5))
464			(cons
465				(loc-place loc)
466				(npcg-get-post (gob kchar))
467			))
468	))
469
470(define (wizard-traveler-ai kchar)
471  (or (spell-sword-ai kchar)
472      (traveler-goto-dest kchar (traveler-dest kchar))))
473
474(define (normal-traveler-ai kchar)
475  (or (std-ai kchar)
476      (if (any-visible-hostiles? kchar)
477          #f
478          (traveler-goto-dest kchar (traveler-dest kchar)))))
479
480;; these detect who kchar is friendly/hostile to, not vice-versa
481(define (all-demons-near kchar)
482  (filter (lambda (kobj) (eqv? (kern-char-get-species kobj) sp_demon))
483          (kern-place-get-beings (loc-place (kern-obj-get-location kchar)))))
484
485(define (all-allies-near kchar)
486  (filter (lambda (kobj) (eqv? (kern-char-get-species kobj) sp_human))
487          (kern-place-get-beings (loc-place (kern-obj-get-location kchar)))))
488
489(define (wizard-defender-ai kchar)
490  (or (spell-sword-ai kchar)
491  		(if (and (null? (all-demons-near kchar)) (> (kern-dice-roll "1d3") 2))
492  			(if (> (kern-dice-roll "1d3") 2)
493     			(traveler-goto-dest kchar (traveler-dest kchar))
494     			#t
495     		)
496     		#f)))
497
498(define (normal-defender-ai kchar)
499  (or (std-ai kchar)
500      (if (and (null? (all-demons-near kchar)) (> (kern-dice-roll "1d3") 2))
501      	(if (> (kern-dice-roll "1d3") 2)
502          	(traveler-goto-dest kchar (traveler-dest kchar))
503          	(begin
504          		(kern-obj-dec-ap kchar base-move-ap)
505          		#t
506          	)
507          )
508          #f)))
509
510(define (traveler-exit kchar)
511  (let* ((loc (kern-obj-get-location kchar))
512         (dest (loc-mk (loc-place loc) (+ xoff 20) (+ yoff  5)))
513       )
514    (traveler-goto-dest kchar dest)
515  ))
516
517(define (seek-loot kchar)
518  (let ((loot-list
519         (filter (mk-ifc-query 'get)
520                 (kern-place-get-objects (loc-place (kern-obj-get-location kchar))))
521         ))
522    (if (not (null? loot-list))
523        (let* ((targetloot (nearest-obj kchar loot-list)))
524          (if (< (kern-get-distance (kern-obj-get-location kchar) (kern-obj-get-location targetloot)) 2)
525              (begin
526                (kern-obj-remove targetloot)
527                (kern-map-repaint)
528                #t
529                )
530              (pathfind kchar (kern-obj-get-location targetloot))
531              ))
532        #f
533        )
534    ))
535
536(define (beggar-exit kchar)
537  (or (seek-loot kchar)
538      (traveler-exit kchar))
539    )
540
541(define (erratic-traveler-ai kchar)
542  (or (std-ai kchar)
543     (if (> (kern-dice-roll "1d5") 1)
544	   	(if (> (kern-dice-roll "1d3") 1)
545	       	(traveler-goto-dest kchar (traveler-dest kchar))
546	       	(begin
547          		(kern-obj-dec-ap kchar base-move-ap)
548		       	#t
549	       	)
550       )
551       #f)))
552
553(define (traveler-mk kplace)
554  (let* ((wizard-sprites (list s_black_mage s_old_mage s_plain_mage s_cloaked_female s_companion_wizard s_red_wizard s_lady s_silas s_companion_druid))
555         (warrior-sprites (list s_avatar s_wanderer s_companion_fighter s_companion_paladin s_brigand))
556         (wrogue-sprites (list s_companion_bard s_companion_tinker s_companion_ranger s_ranger s_brigandess s_old_ranger))
557         (info (random-select (list (list 'wizard 'wizard-traveler-ai wizard-sprites)
558                                    (list 'paladin 'normal-traveler-ai warrior-sprites)
559                                    (list 'tinker 'normal-traveler-ai wrogue-sprites)
560                                    (list 'ranger 'normal-traveler-ai wrogue-sprites)
561                                    )))
562         (path (random-select (list
563                               (list (loc-mk kplace (+ xoff 20) (+ yoff  4)) (list  (+ xoff 9) (+ yoff  5)) #f)
564                               (list (loc-mk kplace (+ xoff 20) (+ yoff  5)) (list  (+ xoff 9) (+ yoff  5)) #f)
565                               (list (loc-mk kplace (+ xoff 20) (+ yoff  6)) (list  (+ xoff 9) (+ yoff  5)) #f)
566
567                               (list (loc-mk kplace (+ xoff 10) (+ yoff  4)) (list  (+ xoff 20)(+ yoff  4)) #t)
568                               (list (loc-mk kplace (+ xoff 10) (+ yoff  5)) (list  (+ xoff 20)(+ yoff  5)) #t)
569                               (list (loc-mk kplace (+ xoff 10) (+ yoff  6)) (list  (+ xoff 20)(+ yoff  6)) #t)
570                               )))
571         (kchar (mk-npc (car info) 9))
572         )
573    (npcg-set-post! (gob kchar) (cadr path))
574    (kern-char-set-ai kchar (cadr info) kchar)
575    (kern-obj-set-sprite kchar (random-select (caddr info)))
576    (kern-obj-put-at kchar (car path))
577    (kern-map-repaint)
578    (kern-sleep 20)
579    kchar))
580
581(define (defender-mk ctype aitype kplace postx posty)
582	(let ((kchar (mk-npc ctype 9)))
583		(npcg-set-post! (gob kchar) (list postx posty))
584	   (kern-char-set-ai kchar aitype)
585   	(kern-obj-put-at kchar (loc-mk kplace postx posty))
586   	(kern-map-repaint)
587      (kern-sleep 20)
588   	kchar
589	))
590
591;;----------------------------------------------------------------------------
592;; Wise
593;;----------------------------------------------------------------------------
594(define (wait-ai kchar)
595  #t)
596
597(define (wise-enter-ai kchar)
598  (let* ((wise (gob kchar))
599         (loc (kern-obj-get-location kchar))
600         (dest (cons (loc-place loc) (npcg-get-post wise)))
601         )
602    (if (equal? loc dest)
603        (let ((kmgr (car (npcg-get-subgob wise))))
604          ;; Tell the mgr this one is in position and switch it over to waiting
605          ;; mode.
606          (scene-mgr-incr-num-wise-in-pos! (gob kmgr))
607          (kern-char-set-ai kchar 'wait-ai)
608          #t)
609        (pathfind kchar dest))))
610
611(define (wise-exit-ai kchar)
612  (let* ((wise (gob kchar))
613         (loc (kern-obj-get-location kchar))
614         (dest (cons (loc-place loc)
615                     (npcg-get-post wise)))
616         )
617    (if (equal? loc dest)
618        (let ((kmgr (car (npcg-get-subgob wise))))
619          (kern-obj-remove kchar)
620          (kern-map-repaint)
621          (scene-mgr-incr-num-wise-in-pos! (gob kmgr))
622          #t)
623        (begin
624          (pathfind kchar dest)))))
625
626(define (wise-mk kplace n kmgr)
627  (let* ((kchar (mk-npc 'wizard 9))
628         (info (list-ref (list
629                         (list (list (+ xoff 20) (+ yoff 4)) (list  3 11) s_black_mage)
630                         (list (list (+ xoff 20) (+ yoff 5)) (list  3 13) s_old_mage)
631                         (list (list (+ xoff 20) (+ yoff 6)) (list  5  9) s_plain_mage)
632                         (list (list (+ xoff 20) (+ yoff 4)) (list  5 15) s_cloaked_female)
633                         (list (list (+ xoff 20) (+ yoff 5)) (list  7 15) s_companion_wizard)
634                         (list (list (+ xoff 20) (+ yoff 6)) (list  7  9) s_red_wizard)
635                         (list (list (+ xoff 20) (+ yoff 4)) (list  9 11) s_lady)
636                         (list (list (+ xoff 20) (+ yoff 5)) (list  9 13) s_silas)
637                              )
638                        n))
639         (enter-pos (cons kplace (car info)))
640         (altar-pos (cadr info))
641        )
642    (kern-char-set-ai kchar 'wise-enter-ai)
643    (npcg-set-post! (gob kchar) altar-pos)
644
645    ;; Save the kmgr object in the gob so the wise can notify it when they are
646    ;; in position. Also remember the entrance position so they can pathfind
647    ;; back.
648    (npcg-set-subgob! (gob kchar) (cons kmgr (car info)))
649    (kern-obj-set-sprite kchar (caddr info))
650    (kern-obj-put-at kchar enter-pos)
651    (kern-map-repaint)
652    (kern-sleep 20)
653    kchar))
654
655;;----------------------------------------------------------------------------
656;; Special Object Types
657;;----------------------------------------------------------------------------
658(define portal-ifc
659  (ifc '()
660       (method 'step (lambda (kportal kobj)
661                       ;;(println "portal-step")
662                       ;;(kern-map-flash 100)
663                       (kern-obj-remove kobj)
664                       ))
665       ))
666(mk-obj-type 't_portal "Portal" s_blackgate_full layer-mechanism portal-ifc)
667
668;;----------------------------------------------------------------------------
669;; Scene Manager
670;;----------------------------------------------------------------------------
671(define (scene-mgr-mk) (list 'scene-mgr 0 0 0 '() 0 0))
672(define (scene-mgr-state gob) (list-ref gob 1))
673(define (scene-mgr-set-state! gob val) (set-car! (list-tail gob 1) val))
674(define (scene-mgr-advance-state! gob)
675  (set-car! (list-tail gob 1) (+ 1 (scene-mgr-state gob)))
676  (scene-mgr-set-pause! gob 0)
677  )
678(define (scene-mgr-get-num-demons gob) (list-ref gob 2))
679(define (scene-mgr-set-num-demons! gob val) (set-car! (list-tail gob 2) val))
680(define (scene-mgr-incr-num-demons! gob) (set-car! (list-tail gob 2) (+ 1 (scene-mgr-get-num-demons gob))))
681(define (scene-mgr-get-num-travelers gob) (list-ref gob 3))
682(define (scene-mgr-set-num-travelers! gob val) (set-car! (list-tail gob 3) val))
683(define (scene-mgr-incr-num-travelers! gob) (set-car! (list-tail gob 3) (+ 1 (scene-mgr-get-num-travelers gob))))
684
685(define (scene-mgr-get-wise gob) (list-ref gob 4))
686(define (scene-mgr-get-num-wise gob) (length (scene-mgr-get-wise gob)))
687(define (scene-mgr-add-wise! gob kwise) (set-car! (list-tail gob 4) (cons kwise (scene-mgr-get-wise gob))))
688
689(define (scene-mgr-get-num-wise-in-pos gob) (list-ref gob 5))
690(define (scene-mgr-set-num-wise-in-pos! gob val) (set-car! (list-tail gob 5) val))
691(define (scene-mgr-incr-num-wise-in-pos! gob) (set-car! (list-tail gob 5) (+ 1 (scene-mgr-get-num-wise-in-pos gob))))
692(define (scene-mgr-get-pause gob) (list-ref gob 6))
693(define (scene-mgr-set-pause! gob val) (set-car! (list-tail gob 6) val))
694(define (scene-mgr-incr-pause! gob) (set-car! (list-tail gob 6) (+ 1 (scene-mgr-get-pause gob))))
695
696(define (scene-mgr-intro-travelers-phase kobj)
697  ;;(println "scene-mgr-intro-travelers-phase")
698  (let* ((smgr (kobj-gob-data kobj))
699         (n (scene-mgr-get-num-travelers smgr))
700         )
701    (define (put-traveler)
702      ;;(println "put-traveler")
703      (traveler-mk (loc-place (kern-obj-get-location kobj)))
704      (scene-mgr-incr-num-travelers! smgr)
705      )
706    (cond ((< n 10)
707           (if (> (kern-dice-roll "1d10") 9)
708               (put-traveler)))
709          (else
710           (if (> (kern-dice-roll "1d5") 4)
711           (scene-mgr-advance-state! smgr))))
712    ))
713
714(define (scene-mgr-intro-demons-phase kobj)
715  ;;(println "scene-mgr-intro-demons-phase")
716  (let* ((smgr (kobj-gob-data kobj))
717         (n (scene-mgr-get-num-demons smgr))
718         )
719    (define (put-demon dir)
720      (let ((kdemon (mk-npc 'demon 9)))
721        (kern-char-set-ai kdemon 'std-ai)
722        ;;(kern-map-flash 1000)
723        (kern-obj-put-at kdemon
724                         (loc-offset (mk-loc (loc-place (kern-obj-get-location kobj)) (+ xoff 9)  (+ yoff 5))
725                                     dir)))
726
727      (scene-mgr-incr-num-demons! smgr)
728              (kern-map-repaint)
729  		  (kern-sleep 20)
730      )
731    (cond ((= n 0)
732    			(set-car! flee-gate #t)
733           (kern-add-reveal 1000)
734           (put-demon west))
735          ((= n 1) (put-demon east))
736          ((= n 2) (put-demon south))
737          ((= n 3) (put-demon north))
738          ((= n 4) ;; second wave
739          	(if (> (kern-dice-roll "1d7") 6)
740          		(put-demon west)
741          	)
742          )
743          ((= n 5) (put-demon east))
744          ((= n 6) (put-demon south))
745          ((= n 7) (put-demon north))
746          (else
747           (scene-mgr-advance-state! smgr)))
748    ))
749
750(define (scene-mgr-wait-for-no-demons-phase kobj)
751  (if (null? (all-demons-near (kern-get-player)))
752  			(if (> (kern-dice-roll "1d7") 6)
753      		(scene-mgr-advance-state! (gob kobj)))
754			(if (< (length (all-allies-near (kern-get-player))) 3)
755				(let ((kplace (loc-place (kern-obj-get-location kobj))))
756					(defender-mk 'ranger 'normal-defender-ai kplace (+ xoff 20) (+ yoff  5))
757					(defender-mk 'paladin 'normal-defender-ai kplace (+ xoff 20) (+ yoff  6))
758					(if (> (kern-dice-roll "1d4") 3)
759						(defender-mk 'wizard 'wizard-defender-ai kplace (+ xoff 20) (+ yoff  4))
760						(defender-mk 'paladin 'normal-defender-ai kplace (+ xoff 20) (+ yoff  4))
761					)
762				))
763      ))
764
765(define (scene-mgr-intro-wise kobj)
766  ;;(println "scene-mgr-intro-wise")
767  (let* ((smgr (kobj-gob-data kobj))
768         (n (scene-mgr-get-num-wise smgr))
769         )
770    (cond ((< n 8)
771    			(if (or (> n 6) (> (kern-dice-roll "1d4") 3))
772           (scene-mgr-add-wise! smgr (wise-mk (loc-place (kern-obj-get-location kobj)) n kobj))
773           ))
774          (else
775           (scene-mgr-advance-state! smgr)))
776    )
777  )
778
779(define (scene-mgr-wait-for-wise kobj)
780  ;;(println "scene-mgr-wait-for-wise")
781  (let ((smgr (gob kobj)))
782    (if (= 8 (scene-mgr-get-num-wise-in-pos smgr))
783      (scene-mgr-advance-state! smgr))))
784
785(define (scene-mgr-close-gate kobj)
786  ;;(println "scene-mgr-close-gate")
787
788  (define (drop-rune krune loc)
789    (kern-obj-put-at krune loc)
790    (kern-place-set-terrain loc t_active_altar)
791    )
792
793  (define (drop-all-runes)
794    (let ((kplace (loc-place (kern-obj-get-location kobj))))
795      (drop-rune (kern-tag 'rune_k (kern-mk-obj t_rune_k 1)) (loc-mk kplace  4   8))
796      (drop-rune (kern-tag 'rune_p (kern-mk-obj t_rune_p 1)) (loc-mk kplace  8   8))
797      (drop-rune (kern-tag 'rune_s (kern-mk-obj t_rune_s 1)) (loc-mk kplace 10  10))
798      (drop-rune (kern-tag 'rune_c (kern-mk-obj t_rune_c 1)) (loc-mk kplace 10  14))
799      (drop-rune (kern-tag 'rune_f (kern-mk-obj t_rune_f 1)) (loc-mk kplace  8  16))
800      (drop-rune (kern-tag 'rune_w (kern-mk-obj t_rune_w 1)) (loc-mk kplace  4  16))
801      (drop-rune (kern-tag 'rune_d (kern-mk-obj t_rune_d 1)) (loc-mk kplace  2  14))
802      (drop-rune (kern-tag 'rune_l (kern-mk-obj t_rune_l 1)) (loc-mk kplace  2  10))
803      )
804    (kern-map-repaint)
805    )
806
807  (define (close-portal)
808    (map (lambda (stage)
809           ;; The last sprite in the sequence is null, and if we set the portal's
810           ;; sprite to null it will fall back on the sprite of its object type,
811           ;; which is a fully-open gate, so catch that as a special case.
812           (cond ((not (null? (stage-sprite stage)))
813                  (kern-obj-set-sprite portal (stage-sprite stage))
814                  (kern-obj-set-light portal (stage-light stage))
815                  (kern-map-repaint)
816                  (kern-sleep 125))))
817         (reverse blackgate-stages))
818    (kern-obj-remove portal)
819    (kern-map-repaint)
820    )
821
822  (kern-log-msg "VAS AN EX REL POR!")
823  ;; we need a better rumbling thunder/ earthquake type noise
824  (kern-sound-play sound-lightning)
825  (shake-map 15)
826  (kern-map-flash 1000)
827  (drop-all-runes)
828  (close-portal)
829
830  (scene-mgr-advance-state! (gob kobj))
831  )
832
833(define (scene-mgr-pause kobj delay)
834  ;; Keep the sprites animating during pauses.
835  (kern-map-repaint)
836  (let ((smgr (gob kobj)))
837    (if (>= (scene-mgr-get-pause smgr) delay)
838        (scene-mgr-advance-state! (gob kobj))
839        (scene-mgr-incr-pause! smgr))))
840
841(define (scene-mgr-pickup-runes kobj)
842  ;;(println "scene-mgr-pickup-runes")
843  (for-each (lambda (krune)
844              (kern-obj-remove krune)
845              (kern-map-repaint)
846              (kern-sleep 100)
847              ;; Delay changing back the altar so the player can see that it is
848              ;; the altar glowing, not the rune.
849              (kern-place-set-terrain (kern-obj-get-location krune) t_altar)
850              )
851            (list rune_s rune_w rune_p rune_d rune_f rune_k rune_c rune_l))
852  (scene-mgr-advance-state! (gob kobj))
853  )
854
855(define (scene-mgr-exit-wise kobj)
856  ;;(println "scene-mgr-exit-wise")
857  (map (lambda (kwise)
858         (let ((wise (gob kwise)))
859           ;;(println "post:" (cdr (npcg-get-subgob wise)))
860           (npcg-set-post! wise (cdr (npcg-get-subgob wise)))
861           (kern-char-set-ai kwise 'wise-exit-ai)))
862       (scene-mgr-get-wise (gob kobj)))
863  (scene-mgr-set-num-wise-in-pos! (gob kobj) 0)
864  (scene-mgr-advance-state! (gob kobj))
865  )
866
867(define (scene-mgr-exit-guards kobj)
868  ;;(println "scene-mgr-exit-guards")
869  (map (lambda (kchar)
870		(if (not (is-player-party-member? kchar))
871           (kern-char-set-ai kchar 'traveler-exit)))
872       (kern-place-get-beings (loc-place (kern-obj-get-location kobj))))
873  (scene-mgr-advance-state! (gob kobj))
874  )
875
876(define (scene-mgr-wait-for-exits kobj)
877  ;;(println "scene-mgr-wait-for-guards")
878  (if (< (length (all-allies-near (kern-get-player))) 2)
879	(scene-mgr-advance-state! (gob kobj)))
880  )
881
882(define (scene-mgr-exit-beggar kobj)
883  ;; This is a hack to keep the camera centered on the beggar's location (and
884  ;; thus the whole scene within the vision radius) while allowing the beggar
885  ;; to go pick up the loot and then exit. The party member beggar's sprite is
886  ;; changed to nil, making him invisible, then a new npc beggar is cloned.
887  (let ((kcharn (mk-npc 'ranger 9)))
888    (kern-obj-set-sprite kcharn s_beggar)
889    (kern-char-set-ai kcharn 'beggar-exit)
890    (kern-obj-put-at kcharn (kern-obj-get-location (kern-get-player)))
891   )
892  (map (lambda (kchar)
893		(if (is-player-party-member? kchar)
894           (kern-obj-set-sprite kchar nil)))
895       (kern-place-get-beings (loc-place (kern-obj-get-location kobj))))
896  (scene-mgr-advance-state! (gob kobj))
897  )
898
899(define (scene-mgr-start-days-pass kobj)
900  (kern-log-msg "Days pass...")
901  (set-car! flee-gate #f)
902  (let ((kplace (loc-place (kern-obj-get-location kobj))))
903    (define (wolf-mk from-loc to-xy)
904      (let ((kchar (mk-npc 'wolf 9)))
905        (npcg-set-post! (gob kchar) to-xy)
906        (kern-char-set-ai kchar 'erratic-traveler-ai)
907        (kern-obj-put-at kchar from-loc)
908        (kern-map-repaint)
909  		  (kern-sleep 20)
910        ))
911    (wolf-mk (loc-mk kplace 1 14) (list 17 7))
912    )
913  (kern-map-repaint)
914  (scene-mgr-advance-state! (gob kobj))
915  )
916
917(define (scene-mgr-end-days-pass kobj)
918  (if (null? (filter (lambda (kobj)
919                       (not (is-player-party-member? kobj)))
920                     (kern-place-get-beings (loc-place (kern-obj-get-location kobj)))))
921      (scene-mgr-advance-state! (gob kobj))
922      ))
923
924(define (scene-mgr-years-pass kobj)
925  (kern-log-msg "Then years...")
926  (let ((kplace (loc-place (kern-obj-get-location kobj))))
927    (define (mk-troll loc)
928      (let ((kchar (mk-npc 'troll 9)))
929        (kern-char-set-ai kchar 'wait-ai)
930        (kern-obj-put-at kchar loc)
931        ))
932    (kern-blit-map (kern-place-map kplace) 0 0
933                   (kern-mk-map
934                    nil     19 19 pal_expanded
935                    (list
936                     "000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 "
937                     "019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 "
938                     "038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 "
939                     "057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 "
940                     "076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 "
941                     "095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 "
942                     "fg fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fi "
943							"fj t. |. t. t. tc .. .. ta t. t. |. |. |. tL __ t. |. fl "
944							"fj |. t. tc ar .. .. .. ar t% t. |. t. t. _3 _c t. t. fl "
945							"fj t. tc t# .. .. .. .. .. .. ta t. t. t. _2 tG t. t. fl "
946							"fj tc ar .. .. .. bb .. .. .. ar |. t. tc _2 ta t. t. fl "
947							"fj |. .. .. bb dd dd dd .. .. .. ta tc t# ee ee dd .. fl "
948							"fj t. .. .. dd dd && dd dd .. .. dd dd ee ee dd dd dd fl "
949							"fj t. .. .. .. dd dd dd .. .. .. t7 tA ee __ ee .. dd fl "
950							"fj t. ar .. .. .. .. bb .. .. ar t. t. t5 __ t3 t. t. fl "
951							"fj t. t5 tA .. .. .. .. .. .. t3 |. t. t5 _2 tJ |. t. fl "
952							"fj t. t. t5 ar .. .. .. ar tC t. t. t. t. _a _5 t. |. fl "
953							"fj t. t. |. t5 .. t7 .. t3 |. |. t. t. t. tH __ t. |. fl "
954                     "fm fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fo "
955                     ))
956                   0 0 19 19)
957    (mk-troll (loc-mk kplace 5 12))
958    (mk-troll (loc-mk kplace 7 12))
959    )
960  (scene-mgr-advance-state! (gob kobj))
961  )
962
963(define (scene-mgr-end-years-pass kobj)
964  (println "end-years-pass")
965  (let ((trolls (filter
966                 (lambda (kobj)
967                   (not (is-player-party-member? kobj)))
968                 (kern-place-get-beings (loc-place (kern-obj-get-location kobj))))))
969    (for-each kern-obj-remove trolls))
970  (kern-map-repaint)
971  (scene-mgr-advance-state! (gob kobj))
972  )
973
974
975(define (scene-mgr-ages-pass kobj)
976  (kern-log-msg "Then ages...")
977  (let ((kplace (loc-place (kern-obj-get-location kobj))))
978    (kern-blit-map (kern-place-map kplace) 0 0
979                   (kern-mk-map
980                    nil     19 19 pal_expanded
981                    (list
982                     "000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 "
983                     "019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 "
984                     "038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 "
985                     "057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 "
986                     "076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 "
987                     "095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 "
988                     "fg fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fi "
989							"fj |. |. |. t. |. |. |. t. |. |. |. |. tc %% __ _c %% fl "
990							"fj |. t. t. ar t. |. t. at t. t. |. |. %3 _3 _c %c .. fl "
991							"fj |. t. t. t. t. t. |. t. |. t. t. t. %a _e %c tC t3 fl "
992							"fj t. at t. tc t# bb t% ta t. at t. t. .. %% .. t3 |. fl "
993							"fj |. t. t. bb .. .. .. t% ta t. |. tc tA %% .. ta |. fl "
994							"fj |. |. t. .. .. {f .. .. tD t. tB tD ta gg .. tD t. fl "
995							"fj |. t. t. tA .. .. .. tC t3 t. t. t5 t# %% .. t3 |. fl "
996							"fj t. at t. t5 tA .. bb t3 t. at t. t. .. %% .. ta |. fl "
997							"fj |. t. |. t. t. t. t. t. |. t. |. t. tA %e .. t% t. fl "
998							"fj |. |. t. at t. t. t. ar t. |. |. |. t5 .. %7 .. |. fl "
999							"fj |. |. |. t. |. |. |. t. |. |. t. |. t. .. %% .. |. fl "
1000                     "fm fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fo "
1001                     ))
1002                   0 0 19 19)
1003    (define (deer-mk from-loc to-xy)
1004      (let ((kchar (mk-npc 'wolf 9)))
1005        (npcg-set-post! (gob kchar) to-xy)
1006        (kern-obj-set-sprite kchar s_deer)
1007        (kern-char-set-ai kchar 'erratic-traveler-ai)
1008        (kern-obj-put-at kchar from-loc)
1009        (kern-map-repaint)
1010        (kern-sleep 20)
1011      )
1012      )
1013    (deer-mk (loc-mk kplace 5 7) (list 12 17))
1014    (deer-mk (loc-mk kplace 3 7) (list 13 17))
1015    )
1016  (kern-map-repaint)
1017  (scene-mgr-advance-state! (gob kobj))
1018  )
1019
1020(define (scene-mgr-ages-passed kobj)
1021  (let ((kplace (loc-place (kern-obj-get-location kobj))))
1022  )
1023  (kern-map-repaint)
1024  (scene-mgr-advance-state! (gob kobj))
1025  )
1026
1027
1028
1029(define (scene-mgr-conclude kobj)
1030  (kern-log-msg "Until what was closed and locked by magic has been forgotten.")
1031  (let ((kplace (loc-place (kern-obj-get-location kobj))))
1032    (kern-blit-map (kern-place-map kplace) 0 0
1033                   (kern-mk-map
1034                    nil     19 19 pal_expanded
1035                    (list
1036                     "000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 "
1037                     "019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 "
1038                     "038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 "
1039                     "057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 "
1040                     "076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 "
1041                     "095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 "
1042                     "fg fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fi "
1043							"fj |. |. |. t. |. |. |. t. |. t. .. %% %% %% %% %c .. fl "
1044							"fj |. |. t. at t. |. t. at t. t. tA %a %% %% %% .. t3 fl "
1045							"fj |. t. t. t. |. |. |. t. |. t. t5 tA %a %% %c tC t. fl "
1046							"fj t. at t. |. |. bb |. |. t. at t. t5 .. %% .. t3 |. fl "
1047							"fj |. t. |. bb te .. ta |. |. t. |. t. .. %% .. ta |. fl "
1048							"fj |. |. |. t5 tB {f tD t. |. |. |. ta %b gg %d tD t. fl "
1049							"fj |. t. |. |. t5 tE tb |. |. t. |. t. .. %% .. t3 |. fl "
1050							"fj t. at t. |. |. t5 bb |. t. at t. t. .. gg .. ta |. fl "
1051							"fj |. t. |. t. |. |. |. t. |. t. |. t. tA gg %5 t% t. fl "
1052							"fj |. |. t. at t. |. t. at t. |. |. |. t5 .. gg .. t. fl "
1053							"fj |. |. |. t. |. |. |. t. |. |. |. |. t. .. gg .. t. fl "
1054                     "fm fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fo "
1055                     ))
1056                   0 0 19 19)
1057    (let ((kchar (mk-npc 'giant-spider 9)))
1058      (kern-obj-put-at  kchar (loc-mk kplace 6 12))
1059      (kern-char-set-ai kchar 'wait-ai)
1060      )
1061    (kern-obj-put-at (kern-mk-obj F_web_perm 1) (loc-mk kplace 5 12))
1062    (kern-obj-put-at (kern-mk-obj F_web_perm 1) (loc-mk kplace 6 10))
1063    (kern-obj-put-at (kern-mk-obj F_web_perm 1) (loc-mk kplace 6 11))
1064    (kern-obj-put-at (kern-mk-obj F_web_perm 1) (loc-mk kplace 6 12))
1065    (kern-obj-put-at (kern-mk-obj F_web_perm 1) (loc-mk kplace 6 13))
1066    (kern-obj-put-at (kern-mk-obj F_web_perm 1) (loc-mk kplace 7 12))
1067    (kern-obj-put-at (kern-mk-obj t_corpse 1) (loc-mk kplace 7 12))
1068    )
1069  (kern-map-repaint)
1070  (scene-mgr-advance-state! (gob kobj))
1071  )
1072
1073(define (scene-mgr-exec kobj)
1074  (let* ((smgr (kobj-gob-data kobj))
1075         (state (scene-mgr-state smgr)))
1076    (cond ((= 0 state) (scene-mgr-intro-travelers-phase kobj))
1077          ((= 1 state) (scene-mgr-intro-demons-phase kobj))
1078          ((= 2 state) (scene-mgr-wait-for-no-demons-phase kobj))
1079          ((= 3 state) (scene-mgr-pause kobj 10))
1080          ((= 4 state) (scene-mgr-intro-wise kobj))
1081          ((= 5 state) (scene-mgr-wait-for-wise kobj))
1082          ((= 6 state) (scene-mgr-pause kobj 10))
1083          ((= 7 state) (scene-mgr-close-gate kobj))
1084          ((= 8 state) (scene-mgr-pause kobj 10))
1085          ((= 9 state) (scene-mgr-pickup-runes kobj))
1086          ((= 10 state) (scene-mgr-pause kobj 10))
1087          ((= 11 state) (scene-mgr-exit-wise kobj))
1088          ((= 12 state) (scene-mgr-wait-for-wise kobj))
1089          ((= 13 state) (scene-mgr-exit-guards kobj))
1090          ((= 14 state) (scene-mgr-wait-for-exits kobj))
1091          ((= 15 state) (scene-mgr-exit-beggar kobj))
1092          ((= 16 state) (scene-mgr-wait-for-exits kobj))
1093          ((= 17 state) (scene-mgr-pause kobj 10))
1094          ((= 18 state) (scene-mgr-start-days-pass kobj))
1095          ((= 19 state) (scene-mgr-pause kobj 10))
1096          ((= 20 state) (scene-mgr-end-days-pass kobj))
1097          ((= 21 state) (scene-mgr-years-pass kobj))
1098          ((= 22 state) (scene-mgr-pause kobj 20))
1099          ((= 23 state) (scene-mgr-end-years-pass kobj))
1100          ((= 24 state) (scene-mgr-ages-pass kobj))
1101          ((= 25 state) (scene-mgr-pause kobj 20))
1102          ((= 26 state) (scene-mgr-end-years-pass kobj))
1103          ((= 27 state) (scene-mgr-conclude kobj))
1104          ((= 28 state) (scene-mgr-pause kobj 20))
1105          (else
1106           (kern-end-game)
1107           )
1108          (else
1109           ))
1110    ))
1111
1112(define scene-mgr-ifc
1113  (ifc nil
1114       (method 'exec scene-mgr-exec)))
1115
1116(mk-obj-type 't_scene_mgr nil nil layer-none scene-mgr-ifc)
1117
1118(define (mk-scene-mgr)
1119  (bind (kern-obj-set-visible (kern-mk-obj t_scene_mgr 1) #f)
1120        (scene-mgr-mk)
1121        ))
1122
1123;;----------------------------------------------------------------------------
1124;; Haxima Logo & Frame Terrain
1125;;----------------------------------------------------------------------------
1126(kern-mk-sprite-set 'ss_hl 32 32 6 19 0 0  "haximatext.png")
1127(kern-mk-sprite-set 'ss_gf 32 32 3  3 0 0  "gold_frame.png")
1128
1129(kern-mk-sprite 's_hl_0 ss_hl 1 0 #f 0)
1130(kern-mk-sprite 's_hl_1 ss_hl 1 1 #f 0)
1131(kern-mk-sprite 's_hl_2 ss_hl 1 2 #f 0)
1132(kern-mk-sprite 's_hl_3 ss_hl 1 3 #f 0)
1133(kern-mk-sprite 's_hl_4 ss_hl 1 4 #f 0)
1134(kern-mk-sprite 's_hl_5 ss_hl 1 5 #f 0)
1135(kern-mk-sprite 's_hl_6 ss_hl 1 6 #f 0)
1136(kern-mk-sprite 's_hl_7 ss_hl 1 7 #f 0)
1137(kern-mk-sprite 's_hl_8 ss_hl 1 8 #f 0)
1138(kern-mk-sprite 's_hl_9 ss_hl 1 9 #f 0)
1139(kern-mk-sprite 's_hl_10 ss_hl 1 10 #f 0)
1140(kern-mk-sprite 's_hl_11 ss_hl 1 11 #f 0)
1141(kern-mk-sprite 's_hl_12 ss_hl 1 12 #f 0)
1142(kern-mk-sprite 's_hl_13 ss_hl 1 13 #f 0)
1143(kern-mk-sprite 's_hl_14 ss_hl 1 14 #f 0)
1144(kern-mk-sprite 's_hl_15 ss_hl 1 15 #f 0)
1145(kern-mk-sprite 's_hl_16 ss_hl 1 16 #f 0)
1146(kern-mk-sprite 's_hl_17 ss_hl 1 17 #f 0)
1147(kern-mk-sprite 's_hl_18 ss_hl 1 18 #f 0)
1148(kern-mk-sprite 's_hl_19 ss_hl 1 19 #f 0)
1149(kern-mk-sprite 's_hl_20 ss_hl 1 20 #f 0)
1150(kern-mk-sprite 's_hl_21 ss_hl 1 21 #f 0)
1151(kern-mk-sprite 's_hl_22 ss_hl 1 22 #f 0)
1152(kern-mk-sprite 's_hl_23 ss_hl 1 23 #f 0)
1153(kern-mk-sprite 's_hl_24 ss_hl 1 24 #f 0)
1154(kern-mk-sprite 's_hl_25 ss_hl 1 25 #f 0)
1155(kern-mk-sprite 's_hl_26 ss_hl 1 26 #f 0)
1156(kern-mk-sprite 's_hl_27 ss_hl 1 27 #f 0)
1157(kern-mk-sprite 's_hl_28 ss_hl 1 28 #f 0)
1158(kern-mk-sprite 's_hl_29 ss_hl 1 29 #f 0)
1159(kern-mk-sprite 's_hl_30 ss_hl 1 30 #f 0)
1160(kern-mk-sprite 's_hl_31 ss_hl 1 31 #f 0)
1161(kern-mk-sprite 's_hl_32 ss_hl 1 32 #f 0)
1162(kern-mk-sprite 's_hl_33 ss_hl 1 33 #f 0)
1163(kern-mk-sprite 's_hl_34 ss_hl 1 34 #f 0)
1164(kern-mk-sprite 's_hl_35 ss_hl 1 35 #f 0)
1165(kern-mk-sprite 's_hl_36 ss_hl 1 36 #f 0)
1166(kern-mk-sprite 's_hl_37 ss_hl 1 37 #f 0)
1167(kern-mk-sprite 's_hl_38 ss_hl 1 38 #f 0)
1168(kern-mk-sprite 's_hl_39 ss_hl 1 39 #f 0)
1169(kern-mk-sprite 's_hl_40 ss_hl 1 40 #f 0)
1170(kern-mk-sprite 's_hl_41 ss_hl 1 41 #f 0)
1171(kern-mk-sprite 's_hl_42 ss_hl 1 42 #f 0)
1172(kern-mk-sprite 's_hl_43 ss_hl 1 43 #f 0)
1173(kern-mk-sprite 's_hl_44 ss_hl 1 44 #f 0)
1174(kern-mk-sprite 's_hl_45 ss_hl 1 45 #f 0)
1175(kern-mk-sprite 's_hl_46 ss_hl 1 46 #f 0)
1176(kern-mk-sprite 's_hl_47 ss_hl 1 47 #f 0)
1177(kern-mk-sprite 's_hl_48 ss_hl 1 48 #f 0)
1178(kern-mk-sprite 's_hl_49 ss_hl 1 49 #f 0)
1179(kern-mk-sprite 's_hl_50 ss_hl 1 50 #f 0)
1180(kern-mk-sprite 's_hl_51 ss_hl 1 51 #f 0)
1181(kern-mk-sprite 's_hl_52 ss_hl 1 52 #f 0)
1182(kern-mk-sprite 's_hl_53 ss_hl 1 53 #f 0)
1183(kern-mk-sprite 's_hl_54 ss_hl 1 54 #f 0)
1184(kern-mk-sprite 's_hl_55 ss_hl 1 55 #f 0)
1185(kern-mk-sprite 's_hl_56 ss_hl 1 56 #f 0)
1186(kern-mk-sprite 's_hl_57 ss_hl 1 57 #f 0)
1187(kern-mk-sprite 's_hl_58 ss_hl 1 58 #f 0)
1188(kern-mk-sprite 's_hl_59 ss_hl 1 59 #f 0)
1189(kern-mk-sprite 's_hl_60 ss_hl 1 60 #f 0)
1190(kern-mk-sprite 's_hl_61 ss_hl 1 61 #f 0)
1191(kern-mk-sprite 's_hl_62 ss_hl 1 62 #f 0)
1192(kern-mk-sprite 's_hl_63 ss_hl 1 63 #f 0)
1193(kern-mk-sprite 's_hl_64 ss_hl 1 64 #f 0)
1194(kern-mk-sprite 's_hl_65 ss_hl 1 65 #f 0)
1195(kern-mk-sprite 's_hl_66 ss_hl 1 66 #f 0)
1196(kern-mk-sprite 's_hl_67 ss_hl 1 67 #f 0)
1197(kern-mk-sprite 's_hl_68 ss_hl 1 68 #f 0)
1198(kern-mk-sprite 's_hl_69 ss_hl 1 69 #f 0)
1199(kern-mk-sprite 's_hl_70 ss_hl 1 70 #f 0)
1200(kern-mk-sprite 's_hl_71 ss_hl 1 71 #f 0)
1201(kern-mk-sprite 's_hl_72 ss_hl 1 72 #f 0)
1202(kern-mk-sprite 's_hl_73 ss_hl 1 73 #f 0)
1203(kern-mk-sprite 's_hl_74 ss_hl 1 74 #f 0)
1204(kern-mk-sprite 's_hl_75 ss_hl 1 75 #f 0)
1205(kern-mk-sprite 's_hl_76 ss_hl 1 76 #f 0)
1206(kern-mk-sprite 's_hl_77 ss_hl 1 77 #f 0)
1207(kern-mk-sprite 's_hl_78 ss_hl 1 78 #f 0)
1208(kern-mk-sprite 's_hl_79 ss_hl 1 79 #f 0)
1209(kern-mk-sprite 's_hl_80 ss_hl 1 80 #f 0)
1210(kern-mk-sprite 's_hl_81 ss_hl 1 81 #f 0)
1211(kern-mk-sprite 's_hl_82 ss_hl 1 82 #f 0)
1212(kern-mk-sprite 's_hl_83 ss_hl 1 83 #f 0)
1213(kern-mk-sprite 's_hl_84 ss_hl 1 84 #f 0)
1214(kern-mk-sprite 's_hl_85 ss_hl 1 85 #f 0)
1215(kern-mk-sprite 's_hl_86 ss_hl 1 86 #f 0)
1216(kern-mk-sprite 's_hl_87 ss_hl 1 87 #f 0)
1217(kern-mk-sprite 's_hl_88 ss_hl 1 88 #f 0)
1218(kern-mk-sprite 's_hl_89 ss_hl 1 89 #f 0)
1219(kern-mk-sprite 's_hl_90 ss_hl 1 90 #f 0)
1220(kern-mk-sprite 's_hl_91 ss_hl 1 91 #f 0)
1221(kern-mk-sprite 's_hl_92 ss_hl 1 92 #f 0)
1222(kern-mk-sprite 's_hl_93 ss_hl 1 93 #f 0)
1223(kern-mk-sprite 's_hl_94 ss_hl 1 94 #f 0)
1224(kern-mk-sprite 's_hl_95 ss_hl 1 95 #f 0)
1225(kern-mk-sprite 's_hl_96 ss_hl 1 96 #f 0)
1226(kern-mk-sprite 's_hl_97 ss_hl 1 97 #f 0)
1227(kern-mk-sprite 's_hl_98 ss_hl 1 98 #f 0)
1228(kern-mk-sprite 's_hl_99 ss_hl 1 99 #f 0)
1229(kern-mk-sprite 's_hl_100 ss_hl 1 100 #f 0)
1230(kern-mk-sprite 's_hl_101 ss_hl 1 101 #f 0)
1231(kern-mk-sprite 's_hl_102 ss_hl 1 102 #f 0)
1232(kern-mk-sprite 's_hl_103 ss_hl 1 103 #f 0)
1233(kern-mk-sprite 's_hl_104 ss_hl 1 104 #f 0)
1234(kern-mk-sprite 's_hl_105 ss_hl 1 105 #f 0)
1235(kern-mk-sprite 's_hl_106 ss_hl 1 106 #f 0)
1236(kern-mk-sprite 's_hl_107 ss_hl 1 107 #f 0)
1237(kern-mk-sprite 's_hl_108 ss_hl 1 108 #f 0)
1238(kern-mk-sprite 's_hl_109 ss_hl 1 109 #f 0)
1239(kern-mk-sprite 's_hl_110 ss_hl 1 110 #f 0)
1240(kern-mk-sprite 's_hl_111 ss_hl 1 111 #f 0)
1241(kern-mk-sprite 's_hl_112 ss_hl 1 112 #f 0)
1242(kern-mk-sprite 's_hl_113 ss_hl 1 113 #f 0)
1243
1244(kern-mk-sprite 's_gf_nw ss_gf 1 0 #f 0)
1245(kern-mk-sprite 's_gf_n  ss_gf 1 1 #f 0)
1246(kern-mk-sprite 's_gf_ne ss_gf 1 2 #f 0)
1247(kern-mk-sprite 's_gf_w  ss_gf 1 3 #f 0)
1248(kern-mk-sprite 's_gf_c  ss_gf 1 4 #f 0)
1249(kern-mk-sprite 's_gf_e  ss_gf 1 5 #f 0)
1250(kern-mk-sprite 's_gf_sw ss_gf 1 6 #f 0)
1251(kern-mk-sprite 's_gf_s  ss_gf 1 7 #f 0)
1252(kern-mk-sprite 's_gf_se ss_gf 1 8 #f 0)
1253
1254(kern-mk-terrain 't_hl_0 "logo" pclass-wall s_hl_0 trn 0 nil)
1255(kern-mk-terrain 't_hl_1 "logo" pclass-wall s_hl_1 trn 0 nil)
1256(kern-mk-terrain 't_hl_2 "logo" pclass-wall s_hl_2 trn 0 nil)
1257(kern-mk-terrain 't_hl_3 "logo" pclass-wall s_hl_3 trn 0 nil)
1258(kern-mk-terrain 't_hl_4 "logo" pclass-wall s_hl_4 trn 0 nil)
1259(kern-mk-terrain 't_hl_5 "logo" pclass-wall s_hl_5 trn 0 nil)
1260(kern-mk-terrain 't_hl_6 "logo" pclass-wall s_hl_6 trn 0 nil)
1261(kern-mk-terrain 't_hl_7 "logo" pclass-wall s_hl_7 trn 0 nil)
1262(kern-mk-terrain 't_hl_8 "logo" pclass-wall s_hl_8 trn 0 nil)
1263(kern-mk-terrain 't_hl_9 "logo" pclass-wall s_hl_9 trn 0 nil)
1264(kern-mk-terrain 't_hl_10 "logo" pclass-wall s_hl_10 trn 0 nil)
1265(kern-mk-terrain 't_hl_11 "logo" pclass-wall s_hl_11 trn 0 nil)
1266(kern-mk-terrain 't_hl_12 "logo" pclass-wall s_hl_12 trn 0 nil)
1267(kern-mk-terrain 't_hl_13 "logo" pclass-wall s_hl_13 trn 0 nil)
1268(kern-mk-terrain 't_hl_14 "logo" pclass-wall s_hl_14 trn 0 nil)
1269(kern-mk-terrain 't_hl_15 "logo" pclass-wall s_hl_15 trn 0 nil)
1270(kern-mk-terrain 't_hl_16 "logo" pclass-wall s_hl_16 trn 0 nil)
1271(kern-mk-terrain 't_hl_17 "logo" pclass-wall s_hl_17 trn 0 nil)
1272(kern-mk-terrain 't_hl_18 "logo" pclass-wall s_hl_18 trn 0 nil)
1273(kern-mk-terrain 't_hl_19 "logo" pclass-wall s_hl_19 trn 0 nil)
1274(kern-mk-terrain 't_hl_20 "logo" pclass-wall s_hl_20 trn 0 nil)
1275(kern-mk-terrain 't_hl_21 "logo" pclass-wall s_hl_21 trn 0 nil)
1276(kern-mk-terrain 't_hl_22 "logo" pclass-wall s_hl_22 trn 0 nil)
1277(kern-mk-terrain 't_hl_23 "logo" pclass-wall s_hl_23 trn 0 nil)
1278(kern-mk-terrain 't_hl_24 "logo" pclass-wall s_hl_24 trn 0 nil)
1279(kern-mk-terrain 't_hl_25 "logo" pclass-wall s_hl_25 trn 0 nil)
1280(kern-mk-terrain 't_hl_26 "logo" pclass-wall s_hl_26 trn 0 nil)
1281(kern-mk-terrain 't_hl_27 "logo" pclass-wall s_hl_27 trn 0 nil)
1282(kern-mk-terrain 't_hl_28 "logo" pclass-wall s_hl_28 trn 0 nil)
1283(kern-mk-terrain 't_hl_29 "logo" pclass-wall s_hl_29 trn 0 nil)
1284(kern-mk-terrain 't_hl_30 "logo" pclass-wall s_hl_30 trn 0 nil)
1285(kern-mk-terrain 't_hl_31 "logo" pclass-wall s_hl_31 trn 0 nil)
1286(kern-mk-terrain 't_hl_32 "logo" pclass-wall s_hl_32 trn 0 nil)
1287(kern-mk-terrain 't_hl_33 "logo" pclass-wall s_hl_33 trn 0 nil)
1288(kern-mk-terrain 't_hl_34 "logo" pclass-wall s_hl_34 trn 0 nil)
1289(kern-mk-terrain 't_hl_35 "logo" pclass-wall s_hl_35 trn 0 nil)
1290(kern-mk-terrain 't_hl_36 "logo" pclass-wall s_hl_36 trn 0 nil)
1291(kern-mk-terrain 't_hl_37 "logo" pclass-wall s_hl_37 trn 0 nil)
1292(kern-mk-terrain 't_hl_38 "logo" pclass-wall s_hl_38 trn 0 nil)
1293(kern-mk-terrain 't_hl_39 "logo" pclass-wall s_hl_39 trn 0 nil)
1294(kern-mk-terrain 't_hl_40 "logo" pclass-wall s_hl_40 trn 0 nil)
1295(kern-mk-terrain 't_hl_41 "logo" pclass-wall s_hl_41 trn 0 nil)
1296(kern-mk-terrain 't_hl_42 "logo" pclass-wall s_hl_42 trn 0 nil)
1297(kern-mk-terrain 't_hl_43 "logo" pclass-wall s_hl_43 trn 0 nil)
1298(kern-mk-terrain 't_hl_44 "logo" pclass-wall s_hl_44 trn 0 nil)
1299(kern-mk-terrain 't_hl_45 "logo" pclass-wall s_hl_45 trn 0 nil)
1300(kern-mk-terrain 't_hl_46 "logo" pclass-wall s_hl_46 trn 0 nil)
1301(kern-mk-terrain 't_hl_47 "logo" pclass-wall s_hl_47 trn 0 nil)
1302(kern-mk-terrain 't_hl_48 "logo" pclass-wall s_hl_48 trn 0 nil)
1303(kern-mk-terrain 't_hl_49 "logo" pclass-wall s_hl_49 trn 0 nil)
1304(kern-mk-terrain 't_hl_50 "logo" pclass-wall s_hl_50 trn 0 nil)
1305(kern-mk-terrain 't_hl_51 "logo" pclass-wall s_hl_51 trn 0 nil)
1306(kern-mk-terrain 't_hl_52 "logo" pclass-wall s_hl_52 trn 0 nil)
1307(kern-mk-terrain 't_hl_53 "logo" pclass-wall s_hl_53 trn 0 nil)
1308(kern-mk-terrain 't_hl_54 "logo" pclass-wall s_hl_54 trn 0 nil)
1309(kern-mk-terrain 't_hl_55 "logo" pclass-wall s_hl_55 trn 0 nil)
1310(kern-mk-terrain 't_hl_56 "logo" pclass-wall s_hl_56 trn 0 nil)
1311(kern-mk-terrain 't_hl_57 "logo" pclass-wall s_hl_57 trn 0 nil)
1312(kern-mk-terrain 't_hl_58 "logo" pclass-wall s_hl_58 trn 0 nil)
1313(kern-mk-terrain 't_hl_59 "logo" pclass-wall s_hl_59 trn 0 nil)
1314(kern-mk-terrain 't_hl_60 "logo" pclass-wall s_hl_60 trn 0 nil)
1315(kern-mk-terrain 't_hl_61 "logo" pclass-wall s_hl_61 trn 0 nil)
1316(kern-mk-terrain 't_hl_62 "logo" pclass-wall s_hl_62 trn 0 nil)
1317(kern-mk-terrain 't_hl_63 "logo" pclass-wall s_hl_63 trn 0 nil)
1318(kern-mk-terrain 't_hl_64 "logo" pclass-wall s_hl_64 trn 0 nil)
1319(kern-mk-terrain 't_hl_65 "logo" pclass-wall s_hl_65 trn 0 nil)
1320(kern-mk-terrain 't_hl_66 "logo" pclass-wall s_hl_66 trn 0 nil)
1321(kern-mk-terrain 't_hl_67 "logo" pclass-wall s_hl_67 trn 0 nil)
1322(kern-mk-terrain 't_hl_68 "logo" pclass-wall s_hl_68 trn 0 nil)
1323(kern-mk-terrain 't_hl_69 "logo" pclass-wall s_hl_69 trn 0 nil)
1324(kern-mk-terrain 't_hl_70 "logo" pclass-wall s_hl_70 trn 0 nil)
1325(kern-mk-terrain 't_hl_71 "logo" pclass-wall s_hl_71 trn 0 nil)
1326(kern-mk-terrain 't_hl_72 "logo" pclass-wall s_hl_72 trn 0 nil)
1327(kern-mk-terrain 't_hl_73 "logo" pclass-wall s_hl_73 trn 0 nil)
1328(kern-mk-terrain 't_hl_74 "logo" pclass-wall s_hl_74 trn 0 nil)
1329(kern-mk-terrain 't_hl_75 "logo" pclass-wall s_hl_75 trn 0 nil)
1330(kern-mk-terrain 't_hl_76 "logo" pclass-wall s_hl_76 trn 0 nil)
1331(kern-mk-terrain 't_hl_77 "logo" pclass-wall s_hl_77 trn 0 nil)
1332(kern-mk-terrain 't_hl_78 "logo" pclass-wall s_hl_78 trn 0 nil)
1333(kern-mk-terrain 't_hl_79 "logo" pclass-wall s_hl_79 trn 0 nil)
1334(kern-mk-terrain 't_hl_80 "logo" pclass-wall s_hl_80 trn 0 nil)
1335(kern-mk-terrain 't_hl_81 "logo" pclass-wall s_hl_81 trn 0 nil)
1336(kern-mk-terrain 't_hl_82 "logo" pclass-wall s_hl_82 trn 0 nil)
1337(kern-mk-terrain 't_hl_83 "logo" pclass-wall s_hl_83 trn 0 nil)
1338(kern-mk-terrain 't_hl_84 "logo" pclass-wall s_hl_84 trn 0 nil)
1339(kern-mk-terrain 't_hl_85 "logo" pclass-wall s_hl_85 trn 0 nil)
1340(kern-mk-terrain 't_hl_86 "logo" pclass-wall s_hl_86 trn 0 nil)
1341(kern-mk-terrain 't_hl_87 "logo" pclass-wall s_hl_87 trn 0 nil)
1342(kern-mk-terrain 't_hl_88 "logo" pclass-wall s_hl_88 trn 0 nil)
1343(kern-mk-terrain 't_hl_89 "logo" pclass-wall s_hl_89 trn 0 nil)
1344(kern-mk-terrain 't_hl_90 "logo" pclass-wall s_hl_90 trn 0 nil)
1345(kern-mk-terrain 't_hl_91 "logo" pclass-wall s_hl_91 trn 0 nil)
1346(kern-mk-terrain 't_hl_92 "logo" pclass-wall s_hl_92 trn 0 nil)
1347(kern-mk-terrain 't_hl_93 "logo" pclass-wall s_hl_93 trn 0 nil)
1348(kern-mk-terrain 't_hl_94 "logo" pclass-wall s_hl_94 trn 0 nil)
1349(kern-mk-terrain 't_hl_95 "logo" pclass-wall s_hl_95 trn 0 nil)
1350(kern-mk-terrain 't_hl_96 "logo" pclass-wall s_hl_96 trn 0 nil)
1351(kern-mk-terrain 't_hl_97 "logo" pclass-wall s_hl_97 trn 0 nil)
1352(kern-mk-terrain 't_hl_98 "logo" pclass-wall s_hl_98 trn 0 nil)
1353(kern-mk-terrain 't_hl_99 "logo" pclass-wall s_hl_99 trn 0 nil)
1354(kern-mk-terrain 't_hl_100 "logo" pclass-wall s_hl_100 trn 0 nil)
1355(kern-mk-terrain 't_hl_101 "logo" pclass-wall s_hl_101 trn 0 nil)
1356(kern-mk-terrain 't_hl_102 "logo" pclass-wall s_hl_102 trn 0 nil)
1357(kern-mk-terrain 't_hl_103 "logo" pclass-wall s_hl_103 trn 0 nil)
1358(kern-mk-terrain 't_hl_104 "logo" pclass-wall s_hl_104 trn 0 nil)
1359(kern-mk-terrain 't_hl_105 "logo" pclass-wall s_hl_105 trn 0 nil)
1360(kern-mk-terrain 't_hl_106 "logo" pclass-wall s_hl_106 trn 0 nil)
1361(kern-mk-terrain 't_hl_107 "logo" pclass-wall s_hl_107 trn 0 nil)
1362(kern-mk-terrain 't_hl_108 "logo" pclass-wall s_hl_108 trn 0 nil)
1363(kern-mk-terrain 't_hl_109 "logo" pclass-wall s_hl_109 trn 0 nil)
1364(kern-mk-terrain 't_hl_110 "logo" pclass-wall s_hl_110 trn 0 nil)
1365(kern-mk-terrain 't_hl_111 "logo" pclass-wall s_hl_111 trn 0 nil)
1366(kern-mk-terrain 't_hl_112 "logo" pclass-wall s_hl_112 trn 0 nil)
1367(kern-mk-terrain 't_hl_113 "logo" pclass-wall s_hl_113 trn 0 nil)
1368
1369(kern-mk-terrain 't_gf_nw "frame" pclass-wall s_gf_nw trn 0 nil)
1370(kern-mk-terrain 't_gf_n  "frame" pclass-wall s_gf_n  trn 0 nil)
1371(kern-mk-terrain 't_gf_ne "frame" pclass-wall s_gf_ne trn 0 nil)
1372(kern-mk-terrain 't_gf_w  "frame" pclass-wall s_gf_w  trn 0 nil)
1373(kern-mk-terrain 't_gf_c  "frame" pclass-wall s_gf_c  trn 0 nil)
1374(kern-mk-terrain 't_gf_e  "frame" pclass-wall s_gf_e  trn 0 nil)
1375(kern-mk-terrain 't_gf_sw "frame" pclass-wall s_gf_sw trn 0 nil)
1376(kern-mk-terrain 't_gf_s  "frame" pclass-wall s_gf_s  trn 0 nil)
1377(kern-mk-terrain 't_gf_se "frame" pclass-wall s_gf_se trn 0 nil)
1378
1379(kern-mk-terrain 't_overgrown_altar "altar" pclass-boulder s_overgrown_altar trn 0 nil)
1380
1381;; define our own palette to include the logo terrain
1382(kern-mk-palette 'pal_expanded
1383  (list
1384    ;; NOTE: "x#" is reserved for blocking mechanisms, see block-teleporting in
1385    ;; naz.scm
1386    (list  "xx"   t_wall)               ;; "wall"
1387    (list  "__"   t_deep)               ;; "deep water"
1388    (list  "_!"   t_sunlit_deep)               ;; "deep water"
1389    (list  "~*"   t_blendable_shoals)            ;; "shallow water"
1390    (list  "_s"   t_sludge)
1391    (list  "~s"   t_shallow_sludge)
1392    (list  "dd"   t_dirt)
1393    (list  "gg"   t_gravel)
1394
1395    (list  "%%"   t_bog)                ;; "bog"
1396    (list  ".."   t_grass)              ;; "grass"
1397    (list  ".!"   t_sunlit_grass)              ;; "grass"
1398    (list  "t."   t_trees_v)            ;; "trees (transparent)"
1399    (list  "tt"   t_trees)              ;; "trees"
1400    (list  "t|"   t_trees_d)            ;; "trees denser"
1401
1402    (list  "||"   t_forest)             ;; "forest"
1403    (list  "|X"   t_forest_d)           ;; "forest (denser)"
1404    (list  "|t"   t_forest_l)           ;; "forest (lighter)"
1405    (list  "|."   t_forest_v)           ;; "forest (non-LOS-blocking)"
1406    (list  "|v"   t_forest_b)           ;; "forest (totally LOS-blocking)"
1407
1408    (list  "{{"   t_hills)              ;; "hills"
1409
1410    (list  "^^"   t_mountains)          ;; "mountains"
1411    (list  "^."   t_mountains_v)        ;; "mountains" (non-LOS-blocking)
1412    (list  "^v"   t_mountains_b)        ;; "mountains" (below player)
1413    (list  "^~"   t_fake_mountains)
1414
1415    (list  ",,"   t_flagstones)         ;; "flagstones"
1416    (list  "~,"   t_inv_wall)
1417    (list  "d,"   t_doorway)
1418    (list  "cc"   t_cobblestone)        ;; "cobblestone"
1419    (list  "ee"   t_deck)               ;; "deck"
1420    (list  "oo"   t_mast)               ;; "mast"
1421    (list  "ff"   t_fire_terrain)       ;; "fire"
1422    (list  "!!"   t_lava)               ;; "lava"
1423    (list  "~!"   t_fake_lava)
1424    (list  "!_"   t_deep_lava)
1425    (list  "&&"   t_fireplace)          ;; "fireplace"
1426
1427    (list  "x."   t_wall_v)             ;; "wall"  (non-LOS-blocking)
1428    (list  "~x"   t_fake_wall)
1429
1430    (list  "**"   t_stars)              ;; "stars"
1431	(list  "*."   t_void)
1432    (list  "??"   t_secret_door)        ;; "secret door"
1433    (list  "pp"   t_pillar)             ;; "pillar"
1434    (list  "~p"   t_false_pillar)
1435    (list  "bb"   t_boulder)            ;; "boulder"
1436    (list  "b~"   t_water_rocks)        ;; "boulder" in water
1437
1438    (list  "rr"   t_wall_rock)          ;; "rock wall"
1439    (list  "r."   t_wall_rock_v)        ;; "rock wall"  (non-LOS-blocking)
1440    (list  "~r"   t_fake_wall_rock)     ;; "rock wall"  (fake)
1441
1442    (list  "WW"   t_ships_wheel)        ;; "ship's wheel"
1443    (list  "x!"   t_wall_torch)         ;; "wall torch"
1444    (list  "##"   t_ship_hull)          ;; "ship's hull"
1445    (list  "#>"   t_ship_hull2)          ;; "ship's hull (LOS-blocking)"
1446
1447    (list  ".A"   t_a)                  ;; "an A"
1448    (list  ".B"   t_b)                  ;; "a B"
1449    (list  "?B"   t_fake_b)                  ;; "a B"
1450    (list  ".C"   t_c)                  ;; "a C"
1451    (list  ".D"   t_d)                  ;; "a D"
1452    (list  ".E"   t_e)                  ;; "an E"
1453    (list  ".F"   t_f)                  ;; "an F"
1454    (list  ".G"   t_g)                  ;; "a G"
1455    (list  ".H"   t_h)                  ;; "an H"
1456    (list  ".I"   t_i)                  ;; "an I"
1457    (list  ".J"   t_j)                  ;; "a J"
1458    (list  ".K"   t_k)                  ;; "a K"
1459    (list  ".L"   t_l)                  ;; "an L"
1460    (list  ".M"   t_m)                  ;; "an M"
1461    (list  ".N"   t_n)                  ;; "an N"
1462    (list  ".O"   t_o)                  ;; "an O"
1463    (list  "~O"   t_fake_o)
1464    (list  ".P"   t_p)                  ;; "a P"
1465    (list  ".Q"   t_q)                  ;; "a Q"
1466    (list  ".R"   t_r)                  ;; "an R"
1467    (list  ".S"   t_s)                  ;; "an S"
1468    (list  ".T"   t_t)                  ;; "a T"
1469    (list  ".U"   t_u)                  ;; "a U"
1470    (list  ".V"   t_v)                  ;; "a V"
1471    (list  ".W"   t_w)                  ;; "a W"
1472    (list  ".X"   t_x)                  ;; "an X"
1473    (list  ".Y"   t_y)                  ;; "a Y"
1474    (list  ".Z"   t_z)                  ;; "a Z"
1475
1476    (list  ",A"   t_rune_a)             ;; "a rune"
1477    (list  ",B"   t_rune_b)             ;; "a rune"
1478    (list  ",C"   t_rune_c)             ;; "a rune"
1479    (list  ",D"   t_rune_d)             ;; "a rune"
1480    (list  ",E"   t_rune_e)             ;; "a rune"
1481    (list  ",F"   t_rune_f)             ;; "a rune"
1482    (list  ",G"   t_rune_g)             ;; "a rune"
1483    (list  ",H"   t_rune_h)             ;; "a rune"
1484    (list  ",I"   t_rune_i)             ;; "a rune"
1485    (list  ",J"   t_rune_j)             ;; "a rune"
1486    (list  ",K"   t_rune_k)             ;; "a rune"
1487    (list  ",L"   t_rune_l)             ;; "a rune"
1488    (list  ",M"   t_rune_m)             ;; "a rune"
1489    (list  ",N"   t_rune_n)             ;; "a rune"
1490    (list  ",O"   t_rune_o)             ;; "a rune"
1491    (list  ",P"   t_rune_p)             ;; "a rune"
1492    (list  ",Q"   t_rune_q)             ;; "a rune"
1493    (list  ",R"   t_rune_r)             ;; "a rune"
1494    (list  ",S"   t_rune_s)             ;; "a rune"
1495    (list  ",T"   t_rune_t)             ;; "a rune"
1496    (list  ",U"   t_rune_u)             ;; "a rune"
1497    (list  ",V"   t_rune_v)             ;; "a rune"
1498    (list  ",W"   t_rune_w)             ;; "a rune"
1499    (list  ",X"   t_rune_x)             ;; "a rune"
1500    (list  ",Y"   t_rune_y)             ;; "a rune"
1501    (list  ",Z"   t_rune_z)             ;; "a rune"
1502    (list  ";T"   t_rune_th)            ;; "a rune"
1503    (list  ";E"   t_rune_ee)            ;; "a rune"
1504    (list  ";N"   t_rune_ng)            ;; "a rune"
1505    (list  ";A"   t_rune_ea)            ;; "a rune"
1506    (list  ";S"   t_rune_st)            ;; "a rune"
1507    (list  ";D"   t_rune_dot)           ;; "a rune"
1508
1509    (list  "@@"   t_counter_2x1_c)      ;; "counter"
1510    (list  "[["   t_counter_2x1_w)      ;; "counter"
1511    (list  "]]"   t_counter_2x1_e)      ;; "counter"
1512
1513    (list  "++"   t_ankh)               ;; "ankh"
1514    (list  "+s"   t_statue)               ;; "ankh"
1515    (list  "aa"   t_altar)              ;; "altar"
1516    (list  "ar"   t_rune_altar)              ;; "altar"
1517    (list  "a!"   t_active_altar)              ;; "altar"
1518    (list  "at"   t_overgrown_altar)              ;; "altar"
1519    (list  "<<"   t_leftwing)           ;; "castle wall"
1520    (list  ">>"   t_rightwing)          ;; "castle wall"
1521    (list  "w+"   t_arrow_slit)         ;; "arrow slit"
1522    (list  "ws"   t_window_in_stone)    ;; "window"
1523    (list  "wr"   t_window_in_rock)     ;; "window"
1524
1525    (list  "=="   t_bridge_WE)          ;; "east-west bridge"
1526    (list  "=|"   t_bridge_NS)          ;; "east-west bridge"
1527    (list  "=!"   t_lava_bridge_NS)
1528    (list  "vv"   t_chasm)              ;; "chasm"
1529
1530    (list "sE" t_equip_sign)
1531    (list "sA" t_weapon_sign)
1532    (list "sH" t_healer_sign)
1533    (list "sT" t_tavern_sign)
1534    (list "sI" t_inn_sign)
1535    (list "sP" t_alchemy_sign)
1536    (list "sR" t_magic_sign)
1537    (list "sS" t_str_sign)
1538    (list "sD" t_dex_sign)
1539    (list "sW" t_wis_sign)
1540
1541	;; blended terrains (mostly terrain + corner of something else)
1542
1543	(list  "/0"   t_trail_0)            ;; "trail"
1544    (list  "/1"   t_trail_1)            ;; "trail"
1545    (list  "/2"   t_trail_2)            ;; "trail"
1546    (list  "/3"   t_trail_3)            ;; "trail"
1547    (list  "/4"   t_trail_4)            ;; "trail"
1548    (list  "/5"   t_trail_5)            ;; "trail"
1549    (list  "/6"   t_trail_6)            ;; "trail"
1550    (list  "/7"   t_trail_7)            ;; "trail"
1551    (list  "/8"   t_trail_8)            ;; "trail"
1552    (list  "/9"   t_trail_9)            ;; "trail"
1553    (list  "/a"   t_trail_a)            ;; "trail"
1554    (list  "/b"   t_trail_b)            ;; "trail"
1555    (list  "/c"   t_trail_c)            ;; "trail"
1556    (list  "/d"   t_trail_d)            ;; "trail"
1557    (list  "/e"   t_trail_e)            ;; "trail"
1558    (list  "/f"   t_trail_f)            ;; "trail"
1559
1560	(list  "~~" t_shoals)     ;; shallow + land
1561    (list  "~1" t_shore_n)
1562    (list  "~2" t_shore_w)
1563    (list  "~3" t_shore_nw)
1564    (list  "~4" t_shore_e)
1565    (list  "~5" t_shore_ne)
1566    (list  "~6" t_shore_we)
1567    (list  "~7" t_shore_nwe)
1568    (list  "~8" t_shore_s)
1569    (list  "~9" t_shore_ns)
1570    (list  "~a" t_shore_ws)
1571    (list  "~b" t_shore_nws)
1572    (list  "~c" t_shore_es)
1573    (list  "~d" t_shore_nes)
1574    (list  "~e" t_shore_wes)
1575    (list  "~f" t_shore_c)
1576
1577    (list  "--" t_shallow)            ;; water + land
1578    (list  "-1" t_wshore_n)
1579    (list  "-2" t_wshore_w)
1580    (list  "-3" t_wshore_nw)
1581    (list  "-4" t_wshore_e)
1582    (list  "-5" t_wshore_ne)
1583    (list  "-6" t_wshore_we)
1584    (list  "-7" t_wshore_nwe)
1585    (list  "-8" t_wshore_s)
1586    (list  "-9" t_wshore_ns)
1587    (list  "-a" t_wshore_ws)
1588    (list  "-b" t_wshore_nws)
1589    (list  "-c" t_wshore_es)
1590    (list  "-d" t_wshore_nes)
1591    (list  "-e" t_wshore_wes)
1592    (list  "-f" t_wshore_c)
1593
1594	(list  "_1" t_dshore_n)        ;; deep water + land
1595    (list  "_2" t_dshore_w)
1596    (list  "_3" t_dshore_nw)
1597    (list  "_4" t_dshore_e)
1598    (list  "_5" t_dshore_ne)
1599    (list  "_6" t_dshore_we)
1600    (list  "_7" t_dshore_nwe)
1601    (list  "_8" t_dshore_s)
1602    (list  "_9" t_dshore_ns)
1603    (list  "_a" t_dshore_ws)
1604    (list  "_b" t_dshore_nws)
1605    (list  "_c" t_dshore_es)
1606    (list  "_d" t_dshore_nes)
1607    (list  "_e" t_dshore_wes)
1608    (list  "_f" t_dshore_c)
1609
1610	(list  "*1" t_voids_n)             ;; void + land
1611    (list  "*2" t_voids_w)
1612    (list  "*3" t_voids_nw)
1613    (list  "*4" t_voids_e)
1614    (list  "*5" t_voids_ne)
1615    (list  "*6" t_voids_we)
1616    (list  "*7" t_voids_nwe)
1617    (list  "*8" t_voids_s)
1618    (list  "*9" t_voids_ns)
1619    (list  "*a" t_voids_ws)
1620    (list  "*b" t_voids_nws)
1621    (list  "*c" t_voids_es)
1622    (list  "*d" t_voids_nes)
1623    (list  "*e" t_voids_wes)
1624    (list  "*f" t_voids_c)
1625
1626	(list  "{1" t_hilledge_n)          ;; grass + hills
1627    (list  "{2" t_hilledge_w)
1628    (list  "{3" t_hilledge_nw)
1629    (list  "{4" t_hilledge_e)
1630    (list  "{5" t_hilledge_ne)
1631    (list  "{6" t_hilledge_we)
1632    (list  "{7" t_hilledge_nwe)
1633    (list  "{8" t_hilledge_s)
1634    (list  "{9" t_hilledge_ns)
1635    (list  "{a" t_hilledge_ws)
1636    (list  "{b" t_hilledge_nws)
1637    (list  "{c" t_hilledge_es)
1638    (list  "{d" t_hilledge_nes)
1639    (list  "{e" t_hilledge_wes)
1640    (list  "{f" t_hilledge_c)
1641
1642    (list  "%3" t_bog_nw)              ;; bog + land
1643    (list  "%5" t_bog_ne)
1644    (list  "%7" t_bog_nwe)
1645    (list  "%a" t_bog_ws)
1646    (list  "%b" t_bog_nws)
1647    (list  "%c" t_bog_es)
1648    (list  "%d" t_bog_nes)
1649    (list  "%e" t_bog_wes)
1650    (list  "%f" t_bog_c)
1651
1652    (list  "t3" t_trees_nw)               ;; trees + grass
1653    (list  "t5" t_trees_ne)
1654    (list  "t7" t_trees_nwe)
1655    (list  "ta" t_trees_ws)
1656    (list  "tb" t_trees_nws)
1657    (list  "tc" t_trees_es)
1658    (list  "td" t_trees_nes)
1659    (list  "te" t_trees_wes)
1660    (list  "tf" t_trees_c)
1661
1662	(list  "t#" t_grasst_nw)             ;; grass + trees
1663    (list  "t%" t_grasst_ne)
1664    (list  "t&" t_grasst_nwe)
1665    (list  "tA" t_grasst_ws)
1666    (list  "tB" t_grasst_nws)
1667    (list  "tC" t_grasst_es)
1668    (list  "tD" t_grasst_nes)
1669    (list  "tE" t_grasst_wes)
1670    (list  "tF" t_grasst_c)
1671
1672	(list  "~#" t_grassw_nw)           ;; grass + water
1673    (list  "~%" t_grassw_ne)
1674    (list  "~&" t_grassw_nwe)
1675    (list  "~A" t_grassw_ws)
1676    (list  "~B" t_grassw_nws)
1677    (list  "~C" t_grassw_es)
1678    (list  "~D" t_grassw_nes)
1679    (list  "~E" t_grassw_wes)
1680    (list  "~F" t_grassw_c)
1681
1682	(list  "{#" t_hilli_nw)             ;; hills + grass
1683    (list  "{%" t_hilli_ne)
1684    (list  "{&" t_hilli_nwe)
1685    (list  "{A" t_hilli_ws)
1686    (list  "{B" t_hilli_nws)
1687    (list  "{C" t_hilli_es)
1688    (list  "{D" t_hilli_nes)
1689    (list  "{E" t_hilli_wes)
1690    (list  "{F" t_hilli_c)
1691
1692	(list  "|#" t_forestg_nw)          ;; forest + grass
1693    (list  "|%" t_forestg_ne)
1694    (list  "|&" t_forestg_nwe)
1695    (list  "|A" t_forestg_ws)
1696    (list  "|B" t_forestg_nws)
1697    (list  "|C" t_forestg_es)
1698    (list  "|D" t_forestg_nes)
1699    (list  "|E" t_forestg_wes)
1700
1701	(list  "tG" t_treew_nw)            ;; trees + water
1702    (list  "tH" t_treew_ne)
1703    (list  "tI" t_treew_nwe)
1704    (list  "tJ" t_treew_ws)
1705    (list  "tK" t_treew_nws)
1706    (list  "tL" t_treew_es)
1707    (list  "tM" t_treew_nes)
1708    (list  "tN" t_treew_wes)
1709    (list  "tO" t_treew_c)
1710
1711	(list  "{G" t_hillw_nw)            ;; hills + water
1712    (list  "{H" t_hillw_ne)
1713    (list  "{I" t_hillw_nwe)
1714    (list  "{J" t_hillw_ws)
1715    (list  "{K" t_hillw_nws)
1716    (list  "{L" t_hillw_es)
1717    (list  "{M" t_hillw_nes)
1718    (list  "{N" t_hillw_wes)
1719    (list  "{O" t_hillw_c)
1720
1721	(list  "{g" t_hillv_nw)           ;; hills + void
1722    (list  "{h" t_hillv_ne)
1723    (list  "{i" t_hillv_nwe)
1724    (list  "{j" t_hillv_ws)
1725    (list  "{k" t_hillv_nws)
1726    (list  "{l" t_hillv_es)
1727    (list  "{m" t_hillv_nes)
1728    (list  "{n" t_hillv_wes)
1729
1730	(list  ".g" t_grassv_nw)          ;; grass + void
1731    (list  ".h" t_grassv_ne)
1732    (list  ".i" t_grassv_nwe)
1733    (list  ".j" t_grassv_ws)
1734    (list  ".k" t_grassv_nws)
1735    (list  ".l" t_grassv_es)
1736    (list  ".m" t_grassv_nes)
1737    (list  ".n" t_grassv_wes)
1738
1739	(list  "^g" t_mountv_nw)        ;; mounts + void
1740    (list  "^h" t_mountv_ne)
1741    (list  "^i" t_mountv_nwe)
1742    (list  "^j" t_mountv_ws)
1743    (list  "^k" t_mountv_nws)
1744    (list  "^l" t_mountv_es)
1745    (list  "^m" t_mountv_nes)
1746    (list  "^n" t_mountv_wes)
1747
1748	(list  "^3" t_mountg_nw)     ;; mounts + grass
1749    (list  "^5" t_mountg_ne)
1750    (list  "^7" t_mountg_nwe)
1751    (list  "^a" t_mountg_ws)
1752    (list  "^b" t_mountg_nws)
1753    (list  "^c" t_mountg_es)
1754    (list  "^d" t_mountg_nes)
1755    (list  "^e" t_mountg_wes)
1756    (list  "^f" t_mountg_c)
1757
1758	(list  "^G" t_mountw_nw)        ;; mounts + water
1759    (list  "^H" t_mountw_ne)
1760    (list  "^I" t_mountw_nwe)
1761    (list  "^J" t_mountw_ws)
1762    (list  "^K" t_mountw_nws)
1763    (list  "^L" t_mountw_es)
1764    (list  "^M" t_mountw_nes)
1765    (list  "^N" t_mountw_wes)
1766    (list  "^O" t_mountw_c)
1767
1768    (list  "!3" t_lava_nw)        ;; lava + land
1769    (list  "!5" t_lava_ne)
1770    (list  "!6" t_lava_we)
1771    (list  "!7" t_lava_nwe)
1772    (list  "!a" t_lava_ws)
1773    (list  "!b" t_lava_nws)
1774    (list  "!c" t_lava_es)
1775    (list  "!d" t_lava_nes)
1776    (list  "!e" t_lava_wes)
1777    (list  "!f" t_lava_c)
1778
1779    (list	"#=" t_rail_ew)
1780    (list	"#|" t_rail_ns)
1781    (list	"#a" t_bulwark_n)
1782    (list	"#b" t_bulwark_w)
1783    (list	"#c" t_bulwark_e)
1784    (list	"#d" t_bulwark_s)
1785    (list	"#A" t_bulwark_v_n)
1786    (list	"#B" t_bulwark_v_w)
1787    (list	"#C" t_bulwark_v_e)
1788    (list	"#D" t_bulwark_v_s)
1789    (list	"#e" t_bulwark_w_nw)
1790    (list	"#f" t_bulwark_w_ne)
1791    (list	"#g" t_bulwark_w_sw)
1792    (list	"#h" t_bulwark_w_se)
1793    (list	"#E" t_bulwark_d_nw)
1794    (list	"#F" t_bulwark_d_ne)
1795    (list	"#G" t_bulwark_d_sw)
1796    (list	"#H" t_bulwark_d_se)
1797    (list	"#i" t_bulwark_v_nw)
1798    (list	"#j" t_bulwark_v_ne)
1799    (list	"#k" t_bulwark_v_sw)
1800    (list	"#l" t_bulwark_v_se)
1801    (list	"#I" t_bulwark_x_nw)
1802    (list	"#J" t_bulwark_x_ne)
1803    (list	"#K" t_bulwark_x_sw)
1804    (list	"#L" t_bulwark_x_se)
1805    (list	"#s" t_bulwark_x_ns)
1806    (list	"#r" t_bulwark_x_ew)
1807
1808    (list	"#m" t_tank_l)
1809    (list	"#M" t_tank_d)
1810    (list	"#n" t_tank_nw)
1811    (list	"#o" t_tank_ne)
1812    (list	"#p" t_tank_sw)
1813    (list	"#q" t_tank_se)
1814    (list	"#N" t_tank_d_nw)
1815    (list	"#O" t_tank_d_ne)
1816    (list	"#P" t_tank_d_sw)
1817    (list	"#Q" t_tank_d_se)
1818
1819    (list	"<n" t_stair_un)
1820    (list	"<s" t_stair_us)
1821    (list	"<w" t_stair_uw)
1822    (list	"<e" t_stair_ue)
1823
1824    (list	"rn" t_nat_rock)
1825    (list	"r1" t_nat_rock_n)
1826    (list	"r2" t_nat_rock_w)
1827    (list	"r3" t_nat_rock_nw)
1828    (list	"r4" t_nat_rock_e)
1829    (list	"r5" t_nat_rock_ne)
1830    (list	"r6" t_nat_rock_we)
1831    (list	"r7" t_nat_rock_nwe)
1832    (list	"r8" t_nat_rock_s)
1833    (list	"r9" t_nat_rock_ns)
1834    (list	"ra" t_nat_rock_ws)
1835    (list	"rb" t_nat_rock_nws)
1836    (list	"rc" t_nat_rock_es)
1837    (list	"rd" t_nat_rock_nes)
1838    (list	"re" t_nat_rock_wes)
1839    (list	"rf" t_nat_rock_nwes)
1840    (list	"r~" t_fake_wall_nrock)
1841
1842    (list "000" t_hl_0)
1843    (list "001" t_hl_1)
1844    (list "002" t_hl_2)
1845    (list "003" t_hl_3)
1846    (list "004" t_hl_4)
1847    (list "005" t_hl_5)
1848    (list "006" t_hl_6)
1849    (list "007" t_hl_7)
1850    (list "008" t_hl_8)
1851    (list "009" t_hl_9)
1852    (list "010" t_hl_10)
1853    (list "011" t_hl_11)
1854    (list "012" t_hl_12)
1855    (list "013" t_hl_13)
1856    (list "014" t_hl_14)
1857    (list "015" t_hl_15)
1858    (list "016" t_hl_16)
1859    (list "017" t_hl_17)
1860    (list "018" t_hl_18)
1861    (list "019" t_hl_19)
1862    (list "020" t_hl_20)
1863    (list "021" t_hl_21)
1864    (list "022" t_hl_22)
1865    (list "023" t_hl_23)
1866    (list "024" t_hl_24)
1867    (list "025" t_hl_25)
1868    (list "026" t_hl_26)
1869    (list "027" t_hl_27)
1870    (list "028" t_hl_28)
1871    (list "029" t_hl_29)
1872    (list "030" t_hl_30)
1873    (list "031" t_hl_31)
1874    (list "032" t_hl_32)
1875    (list "033" t_hl_33)
1876    (list "034" t_hl_34)
1877    (list "035" t_hl_35)
1878    (list "036" t_hl_36)
1879    (list "037" t_hl_37)
1880    (list "038" t_hl_38)
1881    (list "039" t_hl_39)
1882    (list "040" t_hl_40)
1883    (list "041" t_hl_41)
1884    (list "042" t_hl_42)
1885    (list "043" t_hl_43)
1886    (list "044" t_hl_44)
1887    (list "045" t_hl_45)
1888    (list "046" t_hl_46)
1889    (list "047" t_hl_47)
1890    (list "048" t_hl_48)
1891    (list "049" t_hl_49)
1892    (list "050" t_hl_50)
1893    (list "051" t_hl_51)
1894    (list "052" t_hl_52)
1895    (list "053" t_hl_53)
1896    (list "054" t_hl_54)
1897    (list "055" t_hl_55)
1898    (list "056" t_hl_56)
1899    (list "057" t_hl_57)
1900    (list "058" t_hl_58)
1901    (list "059" t_hl_59)
1902    (list "060" t_hl_60)
1903    (list "061" t_hl_61)
1904    (list "062" t_hl_62)
1905    (list "063" t_hl_63)
1906    (list "064" t_hl_64)
1907    (list "065" t_hl_65)
1908    (list "066" t_hl_66)
1909    (list "067" t_hl_67)
1910    (list "068" t_hl_68)
1911    (list "069" t_hl_69)
1912    (list "070" t_hl_70)
1913    (list "071" t_hl_71)
1914    (list "072" t_hl_72)
1915    (list "073" t_hl_73)
1916    (list "074" t_hl_74)
1917    (list "075" t_hl_75)
1918    (list "076" t_hl_76)
1919    (list "077" t_hl_77)
1920    (list "078" t_hl_78)
1921    (list "079" t_hl_79)
1922    (list "080" t_hl_80)
1923    (list "081" t_hl_81)
1924    (list "082" t_hl_82)
1925    (list "083" t_hl_83)
1926    (list "084" t_hl_84)
1927    (list "085" t_hl_85)
1928    (list "086" t_hl_86)
1929    (list "087" t_hl_87)
1930    (list "088" t_hl_88)
1931    (list "089" t_hl_89)
1932    (list "090" t_hl_90)
1933    (list "091" t_hl_91)
1934    (list "092" t_hl_92)
1935    (list "093" t_hl_93)
1936    (list "094" t_hl_94)
1937    (list "095" t_hl_95)
1938    (list "096" t_hl_96)
1939    (list "097" t_hl_97)
1940    (list "098" t_hl_98)
1941    (list "099" t_hl_99)
1942    (list "100" t_hl_100)
1943    (list "101" t_hl_101)
1944    (list "102" t_hl_102)
1945    (list "103" t_hl_103)
1946    (list "104" t_hl_104)
1947    (list "105" t_hl_105)
1948    (list "106" t_hl_106)
1949    (list "107" t_hl_107)
1950    (list "108" t_hl_108)
1951    (list "109" t_hl_109)
1952    (list "110" t_hl_110)
1953    (list "111" t_hl_111)
1954    (list "112" t_hl_112)
1955    (list "113" t_hl_113)
1956
1957    (list "fg" t_gf_nw)
1958    (list "fh" t_gf_n )
1959    (list "fi" t_gf_ne)
1960    (list "fj" t_gf_w )
1961    (list "fk" t_gf_c )
1962    (list "fl" t_gf_e )
1963    (list "fm" t_gf_sw)
1964    (list "fn" t_gf_s )
1965    (list "fo" t_gf_se)
1966  )
1967) ;; palette pal_expanded
1968
1969;;----------------------------------------------------------------------------
1970;; Places
1971;;----------------------------------------------------------------------------
1972(kern-mk-map
1973 'm_demo_scene 19 19 pal_expanded
1974
1975	(list
1976		"000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 "
1977		"019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 "
1978		"038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 "
1979		"057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 "
1980		"076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 "
1981		"095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 "
1982		"fg fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fh fi "
1983		"fj t. t. t# .. .. .. .. .. .. t% ta t. t. tc __ t. t. fl "
1984		"fj t. t# .. ar .. .. .. ar .. .. t% t. t. _3 _c t. t. fl "
1985		"fj t# .. .. .. .. .. .. .. .. .. .. ta tc _2 tG t. t. fl "
1986		"fj .. ar .. .. .. .. .. .. .. ar .. .. .. __ .. .. .. fl "
1987		"fj .. .. .. .. dd dd dd .. .. .. .. dd ee ee ee dd dd fl "
1988		"fj .. .. .. dd dd {f dd dd dd dd dd dd ee ee ee dd dd fl "
1989		"fj .. .. .. .. dd dd dd .. .. .. .. dd ee ee ee dd dd fl "
1990		"fj .. ar .. .. .. .. .. .. .. ar .. .. .. __ .. .. .. fl "
1991		"fj tA .. .. .. .. .. .. .. .. .. .. t3 t5 _2 tJ t. t. fl "
1992		"fj t. tA .. ar .. .. .. ar .. .. tC t. t. _a _5 t. t. fl "
1993		"fj t. t. tA .. .. .. .. .. .. tC t3 t. t. t5 __ t. t. fl "
1994		"fm fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fn fo "
1995	)
1996 )
1997
1998(kern-mk-place
1999 'p_demo_scene   ; tag
2000 "Demo Scene"    ; name
2001 nil             ; sprite
2002 m_demo_scene    ; map
2003 #f              ; wraps
2004 #f              ; underground
2005 #f              ; large-scale (wilderness)
2006 #f              ; tmp combat place
2007 nil             ; subplaces
2008 nil             ; neighbors
2009
2010 (list ; objects
2011 (put (guard-pt 'halberdier)   15 10)
2012 (put (guard-pt 'halberdier)   15 14)
2013 (put (guard-pt 'crossbowman) 13 10)
2014 (put (guard-pt 'crossbowman) 13 14)
2015 (put (mk-monman) 0 0)
2016 (put (mk-scene-mgr) 0 0)
2017 (put (kern-tag 'portal (kern-mk-obj t_portal 1)) 6  12)
2018 )
2019 (list 'on-entry-to-dungeon-room) ; hooks
2020 nil ;; edge entrances
2021)
2022
2023;;----------------------------------------------------------------------------
2024;; Characters
2025;;
2026;; Make an invisible, passive character for the player party, because there has
2027;; to be a player party to get the camera on the scene, and the player party
2028;; has to have at least one living member. Yes, this is a blatant hack.
2029;;----------------------------------------------------------------------------
2030
2031(define (passive-ai kchar)
2032	(kern-char-set-hp kchar max-health) ; functionally immortal, in case of stray fireballs
2033	(kern-map-repaint)
2034	(kern-sleep 75)
2035      #t)
2036
2037(let ((kchar (kern-mk-char
2038              'ch_wanderer
2039              "John the Mute"       ; name
2040              sp_human              ; species
2041              oc_wanderer           ; occ
2042              s_beggar    ; sprite
2043              faction-player        ; starting alignment
2044              5 5 5                ; str/int/dex
2045              9999							; functionally immortal, in case of stray fireballs
2046              pc-hp-gain
2047              pc-mp-off
2048              pc-mp-gain
2049              max-health 0 max-health 0 1  ; hp/xp/mp/AP_per_turn/lvl
2050              #f                    ; dead
2051              nil                   ; conv
2052              nil                   ; sched
2053              'passive-ai           ; special ai
2054              nil                   ; container
2055              nil                   ; readied
2056              )))
2057  (kern-char-set-ai kchar 'passive-ai)
2058  )
2059
2060;;----------------------------------------------------------------------------
2061;; Player Party
2062;;----------------------------------------------------------------------------
2063(kern-mk-player
2064 'player                     ; tag
2065 s_wanderer         ; sprite
2066 "Walk"                      ; movement description
2067 sound-walking               ; movement sound
2068 1                           ; food
2069 0                           ; gold
2070 (* 60 60 5)                 ; turns to next meal (5 hours)
2071 nil                         ; formation
2072 nil                         ; campsite map
2073 nil                         ; campsite formation
2074 nil                         ; vehicle
2075 ;; inventory
2076 (kern-mk-inventory nil)
2077 nil ;; party members (should be nil for initial load file)
2078 )
2079
2080(kern-party-add-member player ch_wanderer)
2081
2082;;----------------------------------------------------------------------------
2083;; Astronomy
2084;;----------------------------------------------------------------------------
2085(kern-mk-astral-body
2086 'sun              ; tag
2087 "Fyer (the sun)"  ; name
2088 1                 ; relative astronomical distance
2089 1                 ; minutes per phase (n/a for sun)
2090 (/ (* 24 60) 360) ; minutes per degree
2091 0                 ; initial arc
2092 0                 ; initial phase
2093 '()               ; script interface
2094 ;; phases:
2095 (list
2096  (list s_sun 255 "full")
2097  )
2098 )
2099
2100;;----------------------------------------------------------------------------
2101;; Lumis is the source gate, which means it opens the source moongates on its
2102;; phases. We designate this by using the source-moon-ifc as its ifc.
2103;;
2104;; Note: the arc and phase are calculated to give the moon the right orientation
2105;; with respect to phase vs sun position
2106;;----------------------------------------------------------------------------
2107(mk-moon 'lumis  ; tag
2108         "Lumis" ; name
2109         5       ; hours per phase
2110         60      ; hours per revolution
2111         22      ; initial arc
2112         0       ; initial phase
2113         'source-moon-ifc ; ifc
2114         ;; gates (moons are fixed at 8 phases in mk-moon):
2115         (list 'mg-1 'mg-2 'mg-3 'mg-4
2116               'mg-5 'mg-6 'mg-7 'mg-8
2117               )
2118         "yellow")
2119
2120;;----------------------------------------------------------------------------
2121;; Ord is the destination gate, which means its phase decides the destination
2122;; when the player steps through a moongate. We designate this by giving it a
2123;; nil ifc. Note that its gates do not need to be listed in the same order as
2124;; Lumis. In fact, they don't even need to be the same set of gates.
2125;;
2126;; Note: the arc and phase are calculated to give the moon the right orientation
2127;; with respect to phase vs sun position
2128;;----------------------------------------------------------------------------
2129(mk-moon 'ord    ; tag
2130         "Ord"   ; name
2131         9       ; hours per phase
2132         36      ; hours per revolution
2133         67     ; initial arc
2134         7       ; initial phase
2135         nil     ; ifc
2136         ;; gates (moons are fixed at 8 phases in mk-moon):
2137         (list 'mg-1 'mg-2 'mg-3 'mg-4
2138               'mg-5 'mg-6 'mg-7 'mg-8
2139               )
2140         "blue")
2141
2142;; ----------------------------------------------------------------------------
2143;; The diplomacy table. Each entry defines the attitude of the row to the
2144;; column. Note that attitudes are not necessarily symmetric. Negative values
2145;; are hostile, positive are friendly.
2146;;
2147;; Note: factions should always be allied with themselves in order for
2148;; summoning AI to work properly.
2149;;
2150;; Formatted for spreadsheet
2151;; ----------------------------------------------------------------------------
2152(kern-mk-dtable
2153	;;	non	pla	men	cgb	acc	mon	tro	spd	out	gnt	dem	fgb	prs
2154	(list	2	0	0	0	-1	-2	-2	-2	0	-2	-2	0	0	)	;;	none
2155	(list	0	2	2	-1	-2	-2	-2	-2	-2	2	-2	-2	2	)	;;	player
2156	(list	-1	2	2	-1	-2	-2	-2	-2	-2	-2	-2	-2	2	)	;;	men
2157	(list	-1	2	-2	2	-1	-2	0	-2	-2	-1	-2	-2	0	)	;;	cave goblin
2158	(list	-1	2	-1	-1	2	-2	-1	-1	-2	-1	-2	-2	0	)	;;	accursed
2159	(list	-2	2	-2	-2	-2	2	-2	0	-2	0	-2	0	0	)	;;	monsters
2160	(list	-2	2	-2	0	-1	-2	2	-2	-2	-1	-2	-1	0	)	;;	hill trolls
2161	(list	-2	2	-2	-2	-1	0	-2	2	-2	-1	-2	0	0	)	;;	wood spiders
2162	(list	0	2	-2	-2	-2	-2	-2	-2	2	-2	-2	-1	0	)	;;	outlaws
2163	(list	-2	2	-2	-1	-1	0	-1	-1	-2	2	-2	-1	0	)	;;	gint
2164	(list	-2	2	-2	-2	-2	-2	-2	-2	-2	-2	2	-2	0	)	;;	demon
2165	(list	0	2	-2	-2	-2	0	-2	0	-1	-1	-2	2	0	)	;;	forest goblin
2166	(list	0	2	2	0	0	0	0	0	0	0	0	0	2	)	;;	prisoners
2167)
2168
2169(define (simple-start kplayer)
2170  (kern-obj-put-at kplayer (list p_demo_scene (+ xoff 14)  (+ yoff 3)))
2171	(kern-map-center-camera (mk-loc p_demo_scene (+ xoff 10)  (+ yoff 5)))
2172
2173        (kern-char-set-control-mode ch_wanderer "auto")
2174
2175  ;; Do this to initialize the map viewer's active view, and to replace the
2176  ;; splash screen with the scene.
2177  (kern-map-repaint)
2178  )
2179
2180(kern-add-hook 'new_game_start_hook 'simple-start)
2181