a way of doing dialogue trees, but meh.

This commit is contained in:
2014-09-25 17:07:39 -07:00
parent a5cd9fcea9
commit 51be2e0e14

View File

@@ -145,17 +145,16 @@
(merge params {:collision (advent.pathfind/map-from-resource collision) (merge params {:collision (advent.pathfind/map-from-resource collision)
:interactions interactions-as-list}))) :interactions interactions-as-list})))
(defn make-dialogue-tree [entities target-id tree] (defn run-dialogue-tree [entities command-pairs & [previous-line]]
(let [[e-line t-line options] tree (let [commands (partition 2 command-pairs)]
option-scripts (when options (for [option options] (doseq [[subject arg] commands]
[(first option) (actions/get-script entities (if (= :choices subject)
(make-dialogue-tree entities target-id option))]))] (apply actions/present-choices entities (for [choice (partition 2 arg)]
(actions/talk entities :ego e-line) [(first choice) (actions/get-script entities
(if (string? t-line) (run-dialogue-tree entities (second choice) (first choice)))]))
(actions/talk entities target-id t-line) (if (= :line arg)
(t-line)) (actions/talk entities subject previous-line)
(when options (actions/talk entities subject arg))))))
(apply actions/present-choices entities option-scripts))))
(defn backgrounds [screen] (defn backgrounds [screen]
(let [sheep-sheet (texture! (texture "outsidehouse/sheep-anim.png") :split 33 21) (let [sheep-sheet (texture! (texture "outsidehouse/sheep-anim.png") :split 33 21)
@@ -180,18 +179,28 @@
:cursor :down} :cursor :down}
:wizard {:box [228 80 248 126] :wizard {:box [228 80 248 126]
:script (actions/get-script entities :script (actions/get-script entities
(make-dialogue-tree entities :wizard ["Hello there Mr. Fangald!" (run-dialogue-tree entities [:ego "Hello there Mr. Fangald!"
"Oh no, not you again!" :wizard "Oh no, not you again!"
[["You're not my friend, Mr. Fangald?" :choices ["You're not happy to see me?" [:ego :line
"No, you are a rascally little boy who is nothing but a cheat!" :wizard "Of course not!"
[["Oh come on, I'm not that bad." :wizard "Not after all the hell you've put me through."
"Yes you are. Shoo!"] :choices ["You mean the time I set your rabbit loose?" [:ego :line
["I'm sorry I stole your magic cowboy hat." :wizard "Fluffy was my best rabbit!"]
#(do (actions/talk entities :wizard "Go.") "You're not still sore about my stealing your magic cowboy hat." [:ego :line
(actions/talk entities :wizard "Away.") :ego "Are you?"
(actions/transition-background entities :outside-house [262 88]))]]] :wizard "That cowboy hat was one of a kind!"
["What do you mean, 'not you again'?" :wizard "Truly unique."
"I mean get lost kid."]]]))}} :wizard "It accented my unique facial physique."
:wizard "And now it's gone forever."
:wizard "Leave me to die in peace."]
"You mean the time I set your house on fire with a fire mint?" [:ego :line
:wizard "That was you? I spent a fortune cleaning up the mess you made!"
:wizard "You ruined my life work!"]
"An old hoot like you needs a kick the pants every now and again!" [:ego :line
:wizard "Maybe so, but not from a cheating little boy like you!"]]]
"What do you mean, 'not you again'?" [:ego :line
:wizard "I mean get lost kid."]]]))}}
:layers [(assoc (texture "inside-house/background.png") :x 0 :y 0 :baseline 0) :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/desk.png") :x 0 :y 0 :baseline 200)
(assoc (texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240)] (assoc (texture "inside-house/sillhoute.png") :x 0 :y 0 :baseline 240)]