1;;---------------------------------------------------------------------------- 2;; Camping map 3;;---------------------------------------------------------------------------- 4(kern-mk-map 5 'm_campsite 7 7 pal_expanded 6 (list 7 ".. .. bb bb bb .. .." 8 ".. .. .. .. .. .. .." 9 "bb .. .. .. .. .. bb" 10 "bb .. .. && .. .. bb" 11 "bb .. .. .. .. .. bb" 12 ".. .. .. .. .. .. .." 13 ".. .. bb bb bb .. .." 14 )) 15 16;;---------------------------------------------------------------------------- 17;; Camping proc - run every turn when player is camping in the wilderness 18;; kplayer = player party (kernel object pointer) 19;; kplace = camping place 20;;---------------------------------------------------------------------------- 21(define (camping-proc kplayer kplace) 22 (if (> (kern-dice-roll "1d20") 1) 23 (let ((loc (kern-place-get-location kplace))) 24 (define (nearest a b) 25 (if (null? a) 26 b 27 (if (<= (kern-get-distance (kern-obj-get-location a) loc) 28 (kern-get-distance (kern-obj-get-location b) loc)) 29 a 30 b))) 31 (define (willattack? a) 32 (and (is-hostile? kplayer a) 33 (can-pathfind? a loc))) 34 (define (choose-npc-party) 35 (foldr nearest 36 nil 37 (filter willattack? 38 (kern-place-get-beings (loc-place loc))))) 39 (let ((kparty (choose-npc-party))) 40 (if (not (null? kparty)) 41 (begin 42 (if (loc-8-adjacent? (kern-obj-get-location kplayer) 43 (kern-obj-get-location kparty)) 44 (kern-ambush-while-camping kparty kplace) 45 ;; Have the party actually move, so if they are in a 46 ;; vehicle, then when the ambush is over the vehicle will 47 ;; be in the proper location on the wilderness map. 48 (pathfind kparty (kern-obj-get-location kplayer))))))))) 49 50(kern-add-hook 'camping_turn_start_hook 'camping-proc) 51