887 lines
76 KiB
Clojure
887 lines
76 KiB
Clojure
(ns advent.screens.rooms.outside-house
|
|
(:require [advent.screens.items :as items]
|
|
[advent.screens.rooms :as rooms]
|
|
[advent.screens.rooms.common :as common]
|
|
[advent.screens.rooms.outside-castle :as outside-castle]
|
|
[advent.screens.rooms.inside-castle :as inside-castle]
|
|
[advent.actions :as actions]
|
|
[advent.tween :as tween]
|
|
[advent.steam :as steam]
|
|
[advent.utils :as utils]
|
|
[clojure.zip :as zip]
|
|
[clojure.string :as str]
|
|
[play-clj.core :refer :all]
|
|
[play-clj.ui :refer :all]
|
|
[play-clj.math :refer :all]
|
|
[play-clj.utils :refer :all]
|
|
[play-clj.g2d :refer :all]))
|
|
|
|
|
|
|
|
(defn dawn-fade [entities]
|
|
(actions/run-action entities
|
|
(begin [this screen entities]
|
|
(-> entities
|
|
(assoc-in [:tweens :dawn-r] (tween/tween :dawn-r screen [:time-profiles :default :r] :current 0.63 50.0 :entities entities))
|
|
(assoc-in [:tweens :dawn-g] (tween/tween :dawn-g screen [:time-profiles :default :g] :current 0.36 50.0 :entities entities))
|
|
(assoc-in [:tweens :dawn-b] (tween/tween :dawn-b screen [:time-profiles :default :b] :current 0.23 50.0 :entities entities))
|
|
(assoc-in [:tweens :hue-amount-v] (tween/tween :hue-amount-v screen [:time-profiles :default :hue-amount] :current 0.0 50.0 :entities entities))
|
|
(assoc-in [:tweens :multiply-amount-v] (tween/tween :multiply-amount-v screen [:time-profiles :default :multiply-amount] :current 0.0 50.0 :entities entities))
|
|
|
|
(assoc-in [:tweens :dawn-r-s] (tween/tween :dawn-r-s screen [:time-profiles :sprite :r] :current 0.63 50.0 :entities entities))
|
|
(assoc-in [:tweens :dawn-g-s] (tween/tween :dawn-g-s screen [:time-profiles :sprite :g] :current 0.36 50.0 :entities entities))
|
|
(assoc-in [:tweens :dawn-b-s] (tween/tween :dawn-b-s screen [:time-profiles :sprite :b] :current 0.23 50.0 :entities entities))
|
|
(assoc-in [:tweens :hue-amount-v-s] (tween/tween :hue-amount-v-s screen [:time-profiles :sprite :hue-amount] :current 0.0 50.0 :entities entities))
|
|
(assoc-in [:tweens :multiply-amount-v-s] (tween/tween :multiply-amount-v-s screen [:time-profiles :sprite :multiply-amount] :current 0.0 50.0 :entities entities))))
|
|
(continue [this screen entities]
|
|
entities)
|
|
(done? [this screen entities]
|
|
true)
|
|
(terminate [this screen entities]
|
|
entities)
|
|
(skip-type [this screen entities]
|
|
:none)))
|
|
|
|
|
|
(defn walk-to-castle [entities & {:keys [skip-type stop?] :or {skip-type :end stop? true}}]
|
|
(actions/walk-to entities :ego [0 80] :skip-type skip-type)
|
|
(actions/walk-straight-to entities :ego [-20 80])
|
|
(actions/transition-background entities :outside-castle [330 80])
|
|
(actions/walk-straight-to entities :ego [319 80] :stop? false)
|
|
(actions/walk-to entities :ego [273 81] :skip-type skip-type :stop? stop?))
|
|
|
|
(def ego-sheep-loc
|
|
[132 140])
|
|
|
|
(defn dist-to-sheep [entities]
|
|
(apply utils/dist (get-in entities [:room :entities :sheep :x]) (get-in entities [:room :entities :sheep :y])
|
|
ego-sheep-loc))
|
|
|
|
(defn is-sheep-close? [entities]
|
|
(< (dist-to-sheep entities) 50))
|
|
|
|
(defn is-ready-for-slingshot [entities]
|
|
(and (actions/has-obtained? entities :broken-clock)
|
|
(not (actions/has-item? entities :broken-clock))
|
|
(actions/has-obtained? entities :money)
|
|
(not (actions/has-item? entities :money))))
|
|
|
|
(defn set-sheep-anim [screen entities]
|
|
(if-let [wool-count (get-in entities [:state :wool-count])]
|
|
(update-in entities
|
|
[:room :entities :sheep]
|
|
#(actions/start-animation screen %
|
|
(get % [:stand wool-count])))
|
|
|
|
entities))
|
|
|
|
(defn walk-to-sheep [entities]
|
|
(actions/walk-to entities :ego [118 131] :skip-type :end))
|
|
|
|
(defn magic [entities]
|
|
(actions/run-action entities
|
|
(begin [this screen entities]
|
|
(doto (get-in entities [:room :entities :magic])
|
|
(particle-effect! :reset)
|
|
(particle-effect! :start))
|
|
entities)
|
|
(continue [this screen entities]
|
|
entities)
|
|
(done? [this screen entities]
|
|
(particle-effect! (get-in entities [:room :entities :magic]) :is-complete))
|
|
(terminate [this screen entities]
|
|
entities)
|
|
(skip-type [this screen entities]
|
|
:none)))
|
|
|
|
(defn put-something-in-cauldron [item]
|
|
(condp = item
|
|
:money (actions/get-script entities
|
|
(if (actions/has-item? entities :note-2)
|
|
(do
|
|
(actions/walk-to entities :ego [141 90] :face :right)
|
|
(actions/play-animation entities :ego :reach)
|
|
(actions/remove-item entities :money)
|
|
(actions/play-sound entities "outsidehouse/drop.ogg" 0.2)
|
|
(actions/camera-shake entities 2)
|
|
(Thread/sleep 500)
|
|
(actions/talk entities :ego "I guess that's what you could call 'money in the pot'."))
|
|
(actions/talk entities :ego "I don't want to put something in there unless I'm sure I need to.")))
|
|
:slingshot (actions/get-script entities
|
|
(if (is-ready-for-slingshot entities)
|
|
(do
|
|
(actions/walk-to entities :ego [141 90] :face :right)
|
|
(dawn-fade entities)
|
|
(actions/talk entities :ego "Here goes!")
|
|
(actions/play-animation entities :ego :reach-start :stop? false)
|
|
(actions/play-sound entities "outsidehouse/drop.ogg" 0.2)
|
|
(actions/camera-shake entities 12)
|
|
(actions/play-sound entities "outsidehouse/cauldron-done.ogg" 0.6 false)
|
|
(magic entities)
|
|
|
|
(actions/play-animation entities :ego :reach-stop :stop? true)
|
|
|
|
(actions/remove-item entities :slingshot :quiet? true )
|
|
(actions/give entities :magic-slingshot)
|
|
|
|
(actions/do-dialogue entities :ego "It worked!")
|
|
|
|
(actions/glad entities)
|
|
(actions/do-dialogue entities
|
|
:ego "I now have The Slinger's Shot."
|
|
:ego "And just in time, too. It's getting light.")
|
|
|
|
(actions/update-state entities #(assoc % :next-time :sunrise :seen-bloodclot? false))
|
|
(walk-to-castle entities :skip-type :none :stop? false)
|
|
(outside-castle/go-through-gate entities :skip-type :none :stop? false)
|
|
(actions/update-state entities #(assoc % :next-time :day))
|
|
(inside-castle/walk-to-blergh entities)
|
|
(actions/do-dialogue entities
|
|
:ego "Bloodclot!"
|
|
:bloodclot-head "Oh, hello again."
|
|
:bloodclot-head "I thought I had taken care of you the last time I saw you."
|
|
:bloodclot-head "Any final words before I destroy you again?")
|
|
(actions/play-animation entities :ego :scared :continue? true)
|
|
(Thread/sleep 500)
|
|
(actions/walk-straight-to entities :ego [35 45] :override-dir :right :speed 3.0))
|
|
(actions/talk entities :ego "I don't think it's ready yet.")))
|
|
:broken-clock (actions/get-script entities
|
|
(if (actions/has-item? entities :note-2)
|
|
(do
|
|
(actions/walk-to entities :ego [141 90] :face :right)
|
|
(actions/play-animation entities :ego :reach)
|
|
(actions/remove-item entities :broken-clock)
|
|
(actions/play-sound entities "outsidehouse/drop.ogg" 0.2)
|
|
(actions/camera-shake entities 2)
|
|
(Thread/sleep 500)
|
|
(actions/talk entities :ego "Just in the nick of time."))
|
|
(actions/talk entities :ego "I don't want to put something in there unless I'm sure I need to.")))
|
|
:recipe (actions/get-script entities
|
|
(actions/walk-to entities :ego [151 90] :face :right)
|
|
(actions/play-animation entities :ego :squat)
|
|
(actions/remove-item entities :recipe)
|
|
(actions/give entities :ash)
|
|
(actions/talk entities :ego "It burned up into ash."))
|
|
:spell-component (actions/get-script entities
|
|
(actions/walk-to entities :ego [141 90] :face :right)
|
|
(actions/play-animation entities :ego :reach)
|
|
(actions/remove-item entities :spell-component)
|
|
(actions/play-sound entities "outsidehouse/drop.ogg" 0.2)
|
|
(actions/camera-shake entities 2)
|
|
(Thread/sleep 500)
|
|
(actions/talk entities :ego "I poured it in. Now what?")
|
|
(utils/save-chapter @entities :chapter-5))
|
|
(actions/get-script entities
|
|
(actions/talk entities :ego "I don't want to put something in there unless I'm sure I need to."))))
|
|
|
|
|
|
(defn do-frog [entities]
|
|
(actions/talk entities :wizard "Grenouille CHALA!!!" :anim :talk-angry :stop? false)
|
|
(actions/play-sound entities "ending-castle/georgia-appear.ogg" 0.5 false)
|
|
(particle-effect! (get-in @entities [:room :entities :magic-frog-particle]) :reset)
|
|
(particle-effect! (get-in @entities [:room :entities :magic-frog-particle]) :start)
|
|
(actions/begin-animation entities :ego :frog)
|
|
(Thread/sleep 2000)
|
|
(actions/begin-animation entities :wizard :stand)
|
|
(Thread/sleep 1000)
|
|
(actions/do-dialogue entities
|
|
:wizard "I warned you, Tick."
|
|
:wizard "Now, I will return you to your true state if you leave me in peace."
|
|
:wizard "Do you promise?")
|
|
(actions/play-animation entities :ego :frog-nod :stop? false)
|
|
(actions/talk entities :wizard "Frustatium DISPOSIUM!!!" :anim :talk-angry :stop? false)
|
|
(actions/play-sound entities "ending-castle/georgia-appear.ogg" 0.5 false)
|
|
(particle-effect! (get-in @entities [:room :entities :magic-frog-particle]) :reset)
|
|
(particle-effect! (get-in @entities [:room :entities :magic-frog-particle]) :start)
|
|
(Thread/sleep 1500)
|
|
(actions/transition-background entities :outside-house [257 90] :face :left))
|
|
|
|
(defn do-prophecy [entities]
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "Well, let me remind you."
|
|
:wizard "\"On the day when it shall be pulled,\nWith much strength a knight will take hold.\""))
|
|
:choices
|
|
["Is this almost over?"
|
|
{:run #(do (actions/update-state entities (fn [state] (assoc state :convinced-wizard? true)))
|
|
(actions/respond entities %
|
|
:wizard "Patience, boy."
|
|
:wizard "\"Courage will he need,\nWisdom he shall heed."
|
|
:wizard "A final test remains, behold!\""
|
|
:wizard "If this is truly your quest, then I will help you. "
|
|
:ego "So you're my friend now, Gandarf?"
|
|
:wizard "No."))}
|
|
"*cough* *cough* *ahem*"
|
|
{:run #(do (actions/update-state entities (fn [state] (assoc state :convinced-wizard? true)))
|
|
(actions/respond entities %
|
|
:wizard "Excuse you. Moving on..."
|
|
:wizard "\"Courage will he need,\nWisdom he shall heed."
|
|
:wizard "A final test remains, behold!\""
|
|
:wizard "If this is truly your quest, then I will help you. "
|
|
:ego "So you're my friend now, Gandarf?"
|
|
:wizard "No.")
|
|
(utils/save @entities "autosave" "Autosave"))}]})
|
|
|
|
(defn wizard-dialogue [entities]
|
|
(if (get-in @entities [:state :has-met-gandarf?])
|
|
(do (actions/do-dialogue entities :ego "Hello again, Gandarf!"
|
|
:wizard "Not you again!")
|
|
(actions/talk entities :wizard "I command you, leave at once!" :anim :talk-angry :stop? false)
|
|
(actions/talk entities :wizard "Don't make me use my powers against you!" :anim :talk-angry :stop? false)
|
|
(actions/talk entities :wizard "Leave now, or else!" :anim :talk-angry :stop? false)
|
|
(actions/begin-animation entities :wizard :magic-hands))
|
|
(do (actions/do-dialogue entities :ego "Hello there, Gandarf!"
|
|
:wizard "Oh no, not you!"
|
|
:ego "What do you mean, 'not you!'?"
|
|
:wizard "I mean, you've wrecked my life!"
|
|
:wizard "I never want to see the likes of you again!"
|
|
:wizard "Leave!"
|
|
:ego "But...")
|
|
(actions/talk entities :wizard "I command you, by all the power I can muster..." :anim :talk-angry :stop? false)
|
|
(actions/talk entities :wizard "Leave now, or else!" :anim :talk-angry :stop? false)
|
|
(actions/begin-animation entities :wizard :magic-hands)))
|
|
(actions/update-state entities (fn [s] (assoc s :has-met-gandarf? true)))
|
|
(actions/present-choices entities
|
|
{:choices ["Surely you can't still be angry with me!"
|
|
{:run #(actions/respond entities % :wizard "I can't?"
|
|
:wizard "Do you even remember what you did?")
|
|
:choices ["You mean the time I set your house on fire with a lava mint?"
|
|
{:run #(do
|
|
(actions/respond entities %
|
|
:wizard "No, of course n-")
|
|
(Thread/sleep 500)
|
|
(actions/do-dialogue entities :wizard "Wait... that was you!?" :wizard "My house was completely destroyed!")
|
|
(Thread/sleep 500)
|
|
(actions/talk entities :wizard "I had to move out of town into this shack!" :anim :talk-angry :stop? false)
|
|
(actions/talk entities :wizard "Leave, now, or I'll turn you into a ..." :anim :talk-angry :stop? false)
|
|
(actions/talk entities :wizard "... a ..." :anim :talk-angry :stop? false)
|
|
(actions/talk entities :wizard "... a pack of matches!" :anim :talk-angry)
|
|
(actions/begin-animation entities :wizard :magic-hands)
|
|
(actions/talk entities :ego "Okay, okay, I'm leaving!")
|
|
(actions/transition-background entities :outside-house [257 90] :face :left)
|
|
(actions/play-animation entities :ego :sigh)
|
|
(actions/do-dialogue entities :ego "It seems like his temper is on fire."
|
|
:ego "Sort of like his house was."))}
|
|
"You're still cross about my stealing your magic cowboy hat?"
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "Of course I'm cross! It's irreplaceable!"
|
|
:wizard "That cowboy hat accented my facial physique."
|
|
:wizard "And complemented my skin color."
|
|
:wizard "And you, little pipsqueak, stole it from me!"
|
|
:wizard "That's why I bought my MagiSafe 5000: To keep out intruders like you.")
|
|
(actions/talk entities :wizard "Now leave, before I force you out!" :anim :talk-angry :stop? false)
|
|
(actions/begin-animation entities :wizard :magic-hands)
|
|
(actions/transition-background entities :outside-house [257 90] :face :left)
|
|
(actions/do-dialogue entities :ego "I guess he's really upset about that cowboy hat!"))}
|
|
"Maybe the time I freed your pet dragon?"
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "Of course I mean that!"
|
|
:wizard "I've raised Snaggletooth from the day he was born."
|
|
:wizard "Raised him as my own, I did."
|
|
:wizard "47 long years."
|
|
:wizard "All for nothing!")
|
|
(actions/talk entities :wizard "Give me one reason I shouldn't turn you into a replacement dragon right now!"
|
|
:anim :talk-angry :stop? false)
|
|
(actions/begin-animation entities :wizard :magic-hands))
|
|
:choices ["Frankie Rockfist and his gang made me do it!"
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "Frankie Rockfist, eh?"
|
|
:wizard "What kind of dumb name is Frankie Rockfist?!"
|
|
)
|
|
(Thread/sleep 1000)
|
|
(actions/talk entities :wizard "You think I'm stupid enough to fall for that?!" :anim :talk-angry :stop? false)
|
|
(actions/talk entities :wizard "It's time to teach you a lesson." :anim :talk-angry :stop? false)
|
|
(do-frog entities)
|
|
(actions/do-dialogue entities :ego "Phew!"
|
|
:ego "I thought I had nearly croaked!"))}
|
|
|
|
"I'm on an important quest!"
|
|
{:run #(actions/respond entities % :wizard "Eh?"
|
|
:wizard "Pray tell, what kind of quest?")
|
|
:choices ["To leave this house with some of your belongings."
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "My belongings!?")
|
|
(actions/talk entities :wizard "Why you little!" :anim :talk-angry :stop? false)
|
|
(actions/begin-animation entities :wizard :magic-hands)
|
|
(do-frog entities)
|
|
(actions/talk entities :ego "Gandarf is such a stingy old toad."))}
|
|
"To find you a brand new dragon."
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "Great idea, Tick!"
|
|
:wizard "You'd make the perfect base for a dragon-bait stew!"
|
|
:wizard "Let me just summon my boy-sized cooking pot.")
|
|
(actions/talk entities :wizard "Boildrum Ka...." :anim :talk-angry :stop? false)
|
|
(actions/begin-animation entities :wizard :magic-hands)
|
|
(actions/do-dialogue entities :ego "On second thought..."
|
|
:ego "I realized I have a busy schedule this morning."
|
|
:ego "Ciao!")
|
|
(actions/transition-background entities :outside-house [257 90] :face :left)
|
|
(actions/talk entities :ego "That Gandarf can be a real fire under my bum."))}
|
|
"To become a knight of the town of Remington."
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "You are, are you?"
|
|
:wizard "And how do you, a mere reckless youth, plan on becoming a knight?"))
|
|
:choices ["Well I had this dream..."
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "I had a dream last night too, Tick."
|
|
:ego "You did?"
|
|
:wizard "Yes."
|
|
:wizard "I dreamed I was an earthworm."
|
|
:wizard "And you'd never guess what happened when I woke up."
|
|
:ego "What?"
|
|
:wizard "Nothing. I had some indigestion."
|
|
:wizard "Dreams aren't all they're chocked up to be."
|
|
:wizard "Face it, boy, it was just a dream. "
|
|
:wizard "You'll never be a knight."
|
|
:wizard "Now go.")
|
|
(actions/transition-background entities :outside-house [257 90] :face :left)
|
|
(actions/play-animation entities :ego :sigh))}
|
|
"By pulling the Sword of Blergh from its stone!"
|
|
{:run #(actions/respond entities %
|
|
:wizard "You mean to fulfill the ancient prophecy?"
|
|
:wizard "Only one worthy in courage, wisdom, and might can pull it."
|
|
:wizard "You'd never measure up!"
|
|
:ego "Well maybe you could help me?"
|
|
:wizard "I appreciate your spirit, Tick, but why is it so important for you to become a knight?")
|
|
:choices ["I want to impress Georgia McGorgeous."
|
|
{:run #(do (actions/respond entities %
|
|
:ego "You know, win her heart and everything.")
|
|
(actions/georgia-say entities "Win my heart, Tick! You can do it!")
|
|
(actions/do-dialogue entities
|
|
:wizard "Ahem."
|
|
:wizard "Well, I suppose no man can argue with true love."
|
|
:wizard "Me least of all."
|
|
:wizard "I'm still a bachelor myself.")
|
|
(Thread/sleep 1000)
|
|
(actions/do-dialogue entities
|
|
:wizard "I have decided."
|
|
:wizard "I will help you."
|
|
:wizard "Your cause is noble, and your heart is just."
|
|
:wizard "Just don't let me catch you stealing my belongings.")
|
|
(Thread/sleep 1000)
|
|
(actions/do-dialogue entities :wizard "Now, Tick, do you know the prophecy of the Sword of Blergh?"))
|
|
:choices ["Yes."
|
|
(do-prophecy entities)
|
|
"No."
|
|
(do-prophecy entities)]}
|
|
"I want to have the name 'Sir Tick.'"
|
|
{:run #(actions/respond entities %
|
|
:wizard "\"Sir Tick.\""
|
|
:ego "It does have a nice ring to it."
|
|
:ego "Wouldn't you say?"
|
|
:wizard "It does indeed!"
|
|
:wizard "But the title comes after the deed, boy."
|
|
:wizard "You must have a more noble reason to become a knight."
|
|
)
|
|
:choices actions/previous-choices}
|
|
"I want to be famous."
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "Did you ever hear the story of Young Sir Gypsum?"
|
|
:ego "I don't think so."
|
|
:wizard "Well he went off on many quests, seeking fame and fortune.")
|
|
(Thread/sleep 3000)
|
|
(actions/do-dialogue entities
|
|
:ego "... and?"
|
|
:wizard "And what?"
|
|
:ego "And what happened to Young Sir Gypsum?"
|
|
:wizard "Nobody remembers!"
|
|
:wizard "Fame is a fickle friend."))
|
|
:choices actions/previous-choices}
|
|
"I wanteth to speaketh like the other knights."
|
|
{:run #(actions/respond entities %
|
|
:wizard "Oh, dost thou?"
|
|
:wizard "Surely thou doth know that thou can speaketh in this manner."
|
|
:wizard "Thy tongue requireth neither sword nor title.")
|
|
:choices actions/previous-choices}]}
|
|
"By besting traps, beasts, and long, boring, conversations with old geezers."
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "Quite right, quite right.")
|
|
(Thread/sleep 1000)
|
|
(actions/do-dialogue entities
|
|
:wizard "Wait."
|
|
:wizard "What \"old geezer\" are you referring to?"
|
|
:ego "Umm...")
|
|
(actions/talk entities :wizard "You don't happen to be referring to me, do you?" :anim :talk-angry :stop? false)
|
|
(actions/begin-animation entities :wizard :magic-hands)
|
|
(actions/do-dialogue entities :ego "Well, I..."
|
|
:ego "That is to say, I..."
|
|
:ego "... Oh boy.")
|
|
(do-frog entities)
|
|
(actions/play-animation entities :ego :sigh))}]}
|
|
"To improve my standing in the community."
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "Ha! Good standing?"
|
|
:wizard "You're the neighborhood cheat and everyone knows it."
|
|
:wizard "I'm afraid your standing is irreparable."
|
|
:wizard "Now leave me to mourn ol' Snaggletooth.")
|
|
(actions/transition-background entities :outside-house [257 90] :face :left)
|
|
(actions/play-animation entities :ego :sigh))}
|
|
]}
|
|
"Snaggletooth deserved a free life, you old geezer!"
|
|
{:run #(do (actions/respond entities % :wizard "Why, you..."
|
|
:wizard "Snaggletooth was my friend!")
|
|
(Thread/sleep 1000)
|
|
(do-frog entities)
|
|
(actions/talk entities :ego "Phew!")
|
|
(actions/talk entities :ego "I thought I had ribbit the dust!"))}
|
|
|
|
]}
|
|
|
|
]}
|
|
"But I'm your friend, Gandarf!"
|
|
{:run #(do (actions/respond entities % :wizard "Friend? "
|
|
:wizard "What kind of friend would do what you did to me?")
|
|
(Thread/sleep 500)
|
|
(actions/talk entities :wizard "You don't even remember what you did, do you?"))
|
|
:choices #(-> % zip/left zip/left)}
|
|
"Or else what?"
|
|
{:run #(do (actions/talk entities :ego %)
|
|
(actions/talk entities :wizard "Or else I'll turn you into a frog!" :anim :talk-angry :stop? false)
|
|
(actions/begin-animation entities :wizard :magic-hands))
|
|
:choices ["You don't scare me."
|
|
{:run
|
|
#(do
|
|
(actions/talk entities :ego %)
|
|
(actions/talk entities :wizard "You asked for it, boy." :anim :talk-angry :stop? false)
|
|
(do-frog entities))
|
|
}
|
|
"On second thought..."
|
|
{:run #(actions/do-dialogue entities :ego %)
|
|
:choices actions/something-else}
|
|
"Okay, okay, I'm leaving."
|
|
{:run
|
|
#(do
|
|
(actions/talk entities :ego %)
|
|
(actions/transition-background entities :outside-house [257 90] :face :left))}]}
|
|
"Okay, okay, I'm leaving."
|
|
{:run #(do
|
|
(actions/talk entities :ego %)
|
|
(actions/talk entities :wizard "Good riddance!" :anim :talk-angry)
|
|
(actions/transition-background entities :outside-house [257 90] :face :left))}]}))
|
|
|
|
|
|
(defn talk-to-gandarf-outside [entities]
|
|
(actions/walk-to entities :ego [120 80] :face :right)
|
|
(if (actions/has-item? entities :flask-2)
|
|
(actions/do-dialogue entities :wizard "Have you gotten me water from the fountain yet?"
|
|
:ego "No, not yet."
|
|
:wizard "Hurry, boy! Time's-a-wastin'!")
|
|
(do
|
|
(actions/do-dialogue entities :ego "Gandarf! Boy, am I glad to see you."
|
|
:wizard "I'm busy. What is it, Tick?")
|
|
(actions/present-choices entities
|
|
{:choices ["I got put in jail!"
|
|
{:run #(actions/respond entities %
|
|
:wizard "What for, boy?"
|
|
:ego "For borrowing the Duke's ladder."
|
|
:wizard "Hoooo boy, you don't \"borrow\" from the Duke!"
|
|
:wizard "Everyone knows that!"
|
|
:wizard "You're lucky he didn't have your head!")
|
|
:choices actions/previous-choices}
|
|
"I pulled the sword!"
|
|
{:run #(actions/respond entities %
|
|
:wizard "You did?"
|
|
:wizard "Congratulations, Tick!"
|
|
:wizard "Meanwhile, my life hasn't been going so great."
|
|
:wizard "Someone broke into my MagiSafe 5000 and stole some things from my hut."
|
|
:ego "Oh."
|
|
:ego "How awful!")
|
|
:choices actions/previous-choices}
|
|
"Bloodclot is on the loose!"
|
|
{:run #(do (actions/respond entities %
|
|
:wizard "Bloodclot?"
|
|
:wizard "You can't mean the goblin Bloodclot?"
|
|
:wizard "If you did, you'd be burned to a crisp from his lightning gem!"
|
|
:ego "Yes, that Bloodclot!"
|
|
:wizard "I knew that there would be a \"final test\" for the hero who pulled the blade..."
|
|
:wizard "But I had never imagined this."
|
|
:wizard "There's only one way to neutralize his lightning magic:"
|
|
:wizard "The Slinger's Shot."
|
|
:wizard "It's a magical slingshot that has long lost its power."
|
|
:wizard "Here, take it.")
|
|
(actions/give entities :slingshot)
|
|
(actions/do-dialogue entities
|
|
:wizard "Whatever happens, do not lose that slingshot!"
|
|
:wizard "You and me, boy, we're going to return it to its powerful state."
|
|
:wizard "Then you can beat Bloodclot, come sunrise."
|
|
:wizard "Now, time is of the essence."
|
|
:wizard "Take this flask. Fill it with water from the fountain."
|
|
:wizard "And remember. Don't lose the slingshot.")
|
|
(actions/give entities :flask-2))}
|
|
"See ya."
|
|
{:run #(actions/respond entities % :wizard "See you around.")}]}))))
|
|
|
|
(defn add-wizard-if-necessary [entities]
|
|
(if (get-in entities [:state :seen-frankie?])
|
|
entities
|
|
(update-in entities [:room :entities] #(assoc % :wizard (get-in entities [:room :wizard])))))
|
|
|
|
(defn add-note-if-necessary [entities]
|
|
(if (and (get-in entities [:state :seen-frankie?])
|
|
(not (actions/has-obtained? entities :note-1)))
|
|
(update-in entities [:room :entities] #(assoc % :note (get-in entities [:room :note])))
|
|
entities))
|
|
|
|
(defn add-charcoal-if-necessary [entities]
|
|
(if (and (get-in entities [:state :seen-frankie?])
|
|
(not (actions/has-obtained? entities :charcoal)))
|
|
(update-in entities [:room :entities] assoc :charcoal (get-in entities [:room :charcoal]))
|
|
entities))
|
|
|
|
(defn make-night [screen entities]
|
|
|
|
(as-> entities entities
|
|
|
|
(update-in entities [:room :entities] #(dissoc % :butterfly))
|
|
(update-in entities [:room :entities] #(assoc % :cauldron (get-in entities [:room :cauldron])))
|
|
(add-charcoal-if-necessary entities)
|
|
(utils/play-sound! screen entities
|
|
(get-in entities [:room :cauldron-sound :sound])
|
|
(utils/sourced-volume-fn :cauldron 0.15 [139 73])
|
|
(utils/get-sound-pan 139)
|
|
:loop)
|
|
(add-wizard-if-necessary entities)
|
|
(add-note-if-necessary entities)))
|
|
|
|
(defn move-toward [screen entities {:keys [x y] :as e} target-x]
|
|
(let [delta-x (- target-x x)
|
|
speed (* 1.0
|
|
(/ (:delta-time screen)
|
|
(/ 1.0 60.0)))
|
|
speed (if (< delta-x 0) (- speed) speed)
|
|
moved-x (if (< (Math/abs (int delta-x)) speed)
|
|
target-x
|
|
(* speed (/ delta-x delta-x) ))]
|
|
(if (< (Math/abs (int delta-x)) speed)
|
|
(actions/start-animation screen
|
|
(dissoc e :target-x)
|
|
:stand)
|
|
|
|
(actions/start-animation screen
|
|
(assoc (actions/jump-to screen entities e [(+ moved-x x) y] false)
|
|
:facing (cond (< delta-x 0) :left
|
|
(> delta-x 0) :right
|
|
:else (:facing e)))
|
|
:walk))))
|
|
|
|
(defn jump-around [screen entities]
|
|
(if-let [target-x (get-in entities [:room :entities :lamb :target-x])]
|
|
(update-in entities [:room :entities :lamb]
|
|
#(move-toward screen entities % target-x))
|
|
(if (= 1 (rand-int 50))
|
|
(assoc-in entities [:room :entities :lamb :target-x] (rand-nth [30 10 60 70]))
|
|
entities)))
|
|
|
|
|
|
(defn examine-cauldron [entities]
|
|
(let [put-clock (and (actions/has-obtained? entities :broken-clock)
|
|
(not (actions/has-item? entities :broken-clock)))
|
|
put-money (and (actions/has-obtained? entities :money)
|
|
(not (actions/has-item? entities :money)))
|
|
note-2-requirements (filter identity [(when (not put-money)
|
|
"the root of all evil")
|
|
(when (not put-clock)
|
|
"a split second")])]
|
|
|
|
(cond (actions/has-item? entities :note-2)
|
|
(do (actions/do-dialogue entities :ego "According to Gandarf's note...")
|
|
(if (seq note-2-requirements)
|
|
(actions/do-dialogue entities :ego (str "I need to add " (str/join " and " note-2-requirements) ".")
|
|
:ego "Then dip in the Slinger's Shot.")
|
|
(actions/do-dialogue entities :ego "I just need to dip in the Slinger's Shot.")))
|
|
|
|
(and (not (actions/has-item? entities :spell-component))
|
|
(actions/has-obtained? entities :spell-component))
|
|
(actions/do-dialogue entities
|
|
:ego "I added the contents of the flask."
|
|
:ego "But now what?")
|
|
|
|
(actions/has-item? entities :note-1)
|
|
(actions/do-dialogue entities :ego "According to Gandarf's note..."
|
|
:ego "I need to mix some stuff up in a flask and dump it in here.")
|
|
:else
|
|
(actions/talk entities :ego "That's a big cauldron!"))))
|
|
|
|
|
|
(defn make [screen atlas global-atlas]
|
|
(let [sheep-stand-sheet (texture! (utils/atlas->texture atlas "sheep-anim") :split 33 21)
|
|
sheep-walk-sheet (texture! (utils/atlas->texture atlas "sheep-walk") :split 33 21)
|
|
lamb-walk-sheet (texture! (utils/atlas->texture atlas "lamb-walk") :split 27 28)
|
|
sheep-stand (animation 0.15 (for [i (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 2 1 (repeat 25 11) (repeat 15 12)])]
|
|
(aget sheep-stand-sheet 0 i)))
|
|
sheep-1 (utils/make-anim atlas "sheep-1" [33 21] 0.15 (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 2 1 (repeat 25 0) (repeat 15 9)]))
|
|
sheep-2 (utils/make-anim atlas "sheep-2" [33 21] 0.15 (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 2 1 (repeat 25 0) (repeat 15 9)]))
|
|
sheep-3 (utils/make-anim atlas "sheep-3" [33 21] 0.15 (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 2 1 (repeat 25 0) (repeat 15 9)]))
|
|
door (utils/make-anim atlas "door" [24 58] 0.15 (flatten [(range 4) 3 3 3 3 3 3 3]))
|
|
door-closed (utils/make-anim atlas "door" [24 58] 0.15 [0])
|
|
sheep-walk (animation 0.05 (for [i (range 6)]
|
|
(aget sheep-walk-sheet 0 i)))
|
|
butterfly-stand (utils/make-anim atlas "butterfly" [7 7] 0.1 [0 1])
|
|
cauldron (utils/make-anim atlas "cauldron" [50 38] 0.15 (range 4))
|
|
charcoal (utils/make-anim-seq atlas "charcoal" [24 18] 0.25 (range 4))
|
|
scaler (utils/scaler-fn-with-baseline 110 0.10 1.00)
|
|
lamb-stand (aget lamb-walk-sheet 0 0)
|
|
lamb-walk (animation 0.075 (for [i (range 4)]
|
|
(aget lamb-walk-sheet 0 i)))]
|
|
(rooms/make :music {:day :town-2 :night :night}
|
|
:name "Outside house"
|
|
:update-fn jump-around
|
|
:cauldron-sound {:object nil :sound (utils/load-sound "outsidehouse/cauldron.ogg")}
|
|
:interactions
|
|
{:door {:box [250 100 281 160]
|
|
:only-script
|
|
(actions/get-script
|
|
entities
|
|
(actions/walk-to entities :ego [257 90] :face :right :skip-type :end)
|
|
(actions/talk entities :ego (str "Anyone home?"))
|
|
(actions/play-animation entities :ego :reach)
|
|
(cond
|
|
(get-in @entities [:room :entities :wizard])
|
|
(actions/do-dialogue entities :wizard "What are you doing, boy?"
|
|
:wizard "I'm right here.")
|
|
|
|
(= :night (get-in @entities [:state :time]))
|
|
(actions/talk entities :ego "It's locked.")
|
|
|
|
:else
|
|
(do (actions/play-animation entities :door :open)
|
|
(actions/transition-background entities :inside-house [237 0] :between (fn [s e]
|
|
(if (= 1 (rand-int 5))
|
|
(assoc-in e [:room :entities :experiment] (get-in e [:room :experiment]))
|
|
e)))
|
|
(when (get-in @entities [:room :entities :experiment])
|
|
(actions/play-animation entities :experiment :experiment)
|
|
(actions/remove-entity entities :experiment))
|
|
|
|
(if (get-in @entities [:state :convinced-wizard?])
|
|
(do (actions/talk entities :wizard "Oh, hello there, boy.")
|
|
(utils/save @entities "autosave" "Autosave"))
|
|
(wizard-dialogue entities)))))
|
|
:cursor :right}
|
|
|
|
:right-dir {:box [220 141 320 204]
|
|
:only-script (actions/get-script
|
|
entities
|
|
(actions/walk-to entities :ego [244 150] :skip-type :end)
|
|
(actions/transition-background entities :behind-house [122 140])
|
|
(actions/walk-to entities :ego [172 122]))
|
|
:cursor :right}
|
|
:up-dir {:box [105 180 203 240]
|
|
:only-script (actions/get-script
|
|
entities
|
|
(actions/walk-to entities :ego [137 204] :skip-type :end)
|
|
(actions/transition-background entities :cat-tree [223 -51])
|
|
(actions/walk-straight-to entities :ego [200 10]))
|
|
:cursor :up}
|
|
:left-dir {:box [0 40 40 140]
|
|
:only-script (actions/get-script
|
|
entities
|
|
(walk-to-castle entities))
|
|
:cursor :left}}
|
|
:layers {:day [(assoc (utils/atlas->texture atlas "background") :x 0 :y 0 :baseline 0)
|
|
(assoc (utils/atlas->texture atlas "house") :x 0 :y 0 :baseline 122)
|
|
(assoc (utils/atlas->texture atlas "fence") :x 0 :y 0 :baseline 93)
|
|
|
|
(assoc (utils/atlas->texture atlas "background-trees") :x 0 :y 0 :baseline 44)
|
|
(assoc (utils/atlas->texture atlas "fg1") :x 0 :y 0 :baseline 1000 :parallax 1.5)
|
|
(assoc (utils/atlas->texture atlas "fg2") :x (- 320 55) :y 0 :baseline 1000 :parallax 1.5)]
|
|
:night [(assoc (utils/atlas->texture atlas "background") :x 0 :y 0 :baseline 0)
|
|
(assoc (utils/atlas->texture atlas "house") :x 0 :y 0 :baseline 122)
|
|
(assoc (utils/atlas->texture atlas "fence") :x 0 :y 0 :baseline 93)
|
|
|
|
(assoc (utils/atlas->texture atlas "background-trees") :x 0 :y 0 :baseline 44)
|
|
(assoc (utils/atlas->texture atlas "fg1") :x 0 :y 0 :baseline 1000 :parallax 1.5)
|
|
(assoc (utils/atlas->texture atlas "fg2") :x (- 320 55) :y 0 :baseline 1000 :parallax 1.5)]}
|
|
:entities {:sheep (actions/start-animation screen
|
|
(assoc (animation->texture screen sheep-stand) :x 38 :y 160 :baseline 80
|
|
[:stand 1] sheep-1
|
|
[:stand 2] sheep-2
|
|
[:stand 3] sheep-3
|
|
:label "Sheep"
|
|
:cursor :hand
|
|
:origin-y 3
|
|
:origin-x 6
|
|
:scale-x (scaler [38 160])
|
|
:scale-y (scaler [38 160])
|
|
:script (actions/get-script
|
|
entities
|
|
|
|
(if (= 3 (get-in @entities [:state :wool-count]))
|
|
(actions/talk entities :ego "Do you think she feels sheepish without any clothes?")
|
|
|
|
(if (actions/has-item? entities :wool)
|
|
(actions/talk entities :ego "Maybe I should use the wool I have before taking any more.")
|
|
(if (is-sheep-close? @entities)
|
|
(do (walk-to-sheep entities)
|
|
(actions/play-animation entities :ego :reach)
|
|
(actions/update-state entities #(assoc % :wool-count (inc (or (:wool-count %) 0))))
|
|
(when (= 3 (get-in @entities [:state :wool-count]))
|
|
(steam/set-achievement "SHEEP_HORDER"))
|
|
|
|
(actions/update-entities entities #(update-in
|
|
% [:room :entities :sheep]
|
|
(fn [s]
|
|
(let [which (get-in % [:state :wool-count])]
|
|
(assoc s :anim (get s [:stand which]))))))
|
|
(actions/give entities :wool)
|
|
(actions/talk entities :ego "I guess her wool is shedding."))
|
|
(do
|
|
(walk-to-sheep entities)
|
|
(actions/talk entities :ego "Come here, mama sheep!")
|
|
(actions/play-animation entities :ego :sigh)
|
|
(actions/talk entities :ego "She's too far away for me to pet her.")
|
|
)))))
|
|
:scripts #(condp = %
|
|
:wool (actions/get-script entities
|
|
(actions/talk entities :ego "She doesn't need it back."))
|
|
:grass (actions/get-script entities
|
|
(walk-to-sheep entities)
|
|
(actions/talk entities :ego "Come on, girl, get the grass!")
|
|
(actions/play-animation entities :ego :reach)
|
|
(actions/talk entities :ego "I think she's not interested.")
|
|
)
|
|
:carrot (actions/get-script entities
|
|
(walk-to-sheep entities)
|
|
(actions/talk entities :ego "Come on, girl, get the carrot!")
|
|
(actions/walk-straight-to entities :sheep [85 138] :update-baseline? false)
|
|
(actions/play-animation entities :ego :reach)
|
|
(actions/remove-item entities :carrot)
|
|
(actions/update-state entities (fn [s] (assoc s :coaxed-sheep? true)))
|
|
)
|
|
:flask-1 (actions/get-script entities
|
|
(if (actions/has-item? entities :recipe)
|
|
(if (is-sheep-close? @entities)
|
|
(do (walk-to-sheep entities)
|
|
(actions/play-animation entities :ego :milk)
|
|
(actions/remove-item entities :flask-1 :quiet? true)
|
|
(actions/give entities :flask-1-with-milk)
|
|
(actions/talk entities :ego "Sheep's milk.")
|
|
)
|
|
(actions/talk entities :ego "She's too far away."))
|
|
(actions/do-dialogue entities :ego "I'd like a nice glass of milk."
|
|
:ego "But sheep's milk is too creamy for me.")))
|
|
:flask-1-with-mushrooms
|
|
(actions/get-script entities
|
|
(if (is-sheep-close? @entities)
|
|
(do (walk-to-sheep entities)
|
|
(actions/play-animation entities :ego :milk)
|
|
(items/make-cream-of-mushroom entities)
|
|
)
|
|
(actions/talk entities :ego "She's too far away.")))
|
|
|
|
:sword
|
|
(actions/get-script entities
|
|
(actions/talk entities :ego "That's just cruel."))
|
|
nil)
|
|
|
|
:eat-sound (utils/load-sound "outsidehouse/sheep-eat.ogg")
|
|
:bleet-sound (utils/load-sound "outsidehouse/sheep-bleet.ogg")
|
|
:anim-sound-frames {sheep-stand {11 [:eat-sound 0.3]
|
|
35 [:bleet-sound 0.5]}}
|
|
:left {:walk (utils/flip sheep-walk)
|
|
:stand (utils/flip sheep-stand)}
|
|
:right {:walk sheep-walk
|
|
:stand sheep-stand}
|
|
:scaled true)
|
|
sheep-stand)
|
|
|
|
|
|
:outside-particles (common/make-outside-particles)
|
|
:magic (assoc (particle-effect "particles/magic")
|
|
:x 153
|
|
:y 105
|
|
:baseline 238)
|
|
:door (assoc (animation->texture screen door-closed)
|
|
:x 252 :y 88 :baseline 123
|
|
:open door
|
|
:door-sound (utils/load-sound "door.ogg")
|
|
:anim-sound-frames {door {1 [:door-sound 0.1]}}
|
|
)
|
|
:lamb (assoc (utils/atlas->texture atlas "lamb")
|
|
:cursor :look
|
|
:label "Baby lamb"
|
|
:x 10 :y 163 :baseline 77
|
|
:right {:stand (animation 0.1 [lamb-stand])
|
|
:walk lamb-walk}
|
|
|
|
:left {:stand (utils/flip (animation 0.1 [lamb-stand]))
|
|
:walk (utils/flip lamb-walk)}
|
|
:scale-x (scaler [10 163])
|
|
:scale-y (scaler [10 163])
|
|
:script (actions/get-script entities
|
|
(actions/talk entities :ego "Aww, it's a newborn lamb!"))
|
|
:scripts {:carrot (actions/get-script entities (actions/talk entities :ego "I think it's still nursing."))
|
|
:grass (actions/get-script entities (actions/talk entities :ego "I think it's still nursing."))
|
|
:sword (actions/get-script entities (actions/talk entities :ego "I prefer to let the butcher make lamb chops."))})
|
|
:butterfly (assoc (animation->texture screen butterfly-stand)
|
|
:x 161
|
|
:y 218
|
|
:baseline 240
|
|
:anim butterfly-stand
|
|
:anim-start 0
|
|
:path (catmull-rom-spline (map #(apply vector-2* %) (take 10 (repeatedly #(vector (rand-int 320) (rand-int 180))))) true)
|
|
:update-fn (fn [screen entities entity]
|
|
(let [speed 0.009
|
|
pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed)))
|
|
v (vector-2 0 0)
|
|
a (catmull-rom-spline! ^CatmullRomSpline (:path entity) :value-at v pos-f)]
|
|
(assoc entity :x (vector-2! v :x) :y (vector-2! v :y)))))}
|
|
:cauldron (rooms/make-entity :cauldron (assoc (animation->texture screen cauldron)
|
|
:cursor :look
|
|
:x 139 :y 73 :baseline 167
|
|
:label "Magical cauldron"
|
|
:anim cauldron
|
|
:anim-start 0
|
|
:night-profile :none
|
|
:script (actions/get-script entities
|
|
(examine-cauldron entities))
|
|
:scripts put-something-in-cauldron))
|
|
:charcoal (rooms/make-entity :charcoal
|
|
(assoc (animation->texture screen charcoal)
|
|
:cursor :hand
|
|
:label "Charcoal"
|
|
:anim charcoal
|
|
:anim-start 0
|
|
:night-profile :none
|
|
:x 119 :y 73 :baseline 167
|
|
:script (actions/get-script entities
|
|
(actions/walk-to entities :ego [120 73])
|
|
(actions/play-animation entities :ego :start-squat-2 :stop? false)
|
|
(Thread/sleep 200)
|
|
(actions/remove-entity entities :charcoal)
|
|
(actions/give entities :charcoal)
|
|
(actions/play-animation entities :ego :end-squat)
|
|
(actions/talk entities :ego "It's a small, sharp piece of charcoal.")
|
|
)
|
|
))
|
|
:wizard (rooms/make-entity :wizard (common/make-wizard screen global-atlas {:x 190 :y 78 :baseline 162 :scale-x 1.2 :scale-y 1.2
|
|
:script (actions/get-script entities (talk-to-gandarf-outside entities))
|
|
:scripts {:default (actions/get-script entities (actions/talk entities :wizard "No time for that!"))
|
|
:sword (actions/get-script entities (actions/do-dialogue entities
|
|
:wizard "The Sword of Blergh!"
|
|
:wizard "Good job, Tick."))}}))
|
|
:note (rooms/make-entity :note (assoc (utils/atlas->texture atlas "note")
|
|
:x 277 :y 74 :baseline 160
|
|
:label "Paper airplane"
|
|
:cursor :hand
|
|
:night-profile :none
|
|
:script (actions/get-script entities
|
|
(actions/walk-to entities :ego [280 80] :face :right)
|
|
(actions/play-animation entities :ego :squat)
|
|
(actions/remove-entity entities :note)
|
|
(actions/give entities :note-1)
|
|
(common/read-note-1 entities))))
|
|
:collision "outsidehouse/collision.png"
|
|
:scale-fn scaler
|
|
:apply-state (fn [screen entities]
|
|
(utils/fast-forward-particle (get-in entities [:room :entities :outside-particles]))
|
|
(as-> entities entities
|
|
(if (get-in entities [:state :coaxed-sheep?])
|
|
(let [scale ((get-in entities [:room :scale-fn]) [85 138])]
|
|
(update-in entities [:room :entities :sheep] #(assoc % :x 85 :y 138 :baseline 40 :scale-x scale :scale-y scale)))
|
|
entities)
|
|
(if (= :night (get-in entities [:state :time]))
|
|
(make-night screen entities)
|
|
entities)
|
|
(set-sheep-anim screen entities)))
|
|
:start-pos [30 80])))
|