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
7 ;;----------------------------------------------------------------------------
11 ;; Setup progress bar for loading. I arrived at the number by printing the
12 ;; current number of steps in src/foogod.c:foogod_progress_bar_finish().
13 (kern-progress-bar-start "Æɤ߹þ¤ßÃæ" 205)
15 ;; Wrap the original definition of (load ...) with one that advances the
17 (define original-load load)
19 (println (kern-get-ticks) ":" file "...")
20 (kern-progress-bar-advance 1)
25 ;;----------------------------------------------------------------------------
26 ;; Load the read-only game data. See the note on 'kern-load' vs 'load' above.
27 ;;----------------------------------------------------------------------------
28 (kern-load "minimal-game.scm")
30 ;;----------------------------------------------------------------------------
31 ;; Time -- this needs to be set before loading any dungeon rooms
32 ;;----------------------------------------------------------------------------
35 (define time-in-minutes (+ (* hour 60) minutes))
36 (define game-start-time (time-mk 0 0 0 0 hour minutes))
47 ;;----------------------------------------------------------------------------
49 ;;----------------------------------------------------------------------------
56 faction-player ; starting alignment
62 max-health 0 max-health 0 1 ; hp/xp/mp/AP_per_turn/lvl
72 ;;----------------------------------------------------------------------------
74 ;;----------------------------------------------------------------------------
79 "Walk" ; movement description
80 sound-walking ; movement sound
83 (* 60 60 5) ; turns to next meal (5 hours)
86 nil ; campsite formation
89 (kern-mk-inventory nil)
90 nil ;; party members (should be nil for initial load file)
95 ;;----------------------------------------------------------------------------
97 ;;----------------------------------------------------------------------------
98 (kern-party-add-member player ch_wanderer)
99 ;;(kern-party-add-member player ch_thorald_greybeard)
101 ;;----------------------------------------------------------------------------
103 ;;----------------------------------------------------------------------------
106 "Fyer (the sun)" ; name
107 1 ; relative astronomical distance
108 1 ; minutes per phase (n/a for sun)
109 (/ (* 24 60) 360) ; minutes per degree
112 '() ; script interface
115 (list s_sun 255 "full")
119 ; ;;----------------------------------------------------------------------------
120 ; ;; Lumis is the source gate, which means it opens the source moongates on its
121 ; ;; phases. We designate this by using the source-moon-ifc as its ifc.
123 ; ;; Note: the arc and phase are calculated to give the moon the right orientation
124 ; ;; with respect to phase vs sun position
125 ; ;;----------------------------------------------------------------------------
126 ; (mk-moon 'lumis ; tag
128 ; 5 ; hours per phase
129 ; 60 ; hours per revolution
132 ; 'source-moon-ifc ; ifc
133 ; ;; gates (moons are fixed at 8 phases in mk-moon):
134 ; (list 'mg-1 'mg-2 'mg-3 'mg-4
135 ; 'mg-5 'mg-6 'mg-7 'mg-8
139 ; ;;----------------------------------------------------------------------------
140 ; ;; Ord is the destination gate, which means its phase decides the destination
141 ; ;; when the player steps through a moongate. We designate this by giving it a
142 ; ;; nil ifc. Note that its gates do not need to be listed in the same order as
143 ; ;; Lumis. In fact, they don't even need to be the same set of gates.
145 ; ;; Note: the arc and phase are calculated to give the moon the right orientation
146 ; ;; with respect to phase vs sun position
147 ; ;;----------------------------------------------------------------------------
148 ; (mk-moon 'ord ; tag
150 ; 9 ; hours per phase
151 ; 36 ; hours per revolution
155 ; ;; gates (moons are fixed at 8 phases in mk-moon):
156 ; (list 'mg-1 'mg-2 'mg-3 'mg-4
157 ; 'mg-5 'mg-6 'mg-7 'mg-8
161 ;; ----------------------------------------------------------------------------
162 ;; The diplomacy table. Each entry defines the attitude of the row to the
163 ;; column. Note that attitudes are not necessarily symmetric. Negative values
164 ;; are hostile, positive are friendly.
166 ;; Note: factions should always be allied with themselves in order for
167 ;; summoning AI to work properly.
169 ;; Formatted for spreadsheet
170 ;; ----------------------------------------------------------------------------
172 ;; non pla men cgb acc mon tro spd out gnt dem fgb prs gla
173 (list 2 0 0 0 -1 -2 -2 -2 0 -2 -2 0 0 0 ) ;; none
174 (list 0 2 2 -2 -2 -2 -2 -2 -2 -2 -2 -2 2 2 ) ;; player
175 (list -1 2 2 -1 -2 -2 -2 -2 -2 -2 -2 -2 2 2 ) ;; men
176 (list -1 -2 -2 2 -1 -2 0 -2 -2 -1 -2 -2 0 -2 ) ;; cave goblin
177 (list -1 -2 -1 -1 2 -2 -1 -1 -2 -1 -2 -2 0 -2 ) ;; accursed
178 (list -2 -2 -2 -2 -2 2 -2 0 -2 0 -2 0 0 -2 ) ;; monsters
179 (list -2 -2 -2 0 -1 -2 2 -2 -2 -1 -2 -1 0 -2 ) ;; hill trolls
180 (list -2 -2 -2 -2 -1 0 -2 2 -2 -1 -2 0 0 -2 ) ;; wood spiders
181 (list 0 -2 -2 -2 -2 -2 -2 -2 2 -2 -2 -1 0 -2 ) ;; outlaws
182 (list -2 -2 -2 -1 -1 0 -1 -1 -2 2 -2 -1 0 -2 ) ;; gint
183 (list -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 2 -2 0 -2 ) ;; demon
184 (list 0 -2 -2 -2 -2 0 -2 0 -1 -1 -2 2 0 -2 ) ;; forest goblin
185 (list 0 2 2 0 0 0 0 0 0 0 0 0 2 2 ) ;; prisoners
186 (list -1 2 2 -1 -2 -2 -2 -2 -2 -2 -2 -2 2 2 ) ;; glasdrin
191 'p_minimal "Minimal Place" s_keep
193 nil 19 19 pal_expanded
195 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
196 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
197 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
198 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
199 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
200 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
201 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
202 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
203 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
204 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
205 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
206 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
207 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
208 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
209 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
210 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
211 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
212 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
213 ".. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .."
217 #f ; large-scale (wilderness)
218 #f ; tmp combat place
226 (define (mk-npc name)
228 (kern-mk-char (string->symbol (string-append "ch_"
229 (string-lower name))) ; tag
234 faction-men ; starting alignment
238 max-health -1 max-health 0 2 ; hp/xp/mp/AP_per_turn/lvl
254 (kern-obj-set-conv ch_gregor 'gregors-conv)
256 ;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
257 ;; Setup a quest-offer test
259 ;;;; (define (attach kobj val-tag)
260 ;;;; (let ((val (eval val-tag))
261 ;;;; (obj (gob kobj)))
262 ;;;; (if (null? val) (error "attach: no val for " val-tag))
263 ;;;; (if (null? obj) (error "attach: no gob for " (kern-obj-get-name kobj)))
264 ;;;; (if (val 'can-attach? kobj)
265 ;;;; (tbl-append! obj val-tag)
266 ;;;; (val 'on-attach kobj)
269 ;;;; (define (attached? kobj val-tag)
270 ;;;; (let ((obj (gob kobj)))
273 ;;;; (tbl-get obj (val-tag 'key)))
276 ;;;; (define quest-offer-ifc
278 ;;;; (method 'can-attach? (lambda (knpc) (println "can-attach") #t))
279 ;;;; (method 'key (lambda () 'quest-offer))
280 ;;;; (method 'on-attach (lambda (knpc) ))
281 ;;;; (method 'is-avail? (lambda (knpc kpc) #t))
282 ;;;; (method 'offer (lambda (knpc kpc) ))
285 ;;;; (define (gregors-quest-make-offer kpc knpc)
286 ;;;; (say knpc "Want a quest?")
287 ;;;; (cond ((yes? kpc)
288 ;;;; (say knpc "You got it.")
289 ;;;; (quest-assign gregors-quest (gob (kern-get-player))))
291 ;;;; (say knpc "Fine. Loser.")
292 ;;;; (kern-conv-end))
295 ;;;; (define gregors-quest-offer
296 ;;;; (ifc quest-offer-ifc
297 ;;;; (method 'on-attach (lambda (knpc) (kern-add-hook 'conv_end_hook gregors-quest-make-offer)))
298 ;;;; (method 'key (lambda () 'gregors-quest))
301 ;;----------------------------------------------------------------------------
302 ;; end-of-conv hook handling
304 ;; create the table for end-of-conv handlers
305 (kern-define 'end-of-conv-handlers (tbl-mk))
307 ;; a procedure to run all the end-of-conv handlers
308 (define (run-end-of-conv-handlers kpc knpc args)
309 (println "run-end-of-conv-handlers:args=" args)
310 (tbl-for-each-val (lambda (val)
312 (apply (eval (car val)) (cons kpc (cons knpc (cdr val)))))
315 ;; setup the end-of-conv hook to run the handlers (this must be done only once
316 ;; per game, so keep it in the start-game file)
317 (kern-add-hook 'conv_end_hook
318 'run-end-of-conv-handlers
319 '(end-of-conv-handlers))
321 ;;----------------------------------------------------------------------------
322 ;; Offer a predefined quest in a piece of dialogue. 'args' should be a list
325 ;; (offer-string accept-string reject-string quest)
327 ;; Where 'quest' is an instance of a quest.
328 (define (basic-quest-offer kpc knpc args)
329 (println "basic-quest-offer: args=" args)
330 (println "knpc=" knpc)
331 (define (offer t1 t2 t3 quest)
336 (quest-assign (eval quest)
337 (gob (kern-get-player)))
338 (tbl-rm! end-of-conv-handlers quest)
343 (if (equal? knpc (safe-eval (car args)))
344 (apply offer (cdr args))))
347 ;;----------------------------------------------------------------------------
348 ;; gregor's quest (test)
350 ;; create the quest (for now)
351 (kern-define 'gregors-quest
352 (quest-talk-to-for-xp-mk 'ch_gregor 10))
354 ;; Add an end-of-conv handler to offer gregor's quest
356 ;; (note 1: that the entry must be a list in a list because of the way
357 ;; tbl-for-each and the apply within it work)
359 ;; (note 2: by convention, the key is the name of the quest; basic-quest-offer
361 (tbl-set! end-of-conv-handlers
363 '((basic-quest-offer (ch_gregor "Want a quest?" "You got it." "Fine. Loser" gregors-quest))))
366 ;;----------------------------------------------------------------------------
367 ;; random quest assignment (prototype)
369 (define (random-mailman-quest-offer kpc knpc)
371 "I need someone to deliver THIS PACKAGE"
377 ;; (quest-assign ...)
380 (say knpc "WHAT? YOU SUCK!")
385 (define (select-random-quest-offer knpc)
386 (println "select-random-quest-offer")
387 (random-select (list random-mailman-quest-offer
390 (define (offer-random-quest kpc knpc args)
391 (println "offer-random-quest")
392 (let ((offer (select-random-quest-offer knpc)))
396 (tbl-set! end-of-conv-handlers
398 '((offer-random-quest nil)))
400 ;;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
402 ;;----------------------------------------------------------------------------
403 ;; Startup - this is a one-time only script that runs when the player starts
404 ;; the game for the first time (or whenever he starts over from scratch,
405 ;; loading the game from this file). It sets up the story a bit.
406 ;;----------------------------------------------------------------------------
408 (define (simple-start kplayer)
409 (kern-obj-put-at kplayer (list p_minimal 0 0))
410 (kern-obj-put-at ch_gregor (list p_minimal 1 1))
411 (quest-assign (quest-talk-to-for-xp-mk 'ch_gregor 10) (gob kplayer))
414 (kern-add-hook 'new_game_start_hook 'simple-start)
416 (kern-progress-bar-finish)