improvements on conversation tree.
This commit is contained in:
@@ -146,16 +146,55 @@
|
||||
(merge params {:collision (advent.pathfind/map-from-resource collision)
|
||||
:interactions interactions-as-list})))
|
||||
|
||||
(defn run-dialogue-tree [entities command-pairs & [previous-line]]
|
||||
(let [commands (partition 2 command-pairs)]
|
||||
(doseq [[subject arg] commands]
|
||||
(if (= :choices subject)
|
||||
(apply actions/present-choices entities (for [choice (partition 2 arg)]
|
||||
[(first choice) (actions/get-script entities
|
||||
(run-dialogue-tree entities (doto (second choice) println) (first choice)))]))
|
||||
(if (= :line arg)
|
||||
(actions/talk entities subject previous-line)
|
||||
(actions/talk entities subject arg))))))
|
||||
|
||||
(defn do-dialogue [entities & pairs]
|
||||
(loop [pairs (partition 2 pairs)]
|
||||
(let [[[target line]] pairs
|
||||
result (actions/talk entities target line)]
|
||||
(if (seq (rest pairs))
|
||||
(recur (rest pairs))
|
||||
result))))
|
||||
|
||||
(defn respond [entities line & more]
|
||||
(apply do-dialogue entities :ego line more))
|
||||
|
||||
(defn wizard-dialogue [entities]
|
||||
{
|
||||
:choices {"What do you mean, \"Not you again?\""
|
||||
{:run #(respond entities % :wizard "I mean, you've wrecked my life and I never want to see you again.")
|
||||
:choices {"You mean the time I set your house on fire with a fire mint?"
|
||||
{:run #(do
|
||||
(respond entities %
|
||||
:wizard "That was you!?"
|
||||
:wizard "My house was nearly destroyed!"
|
||||
:wizard "I spent weeks rebuilding my home!"
|
||||
:wizard "Leave, now, or I'll turn you into a ..."
|
||||
:wizard "... a ..."
|
||||
:wizard "... a frog!"
|
||||
:ego "Okay, okay! I'm leaving.")
|
||||
(actions/transition-background entities :outside-house [262 88])
|
||||
(actions/talk entities :ego "I guess he's really upset with me."))}
|
||||
"You're still cross about my stealing your magic cowboy hat?"
|
||||
{:run #(do (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 cheat stole it from me!"
|
||||
:wizard "That's why I bought my MagiSafe 5000, to keep out intruders like you."
|
||||
:wizard "Now leave.")
|
||||
(actions/transition-background entities :outside-house [262 88]))}
|
||||
"Even an old hoot like you needs a kick in the pants every now and again."
|
||||
{:run #(respond entities % :wizard "What gives you the right to try to teach me a lesson?")
|
||||
:choices {"My good looks?" {:choices actions/previous-choices}
|
||||
"My good standing within the community?" {:choices actions/previous-choices}
|
||||
"My respectful attitude?" {:choices actions/previous-choices}}}}}
|
||||
"You're not happy to see me, Mr. Fangald?"
|
||||
{:run #(respond entities % :wizard "Of course not, you little brat. You've made my life a living hell!")
|
||||
:choices #(-> % zip/left)}
|
||||
"Good bye, Mr. Fangald!"
|
||||
{:run #(do
|
||||
(respond entities % :wizard "Now scram!")
|
||||
(actions/transition-background entities :outside-house [262 88]))}}})
|
||||
|
||||
(defn backgrounds [screen]
|
||||
(let [sheep-sheet (texture! (texture "outsidehouse/sheep-anim.png") :split 33 21)
|
||||
@@ -180,22 +219,8 @@
|
||||
:cursor :down}
|
||||
:wizard {:box [228 80 248 126]
|
||||
:script (actions/get-script entities
|
||||
(actions/present-choices entities {:choices {"Hello there Mr. Fangald" {:run #(do (actions/talk entities :ego %)
|
||||
(actions/talk entities :wizard "Oh, no. Not you again!"))
|
||||
:choices {"What do you mean, \"Not you again?\"" {:run #(do (actions/talk entities :ego %)
|
||||
(actions/talk entities :wizard "I mean, you've wrecked my life and I never want to see you again."))
|
||||
:choices {"You mean the time I set your house on fire with a fire mint?" {:choices actions/previous-choices}
|
||||
"You're still cross about my stealing your magic cowboy hat?" {:choices actions/previous-choices}
|
||||
"Even an old hoot like you needs a kick in the pants every now and again." {:choices actions/previous-choices}
|
||||
"Something else" {:choices actions/something-else}}}
|
||||
"You're not happy to see me, Mr. Fangald?" {:run #(do (actions/talk entities :ego %)
|
||||
(actions/talk entities :wizard "Of course not, you little cheat. You're nothing but a little cheat."))
|
||||
:choices #(-> % zip/left)}
|
||||
"Something else" {:choices actions/something-else}}}
|
||||
"Good bye, Mr. Fangald!" {:run #(do (actions/talk entities :ego %)
|
||||
(actions/talk entities :wizard "Now scram!"))}}})
|
||||
|
||||
)}}
|
||||
(do-dialogue entities :ego "Hello there Mr. Fangald!" :wizard "Oh no, not you again!")
|
||||
(actions/present-choices entities (wizard-dialogue entities)))}}
|
||||
:layers [(assoc (texture "inside-house/background.png") :x 0 :y 0 :baseline 0)
|
||||
(assoc (texture "inside-house/desk.png") :x 0 :y 0 :baseline 200)
|
||||
(assoc (texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240)]
|
||||
@@ -351,7 +376,7 @@
|
||||
(update! screen :renderer (stage) :camera (orthographic))
|
||||
(let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
|
||||
music (sound "town-music.mp3")
|
||||
;; _ (sound! music :loop 0.20)
|
||||
_ (sound! music :loop 0.20)
|
||||
backgrounds (backgrounds screen)]
|
||||
{:backgrounds backgrounds
|
||||
:state {:object nil
|
||||
|
||||
Reference in New Issue
Block a user