OSDN Git Service

ff11d2114cee90aefcd5bd9e2245373c704985f9
[nazghul-jp/nazghul-jp.git] / worlds / haxima-1.002 / conv.scm
1 ;;----------------------------------------------------------------------------
2 ;; Generic conversation
3 ;;----------------------------------------------------------------------------
4
5 ;; fundamentals
6 (define (generic-hail knpc kpc)
7   (say knpc "Well met"))
8
9 (define (generic-unknown knpc kpc)
10   (say knpc "I can't help you with that"))
11
12 (define (generic-bye knpc kpc)
13   (say knpc "Farewell")
14   (kern-conv-end))
15
16 (define (generic-join knpc kpc)
17   (say knpc "I cannot join you."))
18
19 (define (generic-leav knpc kpc)
20   (cond ((is-player-party-member? knpc)
21          (cond ((is-only-living-party-member? knpc)
22                 (say knpc "Maybe I should resurrect the Wanderer first... "
23                      "or sell his body parts to a thaumaturge, at least."))
24                (else
25                 (say knpc "Do you want me to leave your party now?")
26                 (cond ((yes? kpc)
27                        (cond ((kern-char-leave-player knpc)
28                               (say knpc "If you change your mind I'll be here waiting.")
29                               (kern-conv-end)
30                               )
31                              (else 
32                               (say knpc "I can't leave right now!"))))
33                       (else
34                        (say knpc "You made me nervous there for a minute."))))))
35          (else
36           (say knpc "I'm not a member of your party!"))))
37
38 ;; wise
39 (define (basic-ench knpc kpc)
40   (say knpc "The Enchanter is the Wise Wizard. "
41        "He lives in a tower by the Fens, do you need directions?")
42   (quest-wise-subinit 'questentry-enchanter)
43   (quest-data-update 'questentry-enchanter 'general-loc 1)
44   (if (yes? kpc)
45       (let ((kplace (get-place knpc)))
46         (cond ((equal? kplace p_westpass)
47                (say knpc "Take the ladder down. You'll come out in Eastpass. "
48                     "The knights can help you from there."))
49               ((equal? kplace p_eastpass)
50                (say knpc "Take the road west to Trigrave and ask around there."))
51               ((equal? kplace p_trigrave)
52                 (quest-data-update 'questentry-calltoarms 'directions 1)
53                (say knpc "Take the road north to The Fen."))
54               (else 
55                (say knpc "The Fens are somewhere in the northwest."))
56         ))))
57
58 ;; towns
59 (define (basic-trig knpc kpc)
60   (say knpc "Trigrave is a small town in the west, "
61        "settled where two rivers meet."))
62
63 (define (basic-gree knpc kpc)
64   (say knpc "Green Tower, home of the Rangers, lies deep in the Great Forest. "
65        "Do you need directions?")
66   (if (yes? kpc)
67       (let ((kplace (get-place knpc)))
68         (cond ((equal? kplace p_westpass)
69                (say knpc "Take the road east into the forest. "
70                     "Eventually it turns into a trail, follow it as best you can."))
71               ((equal? kplace p_eastpass)
72                (say knpc "Take the ladder down to Westpass and ask the Rangers there."))
73               ((equal? kplace p_trigrave)
74                (say knpc "Take the road east to the mountains and go through Eastpass. "
75                     "After that, you'll have to ask around."))
76               ((equal? kplace p_enchanters_tower)
77                (say knpc "Go south to Trigrave and ask there."))
78               ((equal? kplace p_oparine)
79                (say knpc "Take the road north to Trigrave and ask there."))
80               ((equal? kplace p_moongate_clearing)
81                (say knpc "Follow the road south to the junction, then travel east. "
82                     "When the road bends north keep going east into the woods."))
83               (else 
84                (say knpc "It's in the middle of the Great Forest."))
85               ))))
86
87 (define (basic-bole knpc kpc)
88   (say knpc "The hamlet of Bole sits in a canyon in the mountains north of "
89        "the Great Wood. Do you need directions?")
90   (if (yes? kpc)
91       (let ((kplace (get-place knpc)))
92         (cond ((equal? kplace p_westpass)
93                (say knpc "It's northeast of here. Follow the mountains."))
94               ((equal? kplace p_eastpass)
95                (say knpc "Take the ladder down to Westpass and ask the Rangers there."))
96               ((equal? kplace p_trigrave)
97                (say knpc "Take the road east to the mountains and go through Eastpass. "
98                     "After that, you'll have to ask around."))
99               ((equal? kplace p_green_tower)
100                (say knpc "Go north through the forest until you hit the mountains, "
101                     "then follow them east a short while."))
102               ((equal? kplace p_enchanters_tower)
103                (say knpc "Go south to Trigrave and ask there."))
104               (else 
105                (say knpc "I think it's by the mountains north of the Great Wood."))
106               ))))
107               
108 (define (basic-absa knpc kpc)
109   (say knpc "Absalot, a great and wicked city, was destroyed for its sins."))
110
111 (define (basic-opar knpc kpc)
112   (say knpc "The city of Oparine can be found in the southwest by a "
113        "deep harbor. Do you need directions?")
114   (if (yes? kpc)
115       (let ((kplace (get-place knpc)))
116         (cond ((equal? kplace p_westpass)
117                (say knpc "Take the ladder down to Eastpass and follow the road west."))
118               ((equal? kplace p_eastpass)
119                (say knpc "Follow the road west."))
120               ((equal? kplace p_trigrave)
121                (say knpc "Follow the road west and south all the way to the sea."))
122               ((equal? kplace p_green_tower)
123                (say knpc "Follow the trail south and west to Westpass and ask the rangers when you get there."))
124               ((equal? kplace p_enchanters_tower)
125                (say knpc "Go south to Trigrave and ask there."))
126               ((equal? kplace p_glasdrin)
127                (say knpc "Take the road south."))
128               ((equal? kplace p_oparine)
129                (say knpc "Well, here you are already!"))
130               (else 
131                (say knpc "It's on the southern coast somewhere."))
132               ))))
133
134 (define (basic-east knpc kpc)
135   (say knpc "Eastpass guards the eastern pass into the River Plain. Do you need directions?")
136   (if (yes? kpc)
137       (let ((kplace (get-place knpc)))
138         (cond ((equal? kplace p_westpass)
139                (say knpc "Take the ladder down, you'll come out in Eastpass."))
140               ((equal? kplace p_eastpass)
141                (say knpc "You're here already."))
142               ((equal? kplace p_trigrave)
143                (say knpc "Follow the road east and you'll run right into it."))
144               ((equal? kplace p_green_tower)
145                (say knpc "Travel west through the woods, then follow the road west to Westpass and ask there."))
146               ((equal? kplace p_enchanters_tower)
147                (say knpc "Go south to Trigrave and ask there."))
148               ((equal? kplace p_glasdrin)
149                (say knpc "Take the road south as far as you can and ask there."))
150               ((equal? kplace p_oparine)
151                (say knpc "Take the road north to Trigrave and ask there."))
152               (else 
153                (say knpc "It's by the mountains west of the Great Forest."))
154               ))))
155
156 (define (basic-west knpc kpc)
157   (say knpc "Westpass guards the western pass into the Great Forest. Do you need directions?")
158   (if (yes? kpc)
159       (let ((kplace (get-place knpc)))
160         (cond ((equal? kplace p_westpass)
161                (say knpc "This is it."))
162               ((equal? kplace p_eastpass)
163                (say knpc "Take the ladder down and you'll come out in it."))
164               ((equal? kplace p_trigrave)
165                (say knpc "Follow the road east and ask in Eastpass."))
166               ((equal? kplace p_green_tower)
167                (say knpc "Travel west through the woods, then follow the road west."))
168               ((equal? kplace p_enchanters_tower)
169                (say knpc "Go south to Trigrave and ask there."))
170               ((equal? kplace p_glasdrin)
171                (say knpc "Take the road south as far as you can."))
172               ((equal? kplace p_oparine)
173                (say knpc "Take the road north to Trigrave and ask there."))
174               (else 
175                (say knpc "Follow the road east from Trigrave."))
176               ))))
177
178 (define (basic-glas knpc kpc)
179   (say knpc "Glasdrin is the fortified city of the Paladins. Do you need directions?")
180   (if (yes? kpc)
181       (let ((kplace (get-place knpc)))
182         (cond ((equal? kplace p_westpass)
183                (say knpc "Follow the road east and north."))
184               ((equal? kplace p_eastpass)
185                (say knpc "Go east to Westpass and ask there."))
186               ((equal? kplace p_trigrave)
187                (say knpc "Go east to Eastpass and ask there."))
188               ((equal? kplace p_green_tower)
189                (say knpc "Go west through the woods until you hit the road, then follow it north."))
190               ((equal? kplace p_enchanters_tower)
191                (say knpc "Go east through the pass and follow the river."))
192               ((equal? kplace p_oparine)
193                (say knpc "Follow the road north to Trigave and ask there, or take a ship and follow the coastline all the way north."))
194               (else 
195                (say knpc "It's up near the northeast coast on an island."))
196               ))))
197
198 (define (basic-fens knpc kpc)
199   (say knpc "The Fens are a swampy area in the northwest."))
200
201 (define (basic-kurp knpc kpc)
202   (say knpc "Kurpolis is an ancient underground ruin. "
203        "The entrance is somewhere in the northern mountains."))
204
205 (define (basic-lost knpc kpc)
206   (say knpc "The Lost Halls? I've only heard them mentioned in bard's songs. "
207        "I didn't know they really existed."))
208
209 ;; establishments
210 (define (basic-whit knpc kpc)
211   (say knpc "The White Stag is in Green Tower."))
212
213 ;; quests
214 (define (basic-thie knpc kpc)
215   (say knpc "No, I don't know anything about a thief."))
216
217 (define (basic-rune knpc kpc)
218   (say knpc "I don't know much about runes. Try asking one of the Wise."))
219
220 (define (basic-wise knpc kpc)
221         (say knpc "The Wise have great influence over affairs in the Shard. Do you want to know their names?")
222         (if (yes? kpc)
223                 (begin
224                         (say knpc "There's the Enchanter, the Necromancer, the Alchemist, the MAN, the Engineer and the Warritrix.")
225                         (map quest-wise-subinit
226                                 (list 'questentry-enchanter 'questentry-warritrix  'questentry-alchemist
227                                                 'questentry-the-man 'questentry-engineer  'questentry-necromancer)
228                         )
229                 )
230         ))
231
232 (define (basic-shar knpc kpc)
233   (say knpc "The Shard is what we call our world.")
234   (quest-data-update 'questentry-whereami 'shard 1)
235   )
236
237 (define (basic-peni knpc kpc)
238   (say knpc "The Peninsula is our little corner of the Shard."))
239
240 (define (basic-warr knpc kpc)
241   (say knpc "The Warritrix is the Wise Warrior. If you're looking for her try Glasdrin.")
242   (quest-wise-subinit 'questentry-warritrix)
243   (quest-data-update 'questentry-warritrix 'general-loc 1)
244   )
245
246 (define (basic-engi knpc kpc)
247   (say knpc "I've heard the Engineer is the greatest Wright in the land, "
248        "but I don't know much about him.")
249        (quest-wise-subinit 'questentry-engineer)
250        (quest-data-update 'questentry-engineer 'common 1)
251        )
252
253 (define (basic-man knpc kpc)
254   (say knpc "The MAN is a master wrogue. Nobody knows where his hideout is. "
255        "It's rumoured that he travels in disguise.")
256        (quest-wise-subinit 'questentry-the-man)
257        (quest-data-update 'questentry-the-man 'common 1)
258        )
259
260 (define (basic-alch knpc kpc)
261   (say knpc "The Alchemist is a Wise Wright who specializes in potions. "
262        "You'll find his shop in Oparine.")
263        (quest-wise-subinit 'questentry-alchemist)
264        (quest-data-update 'questentry-alchemist 'general-loc 1)
265        )
266
267 (define (basic-necr knpc kpc)
268   (say knpc "The Necromancer is a Wise Wizard who specializes in death magic. "
269        "I've heard he lives in a hidden cave.")
270        (quest-wise-subinit 'questentry-necromancer)
271        (quest-data-update 'questentry-necromancer 'general-loc 1)
272        )
273
274 (define (basic-drag knpc kpc)
275   (say knpc "Stories say a mighty dragon is terrorizing shipping on the "
276        "east coast."))
277
278 (define (basic-fire knpc kpc)
279   (say knpc "The Fire Sea? That's a volcano on an island off the east coast."))
280
281 (define basic-conv
282   (ifc '()
283        ;; fundamentals
284        (method 'hail generic-hail)
285        (method 'default generic-unknown)
286        (method 'bye generic-bye)
287        (method 'join generic-join)
288        (method 'leav generic-leav)
289        
290        ;; wise
291        (method 'ench basic-ench)
292        (method 'wise basic-wise)
293        (method 'warr basic-warr)
294        (method 'man basic-man)
295        (method 'engi basic-engi)
296        (method 'alch basic-alch)
297        (method 'necr basic-necr)
298
299        ;; towns & regions
300        (method 'absa basic-absa)
301        (method 'bole basic-bole)
302        (method 'gree basic-gree)
303        (method 'trig basic-trig)
304        (method 'lost basic-lost)
305        (method 'opar basic-opar)
306        (method 'fens basic-fens)
307        (method 'shar basic-shar)
308        (method 'peni basic-peni)
309        (method 'kurp basic-kurp)
310        (method 'glas basic-glas)
311        (method 'fire basic-fire)
312
313        ;; establishments
314        (method 'whit basic-whit)
315
316        ;; quests
317        (method 'thie basic-thie)
318        (method 'rune basic-rune)
319
320        ;; monsters
321        (method 'drag basic-drag)
322
323        ))
324
325 ;; Helper(s)
326 (define (say knpc . msg) (kern-conv-say knpc msg))
327 (define (yes? kpc) (kern-conv-get-yes-no? kpc))
328 (define (no? kpc) (not (kern-conv-get-yes-no? kpc)))
329 (define (reply? kpc) (kern-conv-get-reply kpc))
330 (define (ask? knpc kpc . msg)
331   (kern-conv-say knpc msg)
332   (kern-conv-get-yes-no? kpc))
333 (define (prompt-for-key)
334   (kern-log-msg "<Hit any key to continue>")
335   (kern-ui-waitkey))
336 (define (meet msg)
337   (kern-log-msg msg))
338 (define (get-gold-donation knpc kpc)
339   (let ((give (kern-conv-get-amount kpc))
340         (have (kern-player-get-gold)))
341     (cond ((> give have)
342            (say knpc "You don't have that much!")
343            0)
344           (else
345            (kern-player-set-gold (- have give))
346            give))))
347 (define (get-food-donation knpc kpc)
348   (let ((give (kern-conv-get-amount kpc))
349         (have (kern-player-get-food)))
350     (cond ((> give have)
351            (say knpc "You don't have that much!")
352            0)
353           (else
354            (kern-player-set-food (- have give))
355            give))))
356 (define (working? knpc)
357   (string=? "working" (kern-obj-get-activity knpc)))
358
359 ;; Not really an aside in the theatrical sense, this routine causes a party
360 ;; member to interject something into the conversation. kpc is the character
361 ;; being conversed with, mem-tag is either nil or the party member who should
362 ;; do the interjection. If mem-tag is nil then a party member (other than the
363 ;; speaker) will be chosen at random. msg is the text of the comment. If kpc is
364 ;; the only member of the party then the aside will not do anything.
365 (define (aside kpc kchar-tag . msg)
366   ;;(println msg)
367   (if (null? kchar-tag)
368       (let ((members (filter (lambda (kchar)
369                                (not (eqv? kchar kpc)))
370                              (kern-party-get-members (kern-get-player)))
371                      ))
372         (if (not (null? members))
373             (let ((kchar (random-select members)))
374               (say kchar msg)
375               #t)
376             #f)
377         )
378       (if (in-player-party? kchar-tag)
379           (begin
380             (kern-conv-say (eval kchar-tag) msg)
381             #t)
382           #f)
383       ))
384          
385 ;;----------------------------------------------------------------------------
386 ;; Quests
387 ;;----------------------------------------------------------------------------
388 (define (mk-quest) (list #f #f #f))
389 (define (quest-offered? qst) (car qst))
390 (define (quest-accepted? qst) (cadr qst))
391 (define (quest-done? qst) (caddr qst))
392 (define (quest-offered! qst val) (set-car! qst val))
393 (define (quest-accepted! qst val) (set-car! (cdr qst) val))
394 (define (quest-done! qst val) (set-car! (cddr qst) val))
395
396
397 ;;----------------------------------------------------------------------------
398 ;; Ranger Conversation
399 ;;----------------------------------------------------------------------------
400 (define (ranger-ranger knpc kpc)
401   (say knpc "Rangers guard the borders between wilderness and "
402        "civilization. We patrol the frontier and give aid where we can to the "
403        "Wise."))
404
405 (define (ranger-wise knpc kpc)
406   (say knpc "Rangers have an informal alliance with the Wise. They give us "
407        "aid and hospitality. In return we give them news. Sometimes we serve "
408        "them as messengers and scouts."))
409
410 (define (ranger-join knpc kpc)
411   (cond ((has? kpc t_ranger_orders 1)
412          (say knpc "Let's see those orders... ok. Looks like we're partners "
413               "for a while.")
414          (take kpc t_ranger_orders 1)
415          (join-player knpc)
416          ;; NOTE: the following only permits one ranger at a time to join the
417          ;; player!
418          (kern-tag 'ch_ranger_merc knpc)
419          (give kpc t_arrow 20)
420          (kern-conv-end)
421          )
422         (else
423          (say knpc "Sorry, I've got to get back to my patrol."))))
424
425 (define (ranger-band knpc kpc)
426   (say knpc "When men get in trouble with the law, they flee to the woods. "
427        "There are always bandits in the forest."))
428
429 (define ranger-conv
430   (ifc basic-conv
431        (method 'join ranger-join)
432        (method 'rang ranger-ranger)
433        (method 'wise ranger-wise)
434        (method 'band ranger-band)
435        ))
436
437
438 ;; Knight conversation -- used by Lord Froederick's troops
439 (define knight-conv basic-conv)
440
441 ;; Glasdrin
442 (define (glasdrin-warr knpc kpc)
443   (if (player-found-warritrix?)
444       (say knpc "We all mourn her loss.")
445       (say knpc "The Warritrix is the most cunning warrior of the age. I'm not sure where she is right now, ask the Steward or Commander Jeffries.")
446         )
447         (quest-data-update 'questentry-warritrix 'general-loc 1)
448   )
449
450 (define (glasdrin-stew knpc kpc)
451   (if (player-stewardess-trial-done?)
452       (say knpc "Her name of the Stewardess is a curse among us now. The new Steward is Valus, a former commander.")
453       (say knpc "The Steward is the keeper of the city and realms of Glasdrin. You can usually find her in the Citadel.")))
454
455 (define (glasdrin-jeff knpc kpc)
456   (if (player-stewardess-trial-done?)
457       (say knpc "At best Jeffries failed in his duties as commander to protect those under his command. "
458            "At worst, he was an accomplice in the betrayal of the Warritrix. "
459            "Our new commander is Janice.")
460       (say knpc "Jeffries is the commander of the Glasdrin militia. He's usually at work in the Citadel.")
461       ))
462
463 (define (glasdrin-kurp knpc kpc)
464          (say knpc "Take the bridge north across the river then follow the "
465               "mountains east and north into a canyon."))
466 (define (glasdrin-cita knpc kpc)
467   (say knpc "The Citadel is the inner keep in the north part of the castle."))
468 (define (glasdrin-ghol knpc kpc)
469   (say knpc "I seem to recall a man named Gholet was arrested for theft. You might check the Citadel's dungeon.")
470    (quest-data-update 'questentry-ghertie 'gholet-dungeon 1)
471    )
472 (define (glasdrin-kurp knpc kpc)
473   (say knpc "The dungeon Kurpolis is where most of our troops are now. Follow the mountains west, you'll find the entrance in a canyon."))
474
475 (define (glasdrin-glas knpc kpc)
476   (say knpc "Glasdrin is the city of the Paladins."))
477
478 (define (glasdrin-pala knpc kpc)
479   (say knpc "The Paladins of Glasdrin are the greatest military force in the realm."))
480
481 (define glasdrin-conv
482   (ifc basic-conv
483        (method 'warr glasdrin-warr)
484        (method 'stew glasdrin-stew)
485        (method 'jeff glasdrin-jeff)
486        (method 'kurp glasdrin-kurp)
487        (method 'cita glasdrin-cita)
488        (method 'ghol glasdrin-ghol)
489        (method 'kurp glasdrin-kurp)
490        (method 'glas glasdrin-glas)
491        (method 'pala glasdrin-pala)
492        (method 'jani 
493                (lambda (knpc kpc) 
494                  (if (player-stewardess-trial-done?)
495                       (say knpc "The military council has elected Janice to replace Jeffries as commander of the militia.")
496                       (say knpc "Jeffries is an able leader, but everyone knows that his assistant Janice has the brains."))))
497        (method 'valu
498                (lambda (knpc kpc)
499                  (if (player-stewardess-trial-done?)
500                      (say knpc "Valus was exonerated by the Stewardess's journal. "
501                           "It is a shame we ever believed such lies about him. "
502                           "We have elected him to be the new Steward.")
503                      (say knpc "Valus has been imprisoned for shameful indecency. "
504                           "It's a pity, really. He was a well-respected general."))))
505        ))
506
507 ;; Kurpolis
508 (define kurpolis-conv
509   (ifc basic-conv
510        ))
511
512 ;; Green Tower
513 (define (gt-gobl knpc kpc)
514   (say knpc "Since the goblin wars there's been an uneasy truce. Sometimes they trade here in town, but if you meet them in the forest be careful."))
515 (define (gt-towe knpc kpc)
516   (say knpc "The tower that gives this town its name is now the Ranger headquarters."))
517 (define (gt-ruin knpc kpc)
518   (say knpc "The old ruins are in the southwest corner of town."))
519 (define (gt-band knpc kpc)
520   (say knpc "Ask Deric about bandits. "
521        "He's the one who should be dealing with them."))
522
523
524 (define green-tower-conv
525   (ifc basic-conv
526        (method 'gree
527                (lambda (knpc kpc)
528                  (say knpc "Yes, this town gets its name from the old tower in its center.")))
529        (method 'gobl gt-gobl)
530        (method 'towe gt-towe)
531        (method 'ruin gt-ruin)
532        (method 'band gt-band)
533        ))
534
535 ;; Trigrave
536 (define trigrave-conv
537   (ifc basic-conv
538        (method 'thie 
539                (lambda (knpc kpc) 
540                  (say knpc "I don't know anything about a thief. Ask Gwen, maybe a traveler told her something.")))                       
541        ))
542
543 ;;----------------------------------------------------------------------------
544 ;; Merchant
545
546 ;; Indices into the merchant message list
547 (define merch-closed           0)
548 (define merch-buy              1)
549 (define merch-sell             2)
550 (define merch-trade            3)
551 (define merch-sold-something   4)
552 (define merch-sold-nothing     5)
553 (define merch-bought-something 6)
554 (define merch-bought-nothing   7)
555 (define merch-traded-something 8)
556 (define merch-traded-nothing   9)
557
558 (define (conv-trade knpc kpc menu msgs catalog)
559   (println "conv-trade: " (kern-obj-get-activity knpc))
560   ;;(println "conv-trade: " menu msgs catalog)
561   (if (and (not (string=? "working" (kern-obj-get-activity knpc)))
562            (not (null? (list-ref msgs merch-closed))))
563       (say knpc (list-ref msgs merch-closed) 
564            " I'm " (kern-obj-get-activity knpc) " right now.")
565       (cond ((string=? menu "buy")
566              (say knpc (list-ref msgs merch-buy))
567              (if (kern-conv-trade knpc kpc "buy" catalog)
568                  (say knpc (list-ref msgs merch-sold-something))
569                  (say knpc (list-ref msgs merch-sold-nothing))))
570             ((string=? menu "sell")
571              (say knpc (list-ref msgs merch-sell))
572              (if (kern-conv-trade knpc kpc "sell" catalog)
573                  (say knpc (list-ref msgs merch-bought-something))
574                  (say knpc (list-ref msgs merch-bought-nothing))))
575             (else
576              (say knpc (list-ref msgs merch-trade))
577              (if (kern-conv-trade knpc kpc "trade" catalog)
578                  (say knpc (list-ref msgs merch-traded-something))
579                  (say knpc (list-ref msgs merch-traded-nothing))))
580             )))
581