717 lines
58 KiB
Clojure
717 lines
58 KiB
Clojure
(ns advent.screens.rooms.inside-castle
|
|
(:require [advent.screens.rooms :as rooms]
|
|
[advent.actions :as actions]
|
|
[advent.saves :as saves]
|
|
[advent.screens.rooms.common :as common]
|
|
[advent.screens.rooms.outside-castle :as outside-castle]
|
|
[advent.screens.items :as items]
|
|
[advent.utils :as utils]
|
|
[advent.steam :as steam]
|
|
[advent.tween :as tween]
|
|
[clojure.zip :as zip]
|
|
[clojure.set :as set]
|
|
[clojure.string :as str]
|
|
[play-clj.core :refer :all]
|
|
[play-clj.ui :refer :all]
|
|
[play-clj.utils :refer :all]
|
|
[play-clj.g2d :refer :all]))
|
|
|
|
(defn brian [screen entities]
|
|
(when (and (not (get-in entities [:fg-actions :script-running?]))
|
|
(not (get-in entities [:bg-actions :script-running?]))
|
|
(get-in entities [:state :active?])
|
|
(get-in entities [:room :entities :game-player]))
|
|
((actions/get-bg-script entities
|
|
((rand-nth [#(actions/do-dialogue entities :game-player "2 to the power of pi."
|
|
:game-player "No, that's not right.")
|
|
#(actions/do-dialogue entities :game-player "Eureka!"
|
|
:game-player "It's been staring at me in the face!"
|
|
:game-player "It's E=mc2!")
|
|
#(actions/do-dialogue entities :game-player "Now, according to Croutonian physics..."
|
|
:game-player "There are three states of matter."
|
|
:game-player "Solid, liquid, and ..."
|
|
:game-player "What was that last one?"
|
|
:game-player "Oh yeah, jelly."
|
|
:game-player "Brian, you're a genius!")
|
|
#(actions/do-dialogue entities :game-player "Considering the inverse square law..."
|
|
:game-player "I estimate our planet's escape velocity to be..."
|
|
:game-player "No, that can't be right.")])))
|
|
entities))
|
|
nil)
|
|
|
|
(defn get-chorus-volume [entities]
|
|
(let [ego (get-in entities [:room :entities :ego])]
|
|
(cond (> (:y ego) 112)
|
|
0.0
|
|
(get-in entities [:room :entities :blackout])
|
|
0.0
|
|
(actions/has-obtained? entities :sword)
|
|
0.0
|
|
:else
|
|
(* 0.2
|
|
(max 0.0 (- 1.0 (/ (utils/dist 45 97 (:x ego) (:y ego)) 50.0)))
|
|
(get-in entities [:volume :value])))))
|
|
|
|
(defn bloodclot-appear [entities]
|
|
(actions/run-action entities
|
|
(begin [this screen entities]
|
|
(particle-effect! (get-in entities [:room :entities :appear]) :reset)
|
|
(particle-effect! (get-in entities [:room :entities :appear]) :start)
|
|
(utils/play-sound! screen entities :disappear (constantly 0.7))
|
|
(-> entities
|
|
(assoc-in [:tweens :bloodclot-head-appear]
|
|
(tween/tween :bloodclot-head-appear screen [:room :entities :bloodclot-head :opacity] 0.0 1.0 1.0 :ease tween/ease-in-quadratic))
|
|
(assoc-in [:tweens :bloodclot-appear]
|
|
(tween/tween :bloodclot-appear screen [:room :entities :bloodclot :opacity] 0.0 1.0 1.0 :ease tween/ease-in-quadratic))))
|
|
|
|
(continue [this screen entities]
|
|
entities)
|
|
|
|
(done? [this screen entities]
|
|
(= 1.0 (get-in entities [:room :entities :bloodclot :opacity])))
|
|
|
|
(terminate [this screen entities]
|
|
entities)
|
|
(skip-type [this screen entities]
|
|
:none)))
|
|
|
|
|
|
(defn nice-trophy-dialogue [entities]
|
|
{:run #(actions/respond entities %
|
|
:game-player "Thanks. I'm the reigning champ in the annual Town of Remington Junior Smarty Pants Derby."
|
|
:game-player "I earned it with my wisdom and sharp intellect."
|
|
:game-player "Oh, I'm guessing you want it? "
|
|
:game-player "Maybe to prove your wisdom and pull the Sword of Blergh?"
|
|
:game-player "Perhaps to become a knight and impress a young lady?")
|
|
:choices ["Yes."
|
|
{:run #(actions/respond entities %
|
|
:game-player "My trophy is hard-won."
|
|
:game-player "You won't pry it from my fingers easily."
|
|
:game-player "But I am preparing for next year's Junior Smarty Pants Derby..."
|
|
:game-player "... and I could use some help."
|
|
:game-player "If you can help me, it will secure my success next year."
|
|
:game-player "And I'll give you my trophy in exchange."
|
|
:game-player "Deal?")
|
|
:choices ["What is the Junior Smarty Pants Derby?"
|
|
{:run #(actions/respond entities %
|
|
:game-player "The annual Town of Remington Junior Smarty Pants Derby is a contest of wits."
|
|
:game-player "It's sort of like a game of riddles, mixed with a scavenger hunt."
|
|
:game-player "You must find the answer to the riddle to win."
|
|
:game-player "There are a few riddles that even I, the wise Brian O'Brainy, can't solve."
|
|
:game-player "That's where you come in.")
|
|
:choices actions/previous-choices}
|
|
"Deal."
|
|
{:run #(do (actions/update-state entities (fn [state] (assoc state :current-riddle :wool)))
|
|
(actions/respond entities %
|
|
:game-player "Very well. "
|
|
:game-player "I'm studying for next year's derby..."
|
|
:game-player "... and there are a few puzzles that have ME stumped."
|
|
:game-player "If you can bring me the answers to three riddles, I'll give you my trophy."
|
|
:game-player "Here's the first riddle:"
|
|
:game-player "\"White as snow, but not as cold,\nKeeps you warm, or so I'm told.\""
|
|
:ego "Okay. So I'll be back soon."))}
|
|
"No thanks."
|
|
{:run #(actions/respond entities % :game-player "Fine by me.")}]}
|
|
"No."
|
|
{:run #(actions/respond entities % :game-player "Fine by me.")}]})
|
|
|
|
(defn walk-to-player [entities]
|
|
(actions/walk-to entities :ego [209 74] :face :right)
|
|
(actions/do-force-end entities :bg-actions))
|
|
|
|
(defn brian-pause-from-work [entities]
|
|
(actions/play-animation entities :game-player :pause-from-work :stop? false)
|
|
(actions/do-stop entities :game-player :face :right))
|
|
|
|
(defn brian-get-to-work [entities]
|
|
(actions/play-animation entities :game-player :get-to-work :stop? false)
|
|
(actions/do-stop entities :game-player :face :left))
|
|
|
|
(defn do-game-player-dialogue [entities]
|
|
(walk-to-player entities)
|
|
(actions/do-dialogue entities :ego "You there!")
|
|
(actions/talk entities :game-player "What is it? I'm busy!" :anim :talk-down)
|
|
(Thread/sleep 200)
|
|
(brian-pause-from-work entities)
|
|
(actions/talk entities :game-player "Oh, it's you, Tick.")
|
|
(actions/present-choices entities
|
|
{:choices ["Whatcha doing?"
|
|
{:run #(actions/respond entities %
|
|
:game-player "I'm writing articles in the fields of mathematics, biology..."
|
|
:game-player "... astronomy, physics, archeology ..."
|
|
:game-player "... paleontology, engineering, history ..."
|
|
:game-player "... anthropology, chemistry, quantum mechanics ..."
|
|
:game-player "... literature, physiology, and ...")
|
|
:choices ["... and girls?"
|
|
{:run #(actions/respond entities %
|
|
:game-player "No, of course not."
|
|
:game-player "I'm a boy of the books."
|
|
:game-player "I have no time for dating or love.")
|
|
:choices actions/previous-choices}
|
|
"... and knightology?"
|
|
{:run #(actions/respond entities %
|
|
:game-player "The study of knights?"
|
|
:game-player "That area of research hasn't been founded yet."
|
|
:ego "Well, I can be your first subject!"
|
|
:game-player "I'm far too busy."
|
|
:game-player "Plus, you're not even a knight!")
|
|
:choices actions/previous-choices}
|
|
"... and magic?"
|
|
{:run #(actions/respond entities %
|
|
:game-player "Magic?"
|
|
:game-player "Ha!"
|
|
:game-player "My research will put magic into its rightful place:"
|
|
:game-player "My history books.")
|
|
:choices actions/previous-choices}
|
|
"... and what?"
|
|
{:run #(actions/respond entities % :game-player "Calligraphy."
|
|
:game-player "With all this writing, I get plenty of practice!")
|
|
:choices actions/something-else}
|
|
]}
|
|
"What are you reading all of these books for?"
|
|
{:run #(do (actions/respond entities %
|
|
:game-player "I'm not reading them."
|
|
:game-player "I'm writing them!"
|
|
)
|
|
(brian-get-to-work entities)
|
|
(actions/talk entities :game-player "I've written three books so far today!"))
|
|
:choices ["Can I borrow one?"
|
|
{:run #(actions/respond entities % :game-player "No!")
|
|
:choices actions/previous-choices}
|
|
"Tell me about one of your books."
|
|
{:run (fn [m]
|
|
((rand-nth
|
|
[#(actions/respond entities m :game-player "Have you read my seminal work on vampire dentistry?"
|
|
:game-player "Forget nail biting!"
|
|
:game-player "It's neck biting!")
|
|
#(actions/respond entities m :game-player "How about 'The Universe and Ewe'?"
|
|
:game-player "It's a children's book about theoretical physics and sheep.")
|
|
#(actions/respond entities m :game-player "How about 'Proton: A Life'?"
|
|
:game-player "It's a self-help book."
|
|
:game-player "It shows you how to be positive when surrounded by a cloud of negativity!")
|
|
#(actions/respond entities m :game-player "Have you read my book, 'Dissection for Dummies'?"
|
|
:game-player "It gets right to the heart of the matter.")
|
|
#(actions/respond entities m :game-player "Have you read 'The Elements: From H to Z'?"
|
|
:game-player "It was periodically written on this very table!")])))
|
|
:choices actions/previous-choices}
|
|
"Let's talk about something else."
|
|
{:run #(do (actions/respond entities %)
|
|
(brian-pause-from-work entities)
|
|
(actions/talk entities :game-player "Sure."))
|
|
:choices actions/something-else}]}
|
|
"Do you know anything about the sword in the stone up there?"
|
|
{:run #(actions/respond entities %
|
|
:game-player "It's the Sword of Blergh. "
|
|
:game-player "There's a prophecy that says that whoever pulls it will be a great knight!"
|
|
:game-player "\"The Sword of Blergh, with magic sting,\nshall yield to no earthly king."
|
|
:game-player "Worthy in wisdom, courage, and might,\nonly then with sword he'll fight.\""
|
|
:game-player "I've often dreamed of pulling the sword myself.")
|
|
:choices ["Why don't you?"
|
|
{:run #(do (actions/respond entities %
|
|
:game-player "I, of course, am the wisest in all of Remington."
|
|
:game-player "But I'm not much of a hero."
|
|
:game-player "The knights of Remington have muscles the size of tree trunks."
|
|
:game-player "But I...")
|
|
(actions/play-animation entities :game-player :flex)
|
|
(actions/do-dialogue entities :game-player "... I'd never be able to prove my strength."))
|
|
:choices actions/previous-choices}
|
|
"Something else."
|
|
{:choices actions/something-else}]}
|
|
(when (= nil (get-in @entities [:state :current-riddle]))
|
|
"Nice trophy.")
|
|
(nice-trophy-dialogue entities)
|
|
|
|
(when (= :wool (get-in @entities [:state :current-riddle]))
|
|
"What was that riddle again?")
|
|
{:run #(actions/respond entities %
|
|
:game-player "\"White as snow, but not as cold,\nKeeps you warm, or so I'm told.\"")
|
|
:choices actions/previous-choices}
|
|
|
|
(when (= :balloon (get-in @entities [:state :current-riddle]))
|
|
"What was that riddle again?")
|
|
{:run #(actions/respond entities %
|
|
:game-player "\"Filled with air, light as a feather,\nWant to keep it? Best have a tether.\"")
|
|
:choices actions/previous-choices}
|
|
|
|
(when (= :frog-legs (get-in @entities [:state :current-riddle]))
|
|
"What was that riddle again?")
|
|
{:run #(actions/respond entities %
|
|
:game-player "\"Hippity-hop, I'd jump so high,\nWithout these springs, can't harm a fly.\"")
|
|
:choices actions/previous-choices}
|
|
"Nevermind."
|
|
{:run #(actions/respond entities % :game-player "See you around.")}]})
|
|
|
|
(brian-get-to-work entities)
|
|
)
|
|
|
|
(defn walk-to-blergh [entities]
|
|
(actions/walk-to entities :ego [85 145] :face :right)
|
|
(actions/transition-background entities :space [0 65] :transition-music? false)
|
|
(actions/walk-straight-to entities :ego [160 45] :face :right)
|
|
|
|
(bloodclot-appear entities)
|
|
(actions/transition-music entities nil :duration 0.15))
|
|
|
|
(defn pull-sword [entities]
|
|
(actions/do-force-end entities :bg-actions)
|
|
(actions/play-animation entities :ego :reach-start :stop? false)
|
|
(actions/pause-camera entities)
|
|
(actions/transition-music entities :pull-sword
|
|
:between (fn [e]
|
|
(as-> e e
|
|
(assoc-in e [:room :entities :blackout]
|
|
(get-in e [:room :blackout]))
|
|
(assoc-in e [:room :entities :pull-sword]
|
|
(get-in e [:room :pull-sword])))))
|
|
|
|
(actions/play-animation entities :pull-sword :pull-sword)
|
|
(actions/play-animation entities :ego :reach-stop)
|
|
(actions/give entities :sword)
|
|
(actions/remove-entity entities :sword)
|
|
(actions/remove-entity entities :pull-sword)
|
|
(actions/remove-entity entities :blackout)
|
|
(particle-effect! (get-in @entities [:room :entities :magic]) :allow-completion)
|
|
(actions/resume-camera entities)
|
|
(actions/transition-music entities nil)
|
|
(actions/camera-shake entities 12)
|
|
(Thread/sleep 500)
|
|
(actions/do-dialogue entities :ego "That was weird."
|
|
:ego "I have to go show my friends!")
|
|
|
|
(walk-to-blergh entities)
|
|
|
|
|
|
|
|
(actions/talk entities :ego "Who are you?!" :anim :scared-talk)
|
|
(actions/begin-animation entities :ego :scared)
|
|
(actions/do-dialogue entities
|
|
:bloodclot-head "I am Bloodclot, the goblin!"
|
|
:bloodclot-head "I've spent the last 100 years training for this day."
|
|
:bloodclot-head "The day when I must best the worthiest of knights in battle."
|
|
:bloodclot-head "But I had never expected my foe to be so..."
|
|
:bloodclot-head "... appetizing."
|
|
:bloodclot-head "You're no hero. You're just a morsel."
|
|
:bloodclot-head "Come here, and I promise I will spare you much pain.")
|
|
(actions/talk entities :ego "Wait a second. I'm just a kid." :anim :scared-talk)
|
|
(actions/walk-straight-to entities :ego [115 45] :override-dir :right :anim :scared-walk :speed 0.5 :stop? false)
|
|
(actions/talk entities :ego "I'm just trying to impress Georgia McGorgeous." :anim :scared-talk :stop? false)
|
|
(actions/walk-straight-to entities :ego [75 45] :override-dir :right :anim :scared-walk :speed 0.5 :stop? false)
|
|
(actions/talk entities :ego "I just... accidentally pulled the sword!":anim :scared-talk :stop? false)
|
|
(actions/walk-straight-to entities :ego [35 45] :override-dir :right :anim :scared-walk :speed 0.5 :stop? false)
|
|
(actions/talk entities :ego "I wouldn't taste very good anyhow!" :anim :scared-talk :stop? false)
|
|
(actions/begin-animation entities :ego :scared)
|
|
(actions/do-dialogue entities
|
|
:bloodclot-head "\"A final test remains, behold!\""
|
|
:bloodclot-head "Ring any bells?"
|
|
:bloodclot-head "The final test of my appetite."
|
|
:bloodclot-head "Face it, kiddo, you're no match for me."
|
|
:bloodclot-head "And Georgia McGorgeous would never go for such a cowardly knight anyhow."
|
|
:bloodclot-head "Let the feast begin.")
|
|
(actions/update-entity entities :ego (fn [e]
|
|
(assoc e :stand-override :scared
|
|
:talk-override :scared-talk))))
|
|
|
|
(defn try-to-pull-sword [entities missing-items obtained-items]
|
|
(let [item->proof {:trophy "wisdom" :medal "strength" :kiss "courage"}]
|
|
(actions/play-animation entities :ego :reach)
|
|
(actions/do-dialogue entities
|
|
:ego "I can't pull it out!"
|
|
:ego "It looks like there's an inscription here.")
|
|
(actions/play-animation entities :ego :start-squat-2 :stop? false)
|
|
(actions/squat-talk entities
|
|
"\"In the day when I shall be pulled,\nWith much strength a knight will take hold."
|
|
"Courage will he need,\nWisdom he shall heed."
|
|
"A final test remains, behold!\"")
|
|
(actions/play-animation entities :ego :end-squat)
|
|
(if (= 3 (count missing-items))
|
|
(do
|
|
(actions/walk-to entities :ego [115 54])
|
|
(actions/do-dialogue entities
|
|
:ego "I think it means I have to prove myself worthy in wisdom, courage, and might!"
|
|
:ego "Then I can become a knight and impress Georgia McGorgeous!")
|
|
(actions/georgia-say entities "Tick! My handsome hero!")
|
|
(actions/talk entities :ego "... I wonder what the \"final test\" bit is about."))
|
|
(actions/do-dialogue entities :ego (str "I've proven myself in "
|
|
(str/join " and " (map item->proof obtained-items))
|
|
", but still have to prove myself in "
|
|
(str/join " and " (map item->proof missing-items))
|
|
".")))))
|
|
|
|
(defn add-monocle-if-necessary [entities]
|
|
(if (and (not (actions/has-obtained? entities :monocle))
|
|
(get-in entities [:state :talked-to-owl?]))
|
|
(update-in entities [:room :entities] #(assoc % :monocle (get-in entities [:room :monocle])))
|
|
entities))
|
|
|
|
|
|
|
|
(defn make-night [entities]
|
|
(-> entities
|
|
(update-in [:room :entities] #(dissoc % :game-player :books))
|
|
add-monocle-if-necessary))
|
|
|
|
(defn offer-solution [entities riddle]
|
|
(condp = (get-in @entities [:state :current-riddle])
|
|
riddle true
|
|
:done (do (actions/do-dialogue entities :game-player "I've gotten all the help I need with riddles today.")
|
|
nil)
|
|
nil (do (actions/do-dialogue entities :game-player "Why are you offering me this?")
|
|
nil)
|
|
(do (actions/do-dialogue entities :ego "What about this?" :game-player "No, that's not the solution. Keep looking.")
|
|
nil)))
|
|
|
|
(defn make [screen]
|
|
(let [sign (utils/make-anim-seq "inside-castle/sign" [44 20] 0.3 (flatten [(repeat 20 0) 1 0 2 0 1 0 2 0 1 0 2 0 1]))
|
|
game-player-talk-sheet (texture! (utils/get-texture "inside-castle/game-player-talk.png") :split 40 44)
|
|
game-player-talk-up (animation 0.15 (for [i [0 2 0 2 0 2 0 3 0 2 0 1 0 0 0 0 2 0 2 0 3 0 1 0 1 0 0 1 0 2 0 3 0]]
|
|
(aget game-player-talk-sheet 0 i)))
|
|
|
|
game-player-stand-up (animation 0.15 (for [i [0 0 0 0 0 0 0 0 0 0 0 1]]
|
|
(aget game-player-talk-sheet 0 i)))
|
|
game-player-stand-down (utils/make-anim "inside-castle/brian-working.png" [40 44] 0.1 (flatten (repeat 4 [0 1 1 2 0 2 2 1 0 2 2 2 2 2 1 1 ])))
|
|
game-player-talk-down (utils/make-anim "inside-castle/brian-working.png" [40 44] 0.2 [2 3 2 2 3 2 3 2])
|
|
game-player-pause-from-work (utils/make-anim "inside-castle/brian-working.png" [40 44] 0.15 [2 3 4 5 6 7])
|
|
game-player-get-to-work (utils/make-anim "inside-castle/brian-working.png" [40 44] 0.15 (reverse [2 3 4 5 6 7]))
|
|
game-player-flex (animation 0.075 (for [i [0 0 4 4 5 5 5 5 5 5 5 6 7 8 7 9 7 8 7 9 7 8 7 9 7 8 7 9 7 8 7 9 7 8 7 9 7 8 7 9 7 8 7 9 7 8 7 9 7 8 7 9 7 8 7 6 5 5 5 5 5 5 5 5 5 5 4 4 0 0 0 0]]
|
|
(aget game-player-talk-sheet 0 i)))
|
|
trophy (utils/make-anim "inside-castle/trophy.png" [16 16] 0.1 (flatten [(repeat 50 0) 1 2 3 3 3 3 2 1]))
|
|
pull-sword-anim (utils/make-anim "inside-castle/pull-sword.png" [95 190] 0.10 (flatten [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 3 2 3 2 3 3 2 3 2 2 3 3 2 3 2 3 2 3 2 3 2 3 2 2 3 3 3 2 3 2 3 3 2 3 2 3 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ]))
|
|
monocle (utils/make-anim "inside-castle/monocle.png" [19 19] 0.05 (flatten [(repeat 70 0) 1 2 3 3 3 2 1]))
|
|
door (utils/make-anim "inside-castle/door.png" [21 49] 0.15 (flatten [(range 4) 3 3 3 3 3 3 3]))
|
|
]
|
|
(rooms/make :music {:day :town-1 :night :night :sunrise :night}
|
|
:name "Inside castle"
|
|
:timers {:brian [10.0 7.0 brian]}
|
|
:interactions
|
|
{:right-door {:box [286 140 306 160]
|
|
:cursor :right
|
|
:only-script (actions/get-script entities
|
|
(actions/walk-to entities :ego [284 145] :skip-type :end)
|
|
(actions/walk-straight-to entities :ego [295 145])
|
|
(if (outside-castle/should-block? entities)
|
|
(do
|
|
(actions/transition-background entities :castle-gate [100 83])
|
|
(actions/walk-straight-to entities :ego [157 83] :skip-type :end))
|
|
(do
|
|
(actions/transition-background entities :outside-castle [61 182])
|
|
(actions/walk-straight-to entities :ego [82 180])
|
|
(actions/walk-to entities :ego [129 148] :skip-type :end))))}
|
|
:up-door {:box [50 150 70 170]
|
|
:only-script (actions/get-script entities
|
|
(actions/walk-to entities :ego [65 155] :skip-type :end)
|
|
(if (= :night (get-in @entities [:state :time]))
|
|
(actions/talk entities :ego "It's locked.")
|
|
(do (actions/transition-background entities :inside-cafeteria [319 55])
|
|
(actions/walk-to entities :ego [300 55]))))
|
|
:cursor :up}
|
|
:antique-door {:box [154 90 189 150]
|
|
:cursor :up
|
|
:only-script (actions/get-script entities
|
|
(actions/walk-to entities :ego [182 90] :face :left :skip-type :end)
|
|
(actions/play-animation entities :ego :reach)
|
|
(if (= :night (get-in @entities [:state :time]))
|
|
(actions/talk entities :ego "It's locked.")
|
|
(do
|
|
(actions/play-animation entities :door :open)
|
|
(actions/transition-background entities :inside-antique [325 -30])
|
|
(actions/walk-straight-to entities :ego [235 15] :face :left)
|
|
(if (get-in @entities [:state :allowed-to-keep-teddy?])
|
|
(actions/do-dialogue entities :shopkeep "Hello there, sonny."
|
|
:shopkeep "Have you seen Herb lately?"
|
|
:ego "Erm... No, not recently."
|
|
:shopkeep "Oh. Send him my love if you do see him.")
|
|
(actions/do-dialogue entities :shopkeep "... Son?"
|
|
:shopkeep "Oh, you're not him."
|
|
:shopkeep "Welcome to Ye Olde Antique Shop.")))))}
|
|
:sword {:box [15 93 49 125]
|
|
:label "Pedestal"
|
|
:cursor :hand
|
|
:script (actions/get-script entities
|
|
(if (actions/has-item? entities :sword)
|
|
(actions/talk entities :ego "I already have the Sword of Blergh!")
|
|
(do (actions/talk entities :ego "That's the coolest sword I've ever seen!!")
|
|
(actions/walk-to entities :ego [45 97] :face :left)
|
|
(actions/talk entities :ego "If I pull it out, I can become a great knight!")
|
|
(let [missing-items (set/difference #{:trophy :medal :kiss} (get-in @entities [:state :obtained-items]))
|
|
obtained-items (set/intersection #{:trophy :medal :kiss} (get-in @entities [:state :obtained-items]))]
|
|
(if (= #{} missing-items)
|
|
(pull-sword entities)
|
|
(try-to-pull-sword entities missing-items obtained-items))))))}
|
|
:sign {:box [125 140 165 155]
|
|
:label "Sign"
|
|
:cursor :look
|
|
:script (actions/get-script entities
|
|
(actions/talk entities :ego "Ye Ol' Antique Shoppe."))}
|
|
:background-houses {:box [84 145 126 180]
|
|
:only-script (actions/get-script entities
|
|
(actions/walk-to entities :ego [81 148] :face :right :stop? false :skip-type :end)
|
|
(actions/walk-straight-to entities :ego [92 150] :face :right)
|
|
(actions/transition-background entities :outside-jail [159 -20])
|
|
(actions/walk-straight-to entities :ego [159 20]))
|
|
:cursor :right}
|
|
:mid-house {:box [217 125 250 180]
|
|
:cursor :look
|
|
:label "Billy's house"
|
|
:script (actions/get-script entities
|
|
(actions/do-dialogue entities
|
|
:ego "That's Billy Billigan's house."
|
|
:ego "He's probably still angry from when I put his dog in the dryer."))}
|
|
:frankie-house {:box [251 140 266 160]
|
|
:cursor :look
|
|
:label "Frankie's house"
|
|
:script (actions/get-script entities
|
|
(actions/do-dialogue entities
|
|
:ego "That's Frankie Rockfist's house."
|
|
:ego "The last time I saw him, he socked me one, right in the kisser."))}
|
|
:georgia-house {:box [271 150 286 170]
|
|
:cursor :look
|
|
:label "Georgia's house"
|
|
:script (actions/get-script entities
|
|
(actions/do-dialogue entities
|
|
:ego "That's Georgia McGorgeous' house."
|
|
:ego "One day, when I'm a knight, she'll say...")
|
|
(actions/georgia-say entities "Kiss me, brave Sir Tick!")
|
|
#_(actions/in-love entities))}}
|
|
:layers {:day [(assoc (utils/get-texture "inside-castle/background.png") :x 0 :y 0 :baseline 0)
|
|
(assoc (utils/get-texture "inside-castle/way-back-tree.png") :x 0 :y 0 :baseline 97)
|
|
(assoc (utils/get-texture "inside-castle/roof.png") :x (- 320 57) :y 0 :baseline 240 :parallax 1.5)
|
|
(assoc (utils/get-texture "inside-castle/bookstack.png") :x 244 :y 67 :baseline 190 :origin-x 0 :origin-y 0)]
|
|
:night [(assoc (utils/get-texture "inside-castle/background.png") :x 0 :y 0 :baseline 0)
|
|
(assoc (utils/get-texture "inside-castle/way-back-tree.png") :x 0 :y 0 :baseline 97)
|
|
(assoc (utils/get-texture "inside-castle/roof.png") :x (- 320 57) :y 0 :baseline 240 :parallax 1.5)]
|
|
:sunrise [(assoc (utils/get-texture "inside-castle/background.png") :x 0 :y 0 :baseline 0)
|
|
(assoc (utils/get-texture "inside-castle/way-back-tree.png") :x 0 :y 0 :baseline 97)
|
|
(assoc (utils/get-texture "inside-castle/roof.png") :x (- 320 57) :y 0 :baseline 240 :parallax 1.5)]}
|
|
:blackout (assoc (utils/get-texture "black.png")
|
|
:x -10 :y -10
|
|
:width 340
|
|
:height 260 :opacity 0.8
|
|
:baseline 239)
|
|
:pull-sword (assoc (animation->texture screen pull-sword-anim)
|
|
:x 10
|
|
:y 20
|
|
:baseline 240
|
|
:pull-sword pull-sword-anim)
|
|
:hotspots [{:box [0 74 77 109]
|
|
:fn (fn [screen entities]
|
|
(let [magic (get-in entities [:room :entities :magic])]
|
|
(cond (actions/has-obtained? entities :sword)
|
|
entities
|
|
(nil? magic)
|
|
(do
|
|
(assoc-in entities [:room :entities :magic] (assoc (doto (particle-effect "particles/magic-sword")
|
|
(particle-effect! :reset))
|
|
:x 25
|
|
:y 108
|
|
:baseline 238)))
|
|
(particle-effect! magic :is-complete)
|
|
(do
|
|
(doto magic
|
|
(particle-effect! :start))
|
|
entities)
|
|
:else
|
|
entities)))}
|
|
{:box [78 66 90 86]
|
|
:fn (fn [screen entities]
|
|
(if-let [magic (get-in entities [:room :entities :magic])]
|
|
(do
|
|
(particle-effect! magic :allow-completion)
|
|
entities)
|
|
entities))}]
|
|
:entities {:bird-1 (utils/make-bird screen (as-> [[185 235]
|
|
[220 225] [210 230] [250 235]] p
|
|
(concat p (reverse p))))
|
|
:sign (assoc (animation->texture screen sign )
|
|
:anim sign
|
|
:anim-start 0
|
|
:x 125 :y 138 :baseline 239)
|
|
:bird-2 (utils/make-bird screen (as-> [[220 225] [195 235] [210 230] [250 225]] p
|
|
(concat p (reverse p))))
|
|
|
|
:outside-particles (common/make-outside-particles)
|
|
:door (assoc (animation->texture screen door)
|
|
:x 160 :y 97 :baseline 99
|
|
:open door
|
|
:door-sound (utils/load-sound "door.ogg")
|
|
:anim-sound-frames {door {1 [:door-sound 0.1]}}
|
|
)
|
|
:sword (assoc (utils/get-texture "inside-castle/sword.png")
|
|
:x 22
|
|
:y 110
|
|
:baseline 95)
|
|
:walkie-talkie (assoc (utils/get-texture "inside-castle/walkie-talkie.png")
|
|
:label "Walkie-talkie"
|
|
:cursor :talk
|
|
:x 257
|
|
:y 135
|
|
:baseline 0
|
|
:night-profile :sprite
|
|
:script (actions/get-script entities
|
|
(actions/talk entities :ego "Let's see if this thing works.")
|
|
(actions/walk-to entities :ego [272 136] :face :left)
|
|
(actions/play-animation entities :ego :start-squat-2 :stop? false)
|
|
(common/listen-to-frankie entities)
|
|
(actions/play-animation entities :ego :end-squat)))
|
|
|
|
:trophy (assoc (animation->texture screen trophy)
|
|
:x 230 :y 69 :baseline 191
|
|
:label "Trophy"
|
|
:cursor :hand
|
|
:anim trophy
|
|
:anim-start 0
|
|
:script (actions/get-script entities
|
|
(walk-to-player entities)
|
|
(if (= nil (get-in @entities [:state :current-riddle]))
|
|
(do
|
|
(brian-pause-from-work entities)
|
|
(let [{:keys [run choices]} (nice-trophy-dialogue entities)]
|
|
(run "Nice trophy.")
|
|
(actions/present-choices entities {:choices choices}))
|
|
(brian-get-to-work entities))
|
|
(actions/do-dialogue entities :ego "Can't you give me your trophy of wisdom?"
|
|
:game-player "If you want my trophy, you'll have to help me with my riddles."))))
|
|
:books (assoc (utils/get-texture "inside-castle/books.png")
|
|
:label "Books"
|
|
:cursor :hand
|
|
:x 230 :y 30 :baseline 191
|
|
:script (actions/get-script entities
|
|
(walk-to-player entities)
|
|
(actions/talk entities :game-player "Don't touch my books!")))
|
|
:game-player (assoc (utils/get-texture "inside-castle/gameplayer.png") :x 266 :y 49 :baseline 191
|
|
:label "Brian O'Brainy"
|
|
:cursor :talk
|
|
:talk-color (color 1.0 0.3 0.4 1.0)
|
|
:script (actions/get-script entities (do-game-player-dialogue entities))
|
|
:writing-sound (utils/load-sound "inside-castle/writing.ogg")
|
|
:facing :left
|
|
:scripts #(condp = %
|
|
:wool (actions/get-script entities
|
|
(walk-to-player entities)
|
|
(when (offer-solution entities :wool)
|
|
(do (actions/play-animation entities :ego :idea)
|
|
(brian-pause-from-work entities)
|
|
(actions/update-state entities (fn [s] (assoc s :current-riddle :balloon)))
|
|
(actions/remove-item entities :wool)
|
|
(actions/do-dialogue entities
|
|
:ego "Wool is white as snow, but it keeps you warm."
|
|
:game-player "Good job, Tick! Now for your second riddle:"
|
|
:game-player "\"Filled with air, light as a feather,\nWant to keep it? Best have a tether.\""
|
|
:ego "Okay. Be back soon.")
|
|
(brian-get-to-work entities))))
|
|
:balloon (actions/get-script entities
|
|
(walk-to-player entities)
|
|
(when (offer-solution entities :balloon)
|
|
(do (actions/play-animation entities :ego :idea)
|
|
(brian-pause-from-work entities)
|
|
(actions/update-state entities (fn [s] (assoc s :current-riddle :frog-legs)))
|
|
(actions/remove-item entities :balloon)
|
|
(actions/do-dialogue entities
|
|
:ego "A balloon is light as a feather."
|
|
:game-player "That's right, Tick! Now for your third riddle:"
|
|
:game-player "\"Hippity-hop, I'd jump so high,\nWithout these springs, can't harm a fly.\""
|
|
:ego "Okay. Be back soon.")
|
|
(brian-get-to-work entities))))
|
|
:frog-legs (actions/get-script entities
|
|
(walk-to-player entities)
|
|
|
|
(when (offer-solution entities :frog-legs)
|
|
(if (= :frog-legs (get-in @entities [:state :current-riddle]))
|
|
(do (actions/play-animation entities :ego :idea)
|
|
(brian-pause-from-work entities)
|
|
(actions/update-state entities (fn [s] (assoc s :current-riddle :done)))
|
|
|
|
(actions/remove-item entities :frog-legs)
|
|
(actions/do-dialogue entities
|
|
:ego "What about these frog legs? They jump pretty far."
|
|
:game-player "Wow! That's right!"
|
|
:game-player "You, Tick, have proven yourself worthy of my trophy."
|
|
:game-player "Even I, Brian O'Brainy, am impressed with your wisdom."
|
|
:game-player "Take it, and go in wisdom.")
|
|
(actions/give entities :trophy)
|
|
(actions/remove-entity entities :trophy)
|
|
(actions/glad entities)
|
|
(actions/talk entities :ego "Thanks!")
|
|
(steam/set-achievement "WISE_UP")
|
|
)
|
|
))
|
|
(brian-get-to-work entities))
|
|
:trophy (actions/get-script entities
|
|
(walk-to-player entities)
|
|
(actions/talk entities :game-player "You can keep the trophy. You've earned it."))
|
|
(actions/get-script entities
|
|
(walk-to-player entities)
|
|
(condp = (get-in @entities [:state :current-riddle])
|
|
:done (actions/do-dialogue entities :game-player "I've gotten all the help I need with riddles today.")
|
|
nil (actions/do-dialogue entities :game-player "Why are you offering me this?")
|
|
(actions/do-dialogue entities :ego "What about this?" :game-player "No, that's not the solution. Keep looking."))))
|
|
:anim game-player-stand-down
|
|
:anim-start 0
|
|
:anim-merges {game-player-stand-down {:origin-x 8}
|
|
game-player-stand-up {:origin-x 3}
|
|
game-player-talk-up {:origin-x 3}
|
|
game-player-talk-down {:origin-x 8}
|
|
game-player-get-to-work {:origin-x 8}
|
|
game-player-pause-from-work {:origin-x 8}
|
|
game-player-flex {:origin-x 3}}
|
|
:left {:stand game-player-stand-down
|
|
:talk game-player-talk-down}
|
|
:right {:stand game-player-stand-up
|
|
:talk game-player-talk-up}
|
|
:get-to-work game-player-get-to-work
|
|
:pause-from-work game-player-pause-from-work
|
|
:flex-sound (utils/load-sound "inside-castle/flex.ogg")
|
|
:anim-sound-frames {game-player-stand-up {11 [:blink 0.3 1.1] }
|
|
game-player-talk-up {11 [:blink 0.3 1.1]
|
|
22 [:blink 0.3 1.1]
|
|
24 [:blink 0.3 1.1]
|
|
27 [:blink 0.3 1.1]}
|
|
game-player-stand-down {1 [:writing-sound 0.07]}
|
|
game-player-flex {1 [:flex-sound 0.5]}}
|
|
:flex game-player-flex)}
|
|
:monocle (rooms/make-entity :monocle (assoc (animation->texture screen monocle)
|
|
:label "A reflective thing"
|
|
:cursor :hand
|
|
:x 209 :y 160 :baseline 240
|
|
:origin-x 9
|
|
:anim monocle
|
|
:anim-start 0
|
|
:night-profile :none
|
|
:script (actions/get-script entities
|
|
(actions/walk-to entities :ego [213 87] :face :left)
|
|
(actions/talk entities :ego "There's something up there on the roof!"))
|
|
:scripts {:spear (actions/get-script entities
|
|
(actions/walk-to entities :ego [213 87] :face :left)
|
|
(actions/talk entities :ego "Maybe I can reach it with this.")
|
|
(actions/play-animation entities :ego :spear)
|
|
(actions/talk entities :ego "Got it!")
|
|
(actions/remove-entity entities :monocle)
|
|
(actions/give entities :monocle)
|
|
(actions/talk entities :ego "It looks like a monocle."))}))
|
|
|
|
:chorus {:sound (utils/load-sound "inside-castle/chorus.ogg")}
|
|
:collision "inside-castle/collision.png"
|
|
:scale-fn (utils/scaler-fn-from-image "inside-castle/scale.png" 0.25 1.00)
|
|
:apply-state (fn [screen entities]
|
|
(utils/fast-forward-particle (get-in entities [:room :entities :outside-particles]))
|
|
(as-> entities entities
|
|
(utils/play-sound! screen entities
|
|
(get-in entities [:room :chorus :sound])
|
|
get-chorus-volume
|
|
0.5
|
|
:loop)
|
|
(if (actions/has-obtained? entities :trophy)
|
|
(update-in entities [:room :entities] #(dissoc % :trophy))
|
|
entities)
|
|
(if (actions/has-item? entities :sword)
|
|
(update-in entities [:room :entities] #(dissoc % :sword))
|
|
entities)
|
|
(if (and (not (actions/has-item? entities :walkie-talkies))
|
|
(actions/has-obtained? entities :walkie-talkies))
|
|
entities
|
|
(update-in entities [:room :entities] dissoc :walkie-talkie))
|
|
(if (#{:night :sunrise} (get-in entities [:state :time]))
|
|
(make-night entities)
|
|
entities)))
|
|
|
|
:start-pos [245 90])))
|