1;;----------------------------------------------------------------------------
2;; Constants
3;;----------------------------------------------------------------------------
4
5;; This file loads 58 files
6
7;; Toggle handling for quests
8(define use-quest-pane #t)
9
10;; Slots
11(define slot-nil              0)
12(define slot-amulet           1)
13(define slot-ring             2)
14(define slot-gazer-helm       4)
15(define slot-weapon           8)
16(define slot-shield           8)
17(define slot-weapon-or-shield 8)
18(define slot-armor            16)
19(define slot-boot             32)
20(define slot-helm             64)
21
22;; Speeds  ;; TODO: move most of these into kern-intvars ?
23
24(define speed-human             50)  ;; typical AP/round for humans
25
26(define base-move-ap		50)  ;; this may not bear a neat relationship to speed-human
27(define default-weapon-rap      50)  ;; this may not bear a neat relationship to speed-human
28(define default-armour-apmod    2)  ;; this may not bear a neat relationship to speed-human
29
30(define base-skill-ap			base-move-ap)  ;; this may not bear a neat relationship to speed-human
31(define base-spell-ap			base-move-ap)  ;; this may not bear a neat relationship to speed-human
32
33;; AP costs of various actions which the kernal needs to know about:
34(kern-set-kern-intvar "AP_TOTAL:normal_human"    speed-human)
35
36(kern-set-kern-intvar "AP_COST:default"           speed-human)
37(kern-set-kern-intvar "AP_COST:search"            (* 3 speed-human))
38(kern-set-kern-intvar "AP_COST:get_item"          (* 0.34 speed-human))
39(kern-set-kern-intvar "AP_COST:drop_item"         (* 0.34 speed-human))
40(kern-set-kern-intvar "AP_COST:open_mechanism"    speed-human)
41(kern-set-kern-intvar "AP_COST:open_container"    speed-human)
42(kern-set-kern-intvar "AP_COST:handle_mechanism"  speed-human)
43(kern-set-kern-intvar "AP_COST:use_item"          speed-human)  ;; may be unused, per comment in cmd.c cmdUse()
44
45;; Normal mixing: 18 + (num_mixed * 12) + (spell_level * 12) AP
46(kern-set-kern-intvar "AP_COST:mix_reagents_base"         (* 3 speed-human))
47(kern-set-kern-intvar "AP_COST:mix_reagents_per_mix"      (* 2 speed-human))
48(kern-set-kern-intvar "AP_COST:mix_reagents_per_level"    (* 2 speed-human))
49;; Attempt at non-existent spell: 3d18+6 AP
50(kern-set-kern-intvar "AP_COST:mix_reagents_nospell_num"   3)
51(kern-set-kern-intvar "AP_COST:mix_reagents_nospell_dice" (* 3 speed-human))
52(kern-set-kern-intvar "AP_COST:mix_reagents_nospell_plus"  speed-human)
53;; Missing or additional ingredients: (2 * spell_level)d18+18 AP
54(kern-set-kern-intvar "AP_COST:mix_reagents_badmix_num"    2)  ;; times spell Level
55(kern-set-kern-intvar "AP_COST:mix_reagents_badmix_dice"  (* 3 speed-human))
56(kern-set-kern-intvar "AP_COST:mix_reagents_badmix_plus"  (* 3 speed-human))
57
58;; These values are used by ctrl.c ctrl_attack_target()
59;; to adjust weapon AP costs in the event of dual wielding.
60;; The dual weapon rules can thus be tweaked here...
61(kern-set-kern-intvar "AP_MULT12:second_wpn_attack"       6)  ;; AP cost * 6/12 for 2nd weapon attack if dual wpns used
62(kern-set-kern-intvar "AP_MULT12:third_plus_wpn_attack"   6)  ;; AP cost * 6/12 for 3rd+ weapon attacks, if 3+ weapons used
63(kern-set-kern-intvar "AP_THRESHOLD:multi_attack_overage" 0)  ;; attack sequence can continue if AP overage is not > 0
64
65(kern-set-kern-intvar "submerged_def_bonus" 10) ;; defense bonus for submerged critters
66
67;; ship speeds are better handled using mmodes/pclasses-
68;; it should only affect actual movement
69(define speed-ship            speed-human)
70
71;; Action Point costs for various basic actions:
72;; are these used anywhere?
73;;(define ap-for-1H-melee-attack   9)
74;;(define ap-for-2H-melee-attack  12)
75
76;;(define ap-for-1H-thrown-attack 12)
77;;(define ap-for-2H-thrown-attack 18)
78
79;;(define ap-for-shooting-attack  12)
80
81;;(define ap-for-combat-spell      9)
82;;(define ap-to-use-scroll        12)
83
84
85;; Difficulty Classes. "Normal" means an L5 professional with key attribute at
86;; 16 will succeed 50% of the time. For example, an L5 wrogue with 16 dexterity
87;; will have a thiefly ability of 10. This person should be able to pick a
88;; normal lock 50% of the time (remember, he gets to retry with no penalty
89;; except mana loss and maybe breaking a pick on critical failure).
90;;
91;; 1d10 + 1d20 = 5.5 + 10.5 = 16
92;;
93;; For the most difficult things, an L9 professional wrogue with an unusually
94;; strong key attribute of 30 will have an ability rating of 19, and should
95;; only succeed on two perfect rolls:
96;;
97;; 19 + 20 = 39
98;;
99;; Caveat: for abilities other than wrogues (eg, magic or strength-based
100;; abilities), the relationship between ability level, key attribute and
101;; advancement level is different (in fact, it's different in each case, see
102;; occs.scm).
103(define dc-trivial        3) ;; >98%
104(define dc-easy           6) ;; >90%
105(define dc-nontrivial     10) ;; >75%
106(define dc-normal         15) ;; >50%
107(define dc-challenging    26) ;; 5%
108(define dc-hard           28) ;; <2%
109(define dc-masterful      30) ;; just impossible at L5,DEX=16
110(define dc-supremely-hard 38) ;; perfect roll at high levels
111
112(define dc-escape-ensnare  dc-challenging)
113(define dc-escape-paralyze dc-normal)
114(define dc-avoid-stuck     dc-hard)
115(define dc-escape-stuck    dc-hard)
116(define dc-reach           dc-hard)
117
118;; Pmasks (keep them around until mechs are converted to use passability
119;; classes (see below))
120(define pmask-none   0)
121(define pmask-solid  1)
122(define pmask-land   2)
123(define pmask-water  4)
124(define pmask-shoals 8)
125(define pmask-bridge (+ pmask-land pmask-water pmask-shoals))
126(define pmask-all    (+ pmask-solid pmask-land pmask-water pmask-shoals))
127
128;; Passability Difficulty Levels
129;;   (Note: 255 is well-known to the kernel to mean
130;;   "impassible" in the case of movement costs)
131(define fast        (* 0.66 base-move-ap))  ;; 0.66 (2/3)
132(define s-fast      (* 0.8 base-move-ap))  ;; 'slightly fast' 0.8
133(define norm        base-move-ap)  ;; 1.0
134(define s-hard      (* 1.5 base-move-ap))  ;; 1.5
135(define hard       (* 2 base-move-ap))  ;; 2.0
136(define v-hard     (* 3 base-move-ap))  ;; 3.0
137
138(define no-drop    100)  ;; special, used for dropability (not related to speed-human)
139(define cant      255)  ;; special
140
141;; Passability classes
142(define pclass-none          0)
143(define pclass-grass         1)
144(define pclass-deep          2)
145(define pclass-shoals        3)
146(define pclass-mountains     4) ;; no ceiling
147(define pclass-wall          5) ;; has a ceiling
148(define pclass-trees         6)
149(define pclass-forest        7)
150(define pclass-hills         8)
151(define pclass-repel         9) ;; energy shield blocks all
152(define pclass-space         10)
153(define pclass-bridge        pclass-grass)
154(define pclass-road          pclass-grass)
155(define pclass-boulder       11) ;; no ceiling, smaller than mountain
156(define pclass-waterboulder  12) ;; worst case of boulder and water
157(define pclass-sludge        13)
158(define pclass-shallows      14)
159(define pclass-bars          15) ;; portcullis
160(define pclass-window        16) ;; separating from bars for shoot-but-not-crawl-through passability
161(define pclass-vmountains    17)
162(define pclass-canfloat      18) ;; avoids drowning
163(define pclass-canfly        19) ;; avoids ground based issues
164
165;; Movement modes
166(define mmodes
167  (list
168   (list 'mmode-walk      "walking"     0)
169   (list 'mmode-hover     "hovering"    1)
170   (list 'mmode-ship      "sailing"     2)
171   (list 'mmode-phase     "phasing"     3)
172   (list 'mmode-fly       "flying"      4)
173   (list 'mmode-skiff     "rowing"      5)
174   (list 'mmode-fish      "swimming"    6)
175   (list 'mmode-crawl     "crawling"    7) ;; spiders, can cross boulders
176   (list 'mmode-voidship  "sailing"     8)
177   (list 'mmode-ranger    "stalking"    9)
178   (list 'mmode-none      "stationary" 10)
179   (list 'mmode-wriggle   "wriggle"    11) ;; rogue special move
180   (list 'mmode-missile   "missile"    12)
181   (list 'mmode-fastfly   "flying"     13)
182   (list 'mmode-fastrun   "running"    14)
183   (list 'mmode-fastcrawl "crawling"   15)
184   (list 'mmode-smallobj  "smallobj"   16) ;; for determining dropability of small objects
185   (list 'mmode-largeobj  "largeobj"   17) ;; for determining dropability of big objects- basically, stuff that wont fit through bars/windows
186   (list 'mmode-field     "field"      18) ;; for determining dropability of fields
187   (list 'mmode-return    "return"     19) ;; return path for magic axe (for now assume it always returns)
188   (list 'mmode-cannon    "cannon"     20) ;; enhanced missile passibility for cannon shells
189   (list 'mmode-large     "striding"   21) ;; big critters
190))
191(map (lambda (mmode) (apply kern-mk-mmode mmode)) mmodes)
192
193(define mmode-jump mmode-fly)
194
195;; Movement cost table (optimized for cut to/paste from spreadsheet!)
196(kern-mk-ptable
197	;;	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
198	(list	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	)	;; none
199	(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
200	(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
201	(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
202	(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
203	(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)
204	(list	hard	hard	cant	norm	norm	cant	cant	hard	cant	norm	cant	hard	10	fast	norm	norm	norm	norm	norm	0	7	hard	)	;; trees
205	(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
206	(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
207	(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
208	(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
209	(list	cant	norm	cant	norm	norm	cant	cant	hard	cant	cant	cant	hard	10	fast	cant	norm	norm	norm	norm	0	4	norm	)	;; boulder
210	(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
211	(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
212	(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
213	(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)
214	(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
215	(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
216	(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
217	(list	cant	hard	cant	cant	norm	hard	cant	cant	norm	cant	cant	cant	norm	norm	cant	cant	cant	cant	norm	norm	norm	cant	)	;; fly
218)
219;; Note that pclass 'missl' is using the value as a percentage chance
220;; for a missile to be blocked by obscuring terrain, not as an AP cost
221
222
223;; Factions. The diplomacy table (which defines the relationship between
224;; factions) must be defined in the session file, because it changes over time.
225(define faction-none          0)
226(define faction-player        1)
227(define faction-men           2)
228(define faction-cave-goblin   3)
229(define faction-accursed      4)
230(define faction-monster       5)
231(define faction-troll         6)
232(define faction-spider        7)
233(define faction-outlaw        8)
234(define faction-gint          9)
235(define faction-demon         10)
236(define faction-forest-goblin 11)
237(define faction-green-tower   faction-men)
238(define faction-oparine       faction-men)
239(define faction-trigrave      faction-men)
240(define faction-nixie         faction-monster)
241(define faction-prisoner      12)
242(define faction-glasdrin      13) ;; must be separate from men, or exile by statue will affect player with all towns
243(define faction-num           14)
244
245;; Layers (must match object.h)
246(define layer-none       0)
247(define layer-tfeat      1)
248(define layer-mechanism  2)
249(define layer-portal     3)
250(define layer-vehicle    4)
251(define layer-bed        5)
252(define layer-container  6)
253(define layer-item       7)
254(define layer-field      8)
255(define layer-being      9)
256(define layer-projectile 10)
257(define layer-crosshair  11)
258
259;; Contexts
260(define context-world 1)
261(define context-town  2)
262(define context-any      (+ context-town context-world))
263
264;; Damage/Immunity types (ordinal, not bitmasks)
265(define damage-none   0)
266(define damage-fire   1)
267(define damage-poison 2)
268(define damage-sleep  3)
269
270;; Damage amounts
271(define lava-damage 10)
272
273;; Directions (as returned by kern-ui-get-direction)
274(define northwest 0)
275(define north     1)
276(define northeast 2)
277(define west      3)
278(define here      4)
279(define east      5)
280(define southwest 6)
281(define south     7)
282(define southeast 8)
283(define up        9)
284(define down      10)
285
286;; Scroll directions (for UI keyhandling, must match kernel's StatusScrollDir)
287(define scroll-up       0)
288(define scroll-down     1)
289(define scroll-right    2)
290(define scroll-left     3)
291(define scroll-pageup   4)
292(define scroll-pagedown 5)
293(define scroll-top      6)
294(define scroll-bottom   7)
295
296(define opposite-dir (vector southeast south southwest
297                             east here west
298                             northeast north northwest
299                             down up))
300
301;; Player character bonuses
302(define pc-hp-off  25)
303(define pc-hp-gain 5)
304(define pc-mp-off  1)
305(define pc-mp-gain 1)
306
307;; NPC activities
308(define (isdrunk? knpc)
309  (string=? "drunk" (kern-obj-get-activity knpc)))
310(define (isworking? knpc)
311  (string=? "working" (kern-obj-get-activity knpc)))
312
313;; Prices
314(define base-scroll-cost 20) ;; gold pieces per level of scroll's spell
315(define reagent-price-mult 1) ;; global reagent price multiplier
316
317;; rather than trying to calculate appropriate hp/mp for
318;; characters, stick in a big number and let Character::new
319;; trim it as needed
320(define max-health 999999999)
321
322;; Some of the following are order-dependent
323(load "loc.scm")
324(load "kobj.scm")
325(load "ifc.scm")
326(load "sprite-sets.scm")
327(load "sprites.scm")
328(load "sounds.scm")
329(load "effects.scm")
330(load "terrains.scm")
331(load "palette.scm")
332(load "fields.scm")
333(load "combat-maps.scm")
334
335;; Object types
336(load "objs.scm")
337(load "traps.scm")
338(load "pitfalls.scm")
339(load "landslide.scm")
340(load "containers.scm")
341(load "reagents.scm")
342(load "food.scm")
343(load "arms.scm")
344(load "powers.scm")
345(load "ability.scm")
346(load "cast-ui.scm")
347(load "spells.scm")
348(load "items.scm")
349(load "vehicles.scm")
350(load "beds.scm")
351(load "money.scm")
352(load "skills.scm")
353(load "occs.scm")
354(load "ai.scm")
355(load "species.scm")
356(load "conv.scm") ;; basic conversation
357(load "yellow-slime.scm")
358(load "troll.scm")
359(load "spider.scm")
360(load "npc-types.scm")
361(load "mimic.scm")
362(load "parties.scm")
363(load "jewelry.scm")
364(load "gate-guard.scm")
365
366;; Mechanism-like things
367(load "bim.scm")
368(load "step.scm")
369(load "monster-generator.scm")
370;;(load "wilderness-manager.scm")
371(load "terrain-to-ptype.scm")
372(load "edge-spawn.scm")
373(load "door.scm")
374(load "portcullis.scm")
375(load "hidden.scm")
376(load "lever.scm")
377(load "timer.scm")
378(load "tblit.scm")
379(load "portals.scm")
380(load "moongate.scm")
381(load "bridge.scm")
382(load "drawbridge.scm")
383(load "weather-vane.scm")
384(load "wind-bridge.scm")
385
386;; Astronomy
387(load "moon.scm")
388
389;; Quest system
390(load "tbl.scm")
391(load "ztats-quest-ui.scm")
392(load "quest-sys.scm")
393
394;; Miscellaneous crap
395(mk-obj-type 't_crosshair "crosshair" s_crosshair layer-crosshair nil)
396(kern-set-crosshair t_crosshair)
397(kern-set-frame s_frame_ulc
398                s_frame_urc
399                s_frame_llc
400                s_frame_lrc
401                s_frame_td
402                s_frame_tu
403                s_frame_tl
404                s_frame_tr
405                s_null
406                s_frame_horz
407                s_frame_vert
408                s_frame_endl
409                s_frame_endr)
410(kern-set-ascii ss_u4_charset 32)
411(kern-set-cursor ls_whirlpool)
412(kern-set-damage-sprite s_hit)
413(kern-add-query 'str_based_attack_query proc-stratt)
414(kern-add-query 'dex_based_attack_query proc-dexatt)
415(kern-add-query 'damage_bonus_query proc-stratt)
416(kern-add-query 'defense_bonus_query proc-dexdef)
417(kern-add-hook 'combat_change_hook 'music-on-combat-change)
418(kern-add-hook 'session_start_hook 'music-on-combat-change)
419
420;; Setup the global effect sprites
421(kern-set-quicken-sprite s_quicken)
422(kern-set-time-stop-sprite s_time_stop)
423(kern-set-magic-negated-sprite s_magic_negated)
424(kern-set-reveal-sprite s_reveal)
425(kern-set-xray-vision-sprite s_xray_vision)
426
427(kern-init-random)
428
429