239 lines
19 KiB
Clojure
239 lines
19 KiB
Clojure
(ns advent.screens.rooms.outside-castle
|
|
(:require [advent.screens.items :as items]
|
|
[advent.screens.rooms :as rooms]
|
|
[advent.actions :as actions]
|
|
[advent.utils :as utils]
|
|
[clojure.zip :as zip]
|
|
[play-clj.core :refer :all]
|
|
[play-clj.ui :refer :all]
|
|
[play-clj.utils :refer :all]
|
|
[play-clj.math :refer :all]
|
|
[play-clj.g2d :refer :all]))
|
|
|
|
(defn do-initial-peddler-conversation [entities]
|
|
(actions/do-dialogue entities
|
|
:ego "Hello there, peddler."
|
|
:peddler "Good day sir! Care to see any of my wares?"
|
|
:peddler "I have only the choicest of wares."
|
|
:ego "What 'wares' are you selling?"
|
|
:peddler "I have the choicest of all types of wares..."
|
|
:peddler "...I'm well stocked on used earplugs..."
|
|
:peddler "...glass eyes..."
|
|
:peddler "... and motivational tapes."
|
|
:peddler "And today, I have a one day special!"
|
|
:peddler "Every purchase comes with a free balloon!")
|
|
(actions/present-choices entities {:choices ["I'm interested in your earplugs."
|
|
{:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true)))
|
|
(actions/respond entities %
|
|
:peddler "A choice choice sir!"
|
|
:peddler "These earplugs have been used by the the choicest of wearers."
|
|
:peddler "I can see a young man like yourself enjoying these choice earplugs for ages to come!"
|
|
:peddler "And remember, every purchase comes with the choicest of balloons!"
|
|
:peddler "That'll just be 10 sheckels."
|
|
:ego "But I haven't got any money!"
|
|
:peddler "Well I'm afraid you won't have the choicest of earplugs."
|
|
:ego "Can't I give you something else for them?"
|
|
:peddler "I'll tell you what, I don't have any thing for the kids that come to my stand."
|
|
:peddler "If you can bring me the choicest of toys, and I mean the choicest of toys, I will give you the earplugs."))}
|
|
"I'm interested in a glass eye."
|
|
{:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true)))
|
|
(actions/respond entities %
|
|
:peddler "The choicest choice, young man!"
|
|
:peddler "This glass eye is made out of the choicest glass, from across the sea."
|
|
:peddler "And remember, every purchase comes with the choicest of balloons!"
|
|
:peddler "That'll just be 95 sheckels."
|
|
:ego "But I haven't got any money!"
|
|
:peddler "Well I'm afraid you won't have the choicest of glass eyes."
|
|
:ego "Can't I give you something else for them?"
|
|
:peddler "I'll tell you what, I don't have any thing for the kids that come to my stand."
|
|
:peddler "If you can bring me the choicest of toys, I will give you the glass eye."))}
|
|
"I'm interested in the motivational tapes."
|
|
{:run #(do (actions/update-state entities (fn [state] (assoc state :wants-toy true)))
|
|
(actions/respond entities %
|
|
:peddler "Sure thing!"
|
|
:peddler "Has your luck got you down? Feeling pathetic?"
|
|
:peddler "These choicest of motivation tapes will convince you that life isn't so bad."
|
|
:peddler "For only 3 easy payments of 29.99 scheckles, they're yours!"
|
|
:ego "But I'm broke!"
|
|
:peddler "Well I'm afraid you won't have the choicest of motivational tapes."
|
|
:ego "Is there anything else you'd take instead?"
|
|
:peddler "I'll tell you what, I don't have any thing for the kids that come to my stand."
|
|
:peddler "If you can bring me the choicest of kid's toys, I will give you the tapes."))}
|
|
"Nevermind." {:run #(actions/respond entities % :peddler "Goodbye, sir.")}]}))
|
|
|
|
(defn give-teddy [entities]
|
|
(actions/remove-item entities :teddy)
|
|
(actions/do-dialogue entities
|
|
:peddler "That is the choicest of teddy bears!"
|
|
:peddler "True to my word, I will give you one of my wares."
|
|
:peddler "What would you like?")
|
|
(actions/present-choices entities
|
|
{:choices ["The glass eye."
|
|
{:run #(do (actions/respond entities % :peddler "Of course sir. Here you go.")
|
|
(actions/give entities :glass-eye))}
|
|
"The motivational tapes."
|
|
{:run #(do (actions/respond entities % :peddler "Of course sir. Here you go.")
|
|
(actions/give entities :motivational-tapes))}
|
|
"The used earplugs."
|
|
{:run #(do (actions/respond entities % :peddler "Of course sir. Here you go.")
|
|
(actions/give entities :used-earplugs))}]})
|
|
(actions/talk entities :peddler "And, of course, here is your balloon.")
|
|
(actions/give entities :balloon)
|
|
(actions/talk entities :peddler "Thank you for your business!"))
|
|
|
|
(defn do-completed-peddler-conversation [entities]
|
|
(actions/do-dialogue entities
|
|
:ego "Hello there, peddler."
|
|
:peddler "Hello again, sir! I trust you are enjoying your goods!"
|
|
:ego "I sure am."
|
|
:peddler "I thought so!"))
|
|
|
|
(defn do-wants-toy-conversation [entities]
|
|
(actions/do-dialogue entities
|
|
:ego "Hello there, peddler."
|
|
:peddler "Hello again, sir! Have you found me the choicest jack-in-the box yet?"
|
|
:ego "... erm, no."
|
|
:peddler "Oh, well how about the choicest bouncy ball?"
|
|
:ego "... not quite yet."
|
|
:peddler "Marionette? Teddy bear? Building blocks?")
|
|
(if (actions/has-item? entities :teddy)
|
|
(do
|
|
(actions/do-dialogue entities :ego "Well, I have this teddy bear.")
|
|
(give-teddy entities))
|
|
|
|
(actions/do-dialogue entities :ego "No, no, and no."
|
|
:peddler "Well come back when you have something I'm interested in."
|
|
:peddler "Remember - I have a one-day special going."
|
|
:peddler "Every purchase comes with a free balloon!")))
|
|
|
|
(defn walk-to-peddler [entities]
|
|
(actions/walk-to entities :ego [191 90] :face :left))
|
|
|
|
(defn no-returns [entities]
|
|
(walk-to-peddler entities)
|
|
(actions/do-dialogue entities :ego "Can I return this?"
|
|
:peddler "Sorry, no refunds."))
|
|
|
|
(defn do-peddler-dialogue [entities]
|
|
(cond (actions/has-obtained? entities :balloon) (do-completed-peddler-conversation entities)
|
|
(get-in @entities [:state :wants-toy]) (do-wants-toy-conversation entities)
|
|
:else (do-initial-peddler-conversation entities)))
|
|
(defn make [screen]
|
|
(let [peddler-sheet (texture! (texture "outside-castle/peddler-talk.png" ) :split 18 36)
|
|
peddler-talk (animation 0.18 (for [i (flatten [2 3 2 3 2 3 6 1 0 1 0 1 0 1 0 1 2 3 2 3 2 3 6 4 5 4 5 4 5 4 5])]
|
|
(aget peddler-sheet 0 i)))
|
|
peddler-stand (animation 0.2 (for [i (flatten [(repeat 8 0) 6 (repeat 8 0) 6 (repeat 5 0) 4 5 4 5 4 5])]
|
|
(aget peddler-sheet 0 i)))
|
|
balloon-sheet (texture! (texture "outside-castle/balloons.png") :split 20 36)
|
|
balloon-stand (animation 0.25 (for [i [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 0 1 2 1 0 1 2 1 0 1 2 1 0 1 2]]
|
|
(aget balloon-sheet 0 i)))
|
|
|
|
steer-sheet (texture! (texture "outside-castle/steer.png") :split 50 35)
|
|
steer-stand (animation 0.2 (for [i [0 0 0 0 0 0 0 0 0 1 0 2 0 1 0 2 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 0 0 0 0]]
|
|
(aget steer-sheet 0 i)))
|
|
flies-stand (utils/make-anim "outside-castle/flies.png" [15 15] 0.075 [0 1 2 1])]
|
|
(rooms/make :music :town-2
|
|
:interactions
|
|
{:right-dir {:box [300 40 320 140]
|
|
:script (actions/get-script
|
|
entities
|
|
(actions/walk-to entities :ego [310 80])
|
|
(actions/walk-straight-to entities :ego [340 80])
|
|
(actions/transition-background entities :outside-house [0 80])
|
|
(actions/walk-straight-to entities :ego [30 80]))
|
|
:cursor :right}
|
|
:door {:box [66 180 85 195]
|
|
:script (actions/get-script
|
|
entities
|
|
(actions/walk-to entities :ego [82 180])
|
|
(actions/transition-background entities :inside-castle [280 145])
|
|
(actions/walk-to entities :ego [245 90]))
|
|
:cursor :left}
|
|
:castle {:box [0 181 100 240]
|
|
:script (actions/get-script entities
|
|
(actions/do-dialogue entities :ego "That's the town of Remington in the distance."))}
|
|
:wares {:box [69 75 97 110]
|
|
:script (actions/get-script entities
|
|
(actions/talk entities :ego "That peddler has all kinds of strange trinkets."))}
|
|
:garden {:box [103 170 178 200]
|
|
:script (actions/get-script
|
|
entities
|
|
(if (actions/has-obtained? entities :carrot)
|
|
(actions/talk entities :ego "If I steal any more, I might get caught.")
|
|
(do
|
|
(actions/walk-to entities :ego [128 180])
|
|
(actions/talk entities :ego "Hey! Carrots.")
|
|
(actions/play-animation entities :ego :squat)
|
|
(actions/talk entities :ego "No one will notice one missing.")
|
|
(actions/give entities :carrot))))}
|
|
:peddler {:box [110 90 128 146]
|
|
:script (actions/get-script
|
|
entities
|
|
(walk-to-peddler entities)
|
|
(do-peddler-dialogue entities))
|
|
:scripts #(condp = %
|
|
:teddy (actions/get-script entities
|
|
(walk-to-peddler entities)
|
|
(give-teddy entities))
|
|
:glass-eye (actions/get-script entities (no-returns entities))
|
|
:motivational-tapes (actions/get-script entities (no-returns entities))
|
|
:used-earplugs (actions/get-script entities (no-returns entities))
|
|
:balloon (actions/get-script entities (no-returns entities))
|
|
(actions/get-script entities
|
|
(walk-to-peddler entities)
|
|
(actions/do-dialogue entities
|
|
:ego "Are you interested in this?"
|
|
:peddler "No, I have no use for it.")))}}
|
|
:layers [(assoc (texture "outside-castle/background.png") :x 0 :y 0 :baseline 0)]
|
|
:entities {:peddler (actions/start-animation screen
|
|
(assoc (texture "outside-castle/peddler.png") :x 110 :y 90 :baseline 150 :anim nil
|
|
:talk peddler-talk :stand peddler-stand
|
|
:talk-color (color 1.0 0.9 0.4 1.0))
|
|
|
|
:stand)
|
|
:steer (actions/start-animation screen (assoc (animation->texture screen steer-stand) :x 203 :y 155 :baseline 80
|
|
:stand steer-stand
|
|
:script (actions/get-script entities
|
|
(actions/walk-to entities :ego [168 150] :face :right)
|
|
(actions/do-dialogue entities
|
|
:ego "It's Angus, Remington's buff bull."
|
|
:ego "He's used in all of the town's rodeos."
|
|
:ego "Farmer Doug feeds him an exclusive wild high-protein grass diet to keep him in tip top shape."
|
|
:ego "He looks mean, I'd rather not pet him."))
|
|
:scripts #(condp = %
|
|
:grass (actions/get-script entities
|
|
(actions/walk-to entities :ego [168 150] :face :right)
|
|
(actions/play-animation entities :ego :reach)
|
|
(actions/remove-item entities :grass)
|
|
(actions/talk entities :ego "Eww! He slobbered on my hand.")
|
|
(actions/give entities :slobber))
|
|
:carrot (actions/get-script entities
|
|
(actions/walk-to entities :ego [168 150] :face :right)
|
|
(actions/do-dialogue entities
|
|
:ego "I don't thing Angus is interested."
|
|
:ego "Farmer Doug only feeds him a wild high-protein grass."))
|
|
nil))
|
|
:stand)
|
|
:balloons (actions/start-animation screen
|
|
(assoc (animation->texture screen balloon-stand)
|
|
:x 75
|
|
:y 100
|
|
:baseline 140
|
|
:stand balloon-stand
|
|
:script (actions/get-script entities
|
|
(actions/talk entities :ego "Those look like the choicest of balloons.")))
|
|
:stand)
|
|
:bird (utils/make-bird screen (as-> [[82 235] [134 215] [185 235] [165 238]
|
|
[220 225] [210 230] [250 235]] p
|
|
(concat p (reverse p))))
|
|
|
|
:flies (assoc (animation->texture screen flies-stand)
|
|
:x 201
|
|
:y 175
|
|
:anim flies-stand
|
|
:anim-start 0
|
|
:baseline 240)}
|
|
:collision "outside-castle/collision.png"
|
|
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)
|
|
:start-pos [310 80])))
|