Skip to content

Commit

Permalink
lemon quest
Browse files Browse the repository at this point in the history
  • Loading branch information
evanbowman committed Mar 25, 2022
1 parent d345e64 commit 6f841a5
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 125 deletions.
8 changes: 8 additions & 0 deletions help/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,14 @@ o----------------------------o
(room-sym room-x room-y)


o----------------------------o

(room-rem island x y)

Remove room room at x y from
island.


o----------------------------o

(sel)
Expand Down
Binary file modified images/overlay_dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion scripts/challenge.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
'(("1: Goliath" . "challenges/goliath.lisp")
("2: Goblin Raid" . "challenges/goblin_raid.lisp")
("3: Nemesis" . "challenges/backdoor.lisp")
("4: Masonry" . "challenges/masonry.lisp"))
("4: Masonry" . "challenges/masonry.lisp")
;; ("5: test" . "event/quest/2.lisp")
)
6 changes: 5 additions & 1 deletion scripts/event/quest.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
;;;


(gc)

(eval-file
(string "/scripts/event/quest/" (choice 2) ".lisp"))
(string "/scripts/event/quest/" (choice 3) ".lisp"))

(gc)
70 changes: 70 additions & 0 deletions scripts/event/quest/2.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

(dialog "A nearby farming colony requests assistance...")


(opponent-init 8 'neutral)

(island-configure
(opponent)
'((bronze-hull 0 13)
(sunflower 0 11)
(bronze-hull 0 12)
(bronze-hull 0 14)
(power-core 1 13)
(bronze-hull 1 12)
(bronze-hull 2 12)
(bronze-hull 2 11)
(lemon-tree 2 9)
(fountain 3 10)
(lemon-tree 3 13)
(bronze-hull 3 11)
(fountain 4 14)
(lemon-tree 4 9)
(bronze-hull 4 11)
(lemon-tree 5 9)
(lemon-tree 5 13)
(bronze-hull 5 11)
(lemon-tree 6 13)
(bronze-hull 6 11)
(lemon-tree 6 9)
(masonry 7 14)
(masonry 7 13)
(bronze-hull 7 12)
(workshop 7 10)
(masonry 8 14)
(masonry 8 13)
(bronze-hull 8 12)))

(defn on-converge
(let ((m (eval-file "/scripts/event/quest/make_quest_marker.lisp")))
(if m
(progn
(dialog
"<c:Farmer Meyer:9>Looks like a bad storm's coming this way! Hey, I have an idea! How about you do me a favor and relocate my orchard of lemon trees to my brother's island... I'll tell him to pay you 1400@ for each one that you successfully deliver!")

(defn on-dialog-closed
(map
(lambda
(if (equal (car $0) 'lemon-tree)
(room-rem (opponent) (get $0 1) (get $0 2))))
(rooms (opponent)))

;; In case some player decides to farm coins by building his/her own
;; lemon trees and passing them off as Farmer Meyer's trees.
(setq lemon-quest-max-reward 0)

(push 'quests (cons "/scripts/event/quest_marker/lemons.lisp" m))

(map
(lambda
((room-new
(player)
(list 'lemon-tree (car $0) (cdr $0)))
(+= lemon-quest-max-reward 1400)))
(construction-sites (player) '(1 . 2)))

(dialog "<c:Farmer Meyer:9>Please take good care of them! I marked my brother's address on your sky chart with an *!")
(setq on-dialog-closed exit)))
(progn
(dialog "<c:Farmer Meyer:9>I was going to ask you to help relocate some of these lemon trees, but the storm's getting closer and I need to move out! Maybe we'll meet again, someday...")
(setq on-dialog-closed exit)))))
3 changes: 3 additions & 0 deletions scripts/event/quest_marker.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
(eval-file "/scripts/reset_hooks.lisp")


(gc)

(let ((z (zone))
(pos (cdr (wg-pos))))
Expand All @@ -17,3 +18,5 @@
(progn
(eval-file (car (car found))))
(syscall "fatal" "invalid quest marker!"))))

(gc)
54 changes: 54 additions & 0 deletions scripts/event/quest_marker/lemons.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@


(dialog "Farmer Meyer's brother waves in the distance, excited to see you! Err... hopefully you managed to keep some of his lemon trees alive...")



(opponent-init 6 'neutral)

(island-configure
(opponent)
'((power-core 3 13)
(coconut-palm 5 13)))


(setq on-converge
(lambda
(let ((c (* 1400 (length (filter
(lambda (equal (car $0) 'lemon-tree))
(rooms (player)))))))
(if (equal c 0)
(progn
(dialog "<c:Farmer Ted:9>Hey, you lost my brother's trees!?")
(setq on-dialog-closed exit))
(progn
(if (not (bound 'lemon-quest-max-reward))
(setq lemon-quest-max-reward 99999))

(dialog
"<c:Farmer Ted:9>Wonderful! Here's "
(string (min (list lemon-quest-max-reward c)))
" for your trouble!")

(coins-add (min (list lemon-quest-max-reward c)))

(unbind 'lemon-quest-max-reward)
(setq quests '())

(map
(lambda
(if (equal (car $0) 'lemon-tree)
(room-rem (player) (get $0 1) (get $0 2))))
(rooms (player)))

(map
(lambda
((room-new
(opponent)
(list 'lemon-tree (car $0) (cdr $0)))))
(construction-sites (opponent) '(1 . 2)))

;; For the lemon-tree achievement
(syscall "room-enable" 'lemon-tree 1)

(setq on-dialog-closed exit))))))
3 changes: 3 additions & 0 deletions scripts/stdlib.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
;; Defines a bytecode-compiled function.
(macro defn/c (name body) `(setq ,name (compile (lambda ,@body))))

(macro += (name val)
`(setq ,name (+ ,name ,@val)))

(macro setq (name expr)
`(set ,(cons $q name) ,@expr))
Expand Down Expand Up @@ -91,6 +93,7 @@
0)))



(defn append
;; Not the most efficient way to implement append, but this implementation
;; with unquote-splicing is quite compact.
Expand Down
2 changes: 1 addition & 1 deletion source/data/overlay_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// + 375 tiles not compressed
// Total size: 512 + 12000 = 12512
//
// Time-stamp: 2022-03-03, 23:17:32
// Time-stamp: 2022-03-25, 11:23:42
// Exported by Cearn's GBA Image Transmogrifier, v0.8.16
// ( http://www.coranac.com/projects/#grit )
//
Expand Down
Loading

0 comments on commit 6f841a5

Please sign in to comment.