(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.items :as items] [advent.utils :as utils] [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 [:actions :script-running?])) (get-in entities [:state :active?]) (get-in entities [:room :entities :game-player])) ((actions/get-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 (* (max 0.0 (- 1.0 (/ (utils/dist 45 97 (:x ego) (:y ego)) 50.0))) (- 1.0 (get-in entities [:fade :opacity])) (get-in entities [:volume :value] 1.0))))) (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) (sound! (utils/load-sound "inside-house/disappear.ogg") :play (utils/current-sound-volume)) (-> 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 [210 73] :face :right)) (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 "Caligraphy." :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, 'Disection 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 me...") (sound! (utils/load-sound "inside-castle/flex.ogg") :play (utils/current-sound-volume)) (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,\nIf you want 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/play-animation entities :ego :reach) (actions/pause-camera entities) (actions/transition-music entities :pull-sword) (actions/add-entity entities :blackout (get-in @entities [:room :blackout])) (actions/add-entity entities :pull-sword (get-in @entities [:room :pull-sword])) (actions/play-animation entities :pull-sword :pull-sword) (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/do-dialogue entities :ego "That was weird." :ego "I have to go show my friends!") (walk-to-blergh entities) (actions/add-entity entities :blergh (get-in @entities [:room :blergh])) (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 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) (actions/talk entities :ego "I'm just trying to impress Georgia McGorgeous." :anim :scared-talk) (actions/walk-straight-to entities :ego [75 45] :override-dir :right :anim :scared-walk :speed 0.5) (actions/talk entities :ego "I just... accidentally pulled the sword!":anim :scared-talk) (actions/walk-straight-to entities :ego [35 45] :override-dir :right :anim :scared-walk :speed 0.5) (actions/talk entities :ego "I wouldn't taste very good anyhow!" :anim :scared-talk) (actions/begin-animation entities :ego :scared) (actions/do-dialogue entities :bloodclot-head "'Fight he must for one more test,\nHe will die if not the best.'" :bloodclot-head "Ring any bells?" :bloodclot-head "Face it kiddo, you're no match for me, or my appetite." :bloodclot-head "And Georgia McGorgeous would never go for such a cowardly knight anyhow." :bloodclot-head "Let the feast begin.")) (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 :squat) (actions/do-dialogue entities :ego "'In the day when I shall be pulled,\nWith much strength a knight will take hold.'" :ego "'Courage will he need,\nWisdom he shall heed.'" :ego "'A final test remains, behold!'") (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/in-love entities) (actions/talk entities :ego "... I wonder what that last 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 make [screen] (let [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 [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" [7 7] 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} :timers {:brian [10.0 20.0 brian]} :interactions {:right-door {:box [286 140 306 160] :cursor :right :script (actions/get-script entities (actions/walk-to entities :ego [284 145] :skip-type :end) (actions/walk-straight-to entities :ego [295 145]) (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] :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 :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] :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] :script (actions/get-script entities (actions/talk entities :ego "Ye Ol' Antique Shoppe."))} :background-houses {:box [84 145 126 180] :script (actions/get-script entities (actions/walk-to entities :ego [79 145] :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] :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] :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] :script (actions/get-script entities (actions/do-dialogue entities :ego "That's Georgia McGorgeous' house." :ego "One day, when I'm a knight, I'll ask her to be my girlfriend.") (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 0 :y 0 :width 320 :height 240 :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)))) :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 1.0]}} ) :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") :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 :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") :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 :talk-color (color 1.0 0.3 0.2 1.0) :script (actions/get-script entities (do-game-player-dialogue entities)) :facing :left :scripts #(condp = % :wool (actions/get-script entities (walk-to-player entities) (if (= :wool (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 :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,\nIf you want to keep it, best have a tether.'" :ego "Okay. Be back soon.") (brian-get-to-work entities)) (actions/do-dialogue entities :ego "What about this?" :game-player "No, that's not the solution. Keep looking."))) :balloon (actions/get-script entities (walk-to-player entities) (if (= :balloon (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 :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)) (actions/do-dialogue entities :ego "What about this?" :game-player "No, that's not the solution. Keep looking."))) :frog-legs (actions/get-script entities (walk-to-player entities) (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!") (utils/snapshot-state @entities :after-wisdom)) (actions/do-dialogue entities :ego "What about this?" :game-player "No, that's not the solution. Keep looking.")) (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 :anim-sound-frames {game-player-stand-up {11 [:blink 0.3] }} :flex game-player-flex)} :monocle (rooms/make-entity :monocle (assoc (animation->texture screen monocle) :x 209 :y 160 :baseline 240 :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 [_ entities] (utils/fast-forward-particle (get-in entities [:room :entities :outside-particles])) (as-> entities entities (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))) :update-fn (fn [screen entities] #_(when (and (actions/has-obtained? entities :sword) (get-in entities [:room :entities :magic]) (particle-effect! (get-in entities [:room :entities :magic]) :is-complete)) ) (let [chorus-volume (get-chorus-volume entities)] (if (= 0.0 chorus-volume) (if (get-in entities [:room :chorus :instance]) (do (sound! (get-in entities [:room :chorus :sound]) :stop) (update-in entities [:room :chorus] dissoc :instance)) entities) (let [chorus (get-in entities [:room :chorus])] (if (:instance chorus) (do (sound! (:sound chorus) :set-volume (:instance chorus) (utils/current-sound-volume chorus-volume)) entities) (assoc-in entities [:room :chorus :instance] (sound! (:sound chorus) :loop (utils/current-sound-volume chorus-volume)))))))) :start-pos [245 90])))