1 ;; ----------------------------------------------------------------------------
2 ;; Set the list of magic syllables we'll use in our game. The kernel sets a max
3 ;; limit of 26 (one for each letter of the alphabet) largely for reasons I am
4 ;; not willing to address at this point.
5 ;; ----------------------------------------------------------------------------
7 (kern-set-spell-words "An(¥¢¥ó)"
34 ;; ----------------------------------------------------------------------------
35 ;; The only purpose of this list is to prevent the scheme gc from harvesting
36 ;; the spell interfaces which are created on-the-fly in mk-spell. Without this
37 ;; I'd have to explicitly assign a variable to each ifc, which is needlessly
39 ;; ----------------------------------------------------------------------------
41 (define spell-ifcs '())
43 ;; ----------------------------------------------------------------------------
44 ;; mk-spell creates a spell interface on the fly, puts it on the spell-ifcs to
45 ;; prevent the gc from getting it, registers a new object type for the spell
46 ;; with the kernel, and then adds it to the list of spells known to the kernel.
47 ;; ----------------------------------------------------------------------------
48 (define (mk-spell tag name cast-handler magic-words level context sprite
50 (let ((spell-ifc (ifc obj-ifc (method 'cast cast-handler))))
51 (set! spell-ifcs (cons spell-ifc spell-ifcs))
52 (kern-add-spell (mk-obj-type tag name nil layer-none spell-ifc)
57 (/ (* (+ level 1) base-spell-ap) 2) ;; action point cost
58 sprite ;; sprite (FIXME)
64 ;; ============================================================================
66 ;; ============================================================================
68 (define (get-line origin dir n)
69 ;;(println " get-line:" origin "," dir "," n)
75 (get-line (loc-offset origin dir) dir (- n 1))))))
77 (define (get-cone-vert origin depth dy)
78 ;;(println " get-cone-vert:" origin "," depth "," dy)
79 (let ((place (loc-place origin)))
80 (define (get-lines x y n h)
81 ;;(println " get-lines:" x "," y "," n "," h)
83 (let ((line (filter (lambda (a) (and (kern-in-los? origin a)
84 (kern-is-valid-location? a)
85 (terrain-ok-for-field? a)))
86 (get-line (mk-loc place x y) east n))))
87 ;;(println " line:" line)
89 (get-lines (if (= x 0) 0 (- x 1))
91 (+ n (if (= x 0) 1 2))
93 (get-lines (loc-x origin)
98 (define (get-cone-horz origin depth dx)
99 (let ((place (loc-place origin)))
100 (define (get-lines x y n h)
102 (cons (filter (lambda (a) (and (kern-in-los? origin a)
103 (kern-is-valid-location? a)
104 (terrain-ok-for-field? a)))
105 (get-line (mk-loc place x y) south n))
107 (if (= y 0) 0 (- y 1))
108 (+ n (if (= y 0) 1 2))
110 (get-lines (loc-x origin)
115 (define (get-cone origin depth dir)
116 ;;(println "get-cone:" origin "," depth "," dir)
117 (cond ((= dir north) (get-cone-vert origin
118 (min depth (loc-y origin))
120 ((= dir east) (get-cone-horz origin
122 (- (kern-place-get-width (loc-place origin))
125 ((= dir south) (get-cone-vert origin
127 (- (kern-place-get-height (loc-place origin))
130 ((= dir west) (get-cone-horz origin
131 (min depth (loc-x origin))
135 (define (cast-wind-spell origin proc field-type)
136 (let ((dir (ui-get-direction)))
139 (define (dropfield loc)
140 (if (kern-is-valid-location? loc)
141 (kern-obj-put-at (kern-mk-obj field-type 1) loc)))
142 (define (is-my-field? kobj) (eqv? field-type (kern-obj-get-type kobj)))
143 (define (rmfield loc)
144 (if (> (kern-dice-roll "2d20") 16)
145 (let ((fields (filter is-my-field? (kern-get-objects-at loc))))
146 (cond ((null? fields) nil)
148 (kern-obj-remove (car fields)))))))
149 (define (doline line)
151 (map proc (kern-get-objects-at loc)))
157 (let ((lines (get-cone origin 10 dir)))
158 (cond ((null? lines) nil)
160 (map doline (cdr lines))
161 (kern-map-repaint))))))))
164 ;; o has caller-limited depth
165 ;; o has caller-specified direction
166 ;; o applies caller-specified proc to each location
167 ;; (Note: currently used for the spider's web-spew "spell")
168 (define (cast-wind-spell2 origin proc dir depth)
169 ;;(println "cast-wind-spell2:" origin "," proc "," dir "," depth)
170 (define (dropfield loc)
171 (if (kern-is-valid-location? loc)
173 (define (doline line)
176 (let ((lines (get-cone origin depth dir)))
177 (cond ((null? lines) nil)
179 ;;(println " doing lines")
180 (map doline (cdr lines))
181 (kern-map-repaint)))))
184 ;;----------------------------------------------------------------------------
185 ;; Core actions behind spells, special abilities, etc. No UI prompting, no mana
186 ;; or level checking, no mana decrementing -- that all needs to be handled by
187 ;; the callers. All of these calls must return #t on success or #f on
188 ;; failure. No further details as to cause of failure are required.
189 ;;----------------------------------------------------------------------------
192 (define (resurrect kchar)
193 (kern-char-resurrect kchar)
196 ;; ----------------------------------------------------------------------------
197 ;; All the spell cast handlers are listed here. These are the procedures that
198 ;; get called whenever a spell is cast.
199 ;; ----------------------------------------------------------------------------
201 (define (cast-on-party-member spell)
202 (let ((ktarg (kern-ui-select-party-member)))
210 ;;----------------------------------------------------------------------------
212 ;;----------------------------------------------------------------------------
213 (define (spell-name spell) (cadr spell))
214 (define (spell-handler spell) (caddr spell))
215 (define (spell-level spell) (list-ref spell 4))
216 (define (spell-cost spell) (spell-level spell))
217 (define (spell-ap spell) (spell-level spell))
219 ;; ----------------------------------------------------------------------------
220 ;; This is the table of spells.
221 ;; ----------------------------------------------------------------------------
224 (kern-mk-sprite-set 'ss_spells 32 32 8 8 0 0 "spells.png")
226 (define (mk-sprite tag offset)
227 (kern-mk-sprite tag ss_spells 1 offset #f 0))
229 (mk-sprite 's_an_nox 0)
230 (mk-sprite 's_an_zu 1)
231 (mk-sprite 's_grav_por 2)
232 (mk-sprite 's_in_lor 3)
233 (mk-sprite 's_mani 4)
234 (mk-sprite 's_wis_sanct 5)
235 (mk-sprite 's_an_sanct_ylem 6)
236 (mk-sprite 's_ylem_an_ex 7)
237 (mk-sprite 's_sanct_nox 8)
238 (mk-sprite 's_an_sanct 9)
239 (mk-sprite 's_sanct 10)
240 (mk-sprite 's_an_xen_corp 11)
241 (mk-sprite 's_in_wis 12)
242 (mk-sprite 's_kal_xen 13)
243 (mk-sprite 's_rel_hur 14)
244 (mk-sprite 's_in_nox_por 15)
245 (mk-sprite 's_an_xen_bet 16)
246 (mk-sprite 's_bet_flam_hur 17)
247 (mk-sprite 's_in_flam_grav 18)
248 (mk-sprite 's_in_nox_grav 19)
249 (mk-sprite 's_in_zu_grav 20)
250 (mk-sprite 's_vas_flam 21)
251 (mk-sprite 's_vas_lor 22)
252 (mk-sprite 's_in_flam_sanct 23)
253 (mk-sprite 's_an_grav 24)
254 (mk-sprite 's_in_sanct_grav 25)
255 (mk-sprite 's_in_sanct 26)
256 (mk-sprite 's_wis_quas 27)
257 (mk-sprite 's_bet_por 28)
258 (mk-sprite 's_vas_sanct_nox 29)
259 (mk-sprite 's_in_ex_por 30)
260 (mk-sprite 's_an_ex_por 31)
261 (mk-sprite 's_in_bet_xen 32)
262 (mk-sprite 's_in_zu 33)
263 (mk-sprite 's_vas_mani 34)
264 (mk-sprite 's_rel_tym 35)
265 (mk-sprite 's_in_an 36)
266 (mk-sprite 's_wis_an_ylem 37)
267 (mk-sprite 's_an_xen_ex 38)
268 (mk-sprite 's_in_vas_por_ylem 39)
269 (mk-sprite 's_quas_an_wis 40)
270 (mk-sprite 's_vas_uus_ylem 41)
271 (mk-sprite 's_in_rel_por 42)
272 (mk-sprite 's_vas_por 43)
273 (mk-sprite 's_in_nox_hur 44)
274 (mk-sprite 's_in_zu_hur 45)
275 (mk-sprite 's_in_quas_corp 46)
276 (mk-sprite 's_in_quas_wis 47)
277 (mk-sprite 's_sanct_lor 48)
278 (mk-sprite 's_xen_corp 49)
279 (mk-sprite 's_in_quas_xen 50)
280 (mk-sprite 's_kal_xen_nox 51)
281 (mk-sprite 's_in_flam_hur 52)
282 (mk-sprite 's_in_vas_grav_corp 53)
283 (mk-sprite 's_an_tym 54)
284 (mk-sprite 's_kal_xen_corp 55)
285 (mk-sprite 's_in_mani_corp 56)
286 (mk-sprite 's_vas_rel_por 57)
287 (mk-sprite 's_vas_an_nox 58)
288 (mk-sprite 's_ort_grav 59)
289 (mk-sprite 's_bet_ylem_hur 60)
290 (mk-sprite 's_rel_xen_quas 61)
292 ;; ----------------------------------------------------------------------------
293 ;; Now rip through the list of spells, adding them to the kernel.
294 ;; ----------------------------------------------------------------------------
296 ;; tag name handler code L context sprite mixture
297 ;; ========== ================================ ======= ==== = ========= ====== =======
299 (mk-spell 'an_nox "²òÆÇ <An Nox>" an-nox "AN" 1 context-any s_an_nox (list garlic ginseng))
300 (mk-spell 'an_zu "³ÐÀà <An Zu>" an-zu "AZ" 1 context-any s_an_zu (list garlic ginseng))
301 (mk-spell 'grav_por "ËâË¡¤ÎÌð <Grav Por>" grav-por "GP" 1 context-town s_grav_por (list sulphorous_ash black_pearl))
302 (mk-spell 'in_lor "¸÷ <In Lor>" in-lor "IL" 1 context-any s_in_lor (list sulphorous_ash))
303 (mk-spell 'mani "¾®²óÉü <Mani>" mani "M" 1 context-any s_mani (list ginseng spider_silk))
304 (mk-spell 'wis_sanct "æ«ÃµÃÎ <Wis Sanct>" wis-sanct "WS" 1 context-town s_wis_sanct (list sulphorous_ash))
305 (mk-spell 'an_sanct_ylem "櫲ò½ü <An Sanct Ylem>" an-sanct-ylem "ASY" 1 context-town s_an_sanct_ylem (list blood_moss))
306 (mk-spell 'ylem_an_ex "ÌÖ <Ylem An Ex>" ylem-an-ex "YAE" 1 context-town s_ylem_an_ex (list spider_silk black_pearl))
307 (mk-spell 'bet_ylem_hur "±ìËë <Bet Ylem Hur>" bet-ylem-hur "BYH" 1 context-town s_bet_ylem_hur (list sulphorous_ash))
310 (mk-spell 'sanct_nox "ÂÑÆÇ <Sanct Nox>" sanct-nox "SN" 2 context-any s_sanct_nox (list nightshade garlic t_royal_cape))
311 (mk-spell 'an_sanct "³«¾û <An Sanct>" an-sanct "AS" 2 context-town s_an_sanct (list sulphorous_ash blood_moss))
312 (mk-spell 'sanct "»Ü¾û <Sanct>" sanct "S" 2 context-town s_sanct (list sulphorous_ash spider_silk))
313 (mk-spell 'an_xen_corp "ÉÔ»à´Ô <An Xen Corp>" an-xen-corp "AXC" 2 context-town s_an_xen_corp (list garlic sulphorous_ash))
314 (mk-spell 'in_wis "°ÌÃÖ <In Wis>" in-wis "IW" 2 context-any s_in_wis (list nightshade))
315 (mk-spell 'in_bet_xen "Ã´Ô <In Bet Xen>" in-bet-xen "IBX" 2 context-town s_in_bet_xen (list spider_silk blood_moss sulphorous_ash))
316 (mk-spell 'rel_hur "É÷ÊѲ½ <Rel Hur>" rel-hur "RH" 2 context-any s_rel_hur (list sulphorous_ash blood_moss))
317 (mk-spell 'in_nox_por "ÆÇ·â <In Nox Por>" in-nox-por "INP" 2 context-town s_in_nox_por (list nightshade blood_moss black_pearl))
318 (mk-spell 'an_xen_bet "ÂÐÃØéá <An Xen Bet>" an-xen-bet "AXB" 2 context-town s_an_xen_bet (list spider_silk garlic))
319 (mk-spell 'bet_flam_hur "²Ð̸ <Bet Flam Hur>" bet-flam-hur "BFH" 2 context-town s_bet_flam_hur (list black_pearl sulphorous_ash blood_moss))
320 (mk-spell 'in_quas_wis "ÀéΤ´ã <In Quas Wis>" in-quas-wis "IQW" 2 context-any s_in_quas_wis (list nightshade mandrake))
321 (mk-spell 'xen_zu "ºÅ̲ <Xen Zu>" xen-zu "XZ" 2 context-town s_in_zu (list spider_silk ginseng))
324 (mk-spell 'in_flam_grav "²Ð±ê¾ì <In Flam Grav>" in-flam-grav "IFG" 3 context-town s_in_flam_grav (list sulphorous_ash black_pearl spider_silk))
325 (mk-spell 'in_nox_grav "ÆǾì <In Nox Grav>" in-nox-grav "ING" 3 context-town s_in_nox_grav (list nightshade black_pearl spider_silk))
326 (mk-spell 'in_zu_grav "ºÅ̲¾ì <In Zu Grav>" in-zu-grav "IZG" 3 context-town s_in_zu_grav (list ginseng black_pearl spider_silk))
327 (mk-spell 'vas_flam "²Ðµå <Vas Flam>" vas-flam "VF" 3 context-town s_vas_flam (list sulphorous_ash black_pearl))
328 (mk-spell 'vas_lor "¶¯¸÷ <Vas Lor>" vas-lor "VL" 3 context-any s_vas_lor (list mandrake sulphorous_ash))
329 (mk-spell 'in_flam_sanct "ÂѲР<In Flam Sanct>" in-flam-sanct "IFS" 3 context-any s_in_flam_sanct (list garlic sulphorous_ash t_royal_cape))
330 (mk-spell 'vas_an_nox "Á´²òÆÇ <Vas An Nox>" vas-an-nox "VAN" 3 context-any s_vas_an_nox (list mandrake garlic ginseng))
331 (mk-spell 'an_ort_xen "æËâË¡ <An Ort Xen>" an-ort-xen "AOX" 3 context-any s_in_an (list garlic mandrake sulphorous_ash))
334 (mk-spell 'an_grav "æËâË¡¾ì <An Grav>" an-grav "AG" 4 context-any s_an_grav (list black_pearl sulphorous_ash))
335 ;;(mk-spell 'uus_por "¾å¾º <Uus Por>" uus-por "UP" 4 context-any nil (list blood_moss spider_silk))
336 ;;(mk-spell 'des_por "²¼¹ß <Des Por>" des-por "DP" 4 context-any nil (list blood_moss spider_silk))
337 (mk-spell 'in_sanct_grav "¾ãÊÉ <In Sanct Grav>" in-sanct-grav "ISG" 4 context-town s_in_sanct_grav (list mandrake black_pearl spider_silk))
338 (mk-spell 'in_sanct "Êݸî <In Sanct>" in-sanct "IS" 4 context-any s_in_sanct (list sulphorous_ash ginseng garlic))
339 (mk-spell 'wis_quas "²Ä»ë <Wis Quas>" wis-quas "WQ" 4 context-any s_wis_quas (list nightshade sulphorous_ash))
340 (mk-spell 'bet_por "Ä·Ìö <Bet Por>" bet-por "BP" 4 context-town s_bet_por (list black_pearl blood_moss))
341 (mk-spell 'vas_sanct_nox "Á´ÂÑÆÇ <Vas Sanct Nox>" vas-sanct-nox "VSN" 3 context-any s_vas_sanct_nox (list mandrake nightshade garlic t_royal_cape))
342 (mk-spell 'ort_grav "Íë·â <Ort Grav>" ort-grav "OG" 1 context-town s_ort_grav (list black_pearl mandrake sulphorous_ash))
345 (mk-spell 'in_ex_por "Éõ°õ²ò½ü <In Ex Por>" in-ex-por "IEP" 5 context-any s_in_ex_por (list sulphorous_ash blood_moss))
346 (mk-spell 'an_ex_por "Éõ°õ <An Ex Por>" an-ex-por "AEP" 5 context-any s_an_ex_por (list sulphorous_ash blood_moss garlic))
347 (mk-spell 'in_zu "Á´ºÅ̲ <In Zu>" in-zu "IZ" 5 context-town s_in_zu (list nightshade spider_silk ginseng))
348 (mk-spell 'vas_mani "Âç²óÉü <Vas Mani>" vas-mani "VM" 5 context-any s_vas_mani (list mandrake spider_silk ginseng))
349 (mk-spell 'rel_tym "¹â®²½ <Rel Tym>" rel-tym "RT" 5 context-any s_rel_tym (list sulphorous_ash blood_moss mandrake))
350 (mk-spell 'kal_xen "½Ã¾¤´Ô <Kal Xen>" kal-xen "KX" 5 context-town s_kal_xen (list spider_silk mandrake))
351 (mk-spell 'rel_xen_quas "½Ã¸¸»ë <Rel Xen Quas>" rel-xen-quas "RXQ" 5 context-town s_rel_xen_quas (list nightshade blood_moss))
354 (mk-spell 'in_an "ÄÀÌÛ <In An>" in-an "IA" 6 context-any s_in_an (list garlic mandrake sulphorous_ash))
355 (mk-spell 'wis_an_ylem "Æ©»ë <Wis An Ylem>" wis-an-ylem "WAY" 6 context-any s_wis_an_ylem (list mandrake sulphorous_ash))
356 (mk-spell 'an_xen_ex "̥λ <An Xen Ex>" an-xen-ex "AXE" 6 context-town s_an_xen_ex (list black_pearl nightshade spider_silk))
357 (mk-spell 'in_vas_por_ylem "ÃÏ¿Ì <In Vas Por Ylem>" in-vas-por-ylem "IVPY" 6 context-town s_in_vas_por_ylem (list mandrake blood_moss sulphorous_ash))
358 (mk-spell 'quas_an_wis "º®Íð <Quas An Wis>" quas-an-wis "QAW" 6 context-town s_quas_an_wis (list mandrake nightshade))
359 (mk-spell 'vas_uus_ylem "°úÍÈ <Vas Uus Ylem>" vas-uus-ylem "VUY" 6 context-world s_vas_uus_ylem (list mandrake blood_moss spider_silk))
360 (mk-spell 'in_rel_por "Ç°ÎÏ <In Rel Por>" in-rel-por "IRP" 6 context-town s_in_rel_por (list black_pearl blood_moss spider_silk))
361 (mk-spell 'vas_por "½Ö´Ö°ÜÆ° <Vas Por>" vas-por "VP" 6 context-world s_vas_por (list mandrake black_pearl blood_moss))
364 (mk-spell 'in_nox_hur "ÆÇÉ÷ <In Nox Hur>" in-nox-hur "INH" 7 context-town s_in_nox_hur (list nightshade sulphorous_ash blood_moss))
365 (mk-spell 'in_zu_hur "ºÅ̲É÷ <In Zu Hur>" in-zu-hur "IZH" 7 context-town s_in_zu_hur (list mandrake ginseng blood_moss))
366 (mk-spell 'in_quas_corp "¶²ÉÝ <In Quas Corp>" in-quas-corp "IQC" 7 context-town s_in_quas_corp (list nightshade mandrake garlic))
367 (mk-spell 'sanct_lor "ÉԲĻë <Sanct Lor>" sanct-lor "SL" 7 context-any s_sanct_lor (list nightshade mandrake blood_moss))
368 (mk-spell 'xen_corp "Ȉ <Xen Corp>" xen-corp "XC" 7 context-town s_xen_corp (list nightshade black_pearl))
369 (mk-spell 'in_quas_xen "Ê£À½ <In Quas Xen>" in-quas-xen "IQX" 7 context-town s_in_quas_xen (list nightshade mandrake sulphorous_ash spider_silk blood_moss ginseng))
372 (mk-spell 'kal_xen_nox "Í»²ò <Kal Xen Nox>" kal-xen-nox "KXN" 8 context-town s_kal_xen_nox (list spider_silk mandrake nightshade))
373 (mk-spell 'in_flam_hur "±êÉ÷ <In Flam Hur>" in-flam-hur "IFH" 8 context-town s_in_flam_hur (list mandrake sulphorous_ash blood_moss))
374 (mk-spell 'in_vas_grav_corp "»àÉ÷ <In Vas Grav Corp>" in-vas-grav-corp "IVGC" 8 context-town s_in_vas_grav_corp (list mandrake sulphorous_ash nightshade))
375 (mk-spell 'an_tym "»þ´ÖÄä»ß <An Tym>" an-tym "AT" 8 context-any s_an_tym (list mandrake garlic blood_moss))
376 (mk-spell 'kal_xen_corp "ÉԻྤ´Ô <Kal Xen Corp>" kal-xen-corp "KXC" 8 context-town s_kal_xen_corp (list spider_silk mandrake nightshade))
377 (mk-spell 'in_mani_corp "ÁÉÀ¸ <In Mani Corp>" in-mani-corp "IMC" 8 context-any s_in_mani_corp (list garlic ginseng spider_silk sulphorous_ash blood_moss mandrake))
378 (mk-spell 'vas_rel_por "Ìç <Vas Rel Por>" vas-rel-por "VRP" 8 context-any s_vas_rel_por (list sulphorous_ash mandrake black_pearl))