107 lines
7.6 KiB
Clojure
107 lines
7.6 KiB
Clojure
(ns advent.screens.rooms.held
|
|
(:require [advent.screens.rooms :as rooms]
|
|
[advent.screens.rooms.common :as common]
|
|
[advent.actions :as actions]
|
|
[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.math :refer :all]
|
|
[play-clj.g2d :refer :all]))
|
|
|
|
|
|
|
|
|
|
(defn bloodclot-choices [entities]
|
|
(actions/present-choices entities {:choices ["I'm just a kid! You wouldn't eat a kid, would you?"
|
|
{:run #(actions/respond entities %
|
|
:bloodclot-head "But I love eating young, tender children!"
|
|
:bloodclot-head "My mother would sing while making children stew."
|
|
:bloodclot-head "\"Eat the humans while they're young,\nEat the liver, spleen, and lung!\""
|
|
:bloodclot-head "Just singing that makes my mouth water.")
|
|
:choices actions/previous-choices}
|
|
"I'm covered in poison!"
|
|
{:run #(actions/respond entities %
|
|
:bloodclot-head "Actually, us goblins quite enjoy poison."
|
|
:bloodclot-head "It's like a good hotsauce."
|
|
:bloodclot-head "A good poison makes the meal pack a punch.")
|
|
:choices actions/previous-choices}
|
|
"I've got something in my pocket you might be interested in."
|
|
{:run #(do (actions/respond entities %
|
|
:bloodclot-head "Oh yeah, like what?")
|
|
(actions/update-entities entities (fn [e] (assoc-in e [:room :bloodclot-timer] 0))))}]}))
|
|
|
|
(defn add-second [screen entities]
|
|
(when (and (not (get-in entities [:fg-actions :script-running?]))
|
|
(get-in entities [:state :active?]))
|
|
(if (> (get-in entities [:room :bloodclot-timer] 0) 7)
|
|
(do
|
|
((actions/get-script entities (actions/talk entities :bloodclot-head "Time is up, runt.")
|
|
(bloodclot-choices entities)) entities)
|
|
nil)
|
|
(update-in entities [:room :bloodclot-timer] (fnil inc 0)))))
|
|
|
|
(defn bloodclot-talk-script [entities]
|
|
(actions/talk entities :ego "Let me down, Bloodclot!" :anim :suspended-talk)
|
|
(actions/do-dialogue entities :bloodclot-head "You've been a nuisance since I first met you!"
|
|
:bloodclot-head "Why shouldn't I gobble you up?")
|
|
(bloodclot-choices entities))
|
|
|
|
(defn fail-item [who msg]
|
|
(actions/get-script entities
|
|
(actions/talk entities who msg)))
|
|
|
|
(defn make [screen]
|
|
(let [bloodclot-talk (utils/make-anim-seq "held/bloodclot-head" [114 82] 0.1 [0 1 2 1 0 3 3 0 1 2 1 0 3 4 5 6 5 3 3 1 2 1 3 3 3 3 3 0 0 0 7 8 7])
|
|
bloodclot-stand (utils/make-anim-seq "held/bloodclot-head" [114 82] 0.1 (flatten [(repeat 15 0) 7 8 7]))]
|
|
(rooms/make :music :fight
|
|
:name "Held"
|
|
:interactions {:bloodclot {:box [182 42 270 196]
|
|
:script (actions/get-script entities
|
|
(bloodclot-talk-script entities))
|
|
:scripts #(condp = %
|
|
:magic-slingshot (fail-item :ego "I only had one bullet!")
|
|
:spear (fail-item :ego "I'm not strong enough to reach it!")
|
|
:sword (fail-item :ego "I'm not strong enough to reach it!")
|
|
:crowbar (fail-item :ego "I'm not strong enough to reach it!")
|
|
:medal (fail-item :bloodclot-head "Where is your might now, runt?")
|
|
:trophy (fail-item :bloodclot-head "Seems like your wisdom has failed you today.")
|
|
:kiss (fail-item :bloodclot-head "Your bravery won't save you from my belly!")
|
|
:note-1 (fail-item :bloodclot-head "I'm afraid Gandarf will be of no use to you now.")
|
|
:note-2 (fail-item :bloodclot-head "I'm afraid Gandarf will be of no use to you now.")
|
|
:flask-1-strength (common/win)
|
|
(actions/get-script entities
|
|
(actions/talk entities :bloodclot-head "Don't make me laugh, kid!")))
|
|
}}
|
|
:timers {:taunt [5.0 1.0 add-second]}
|
|
:layers [(assoc (utils/get-texture "held/background.png") :x 0 :y 0 :baseline 0)
|
|
(assoc (utils/get-texture "held/hand.png") :x 0 :y 0 :baseline 240)]
|
|
:entities {:bloodclot-head (assoc (animation->texture screen bloodclot-stand)
|
|
:x 211 :y 115 :baseline 240
|
|
:origin-x 57 :origin-y 0
|
|
:talk-color (color 0.95 0.4 0.2 1.0)
|
|
:stand bloodclot-stand
|
|
:talk bloodclot-talk
|
|
:anim bloodclot-stand
|
|
:anim-start 0)}
|
|
:collision "held/collision.png"
|
|
:scale-fn (constantly 1.5)
|
|
:start-pos [113 120]
|
|
:apply-state (fn [screen e]
|
|
(-> e
|
|
(assoc-in [:cam :paused? ] true)
|
|
(update-in [:tweens] dissoc :cam-x :cam-y)
|
|
(update-in [:room :entities :ego] #(actions/start-animation screen % :suspended))
|
|
(assoc-in [:room :entities :ego :stand-override] :suspended)
|
|
(assoc-in [:room :entities :ego :talk-override] :suspended-talk)
|
|
(assoc-in [:room :entities :ego :get-script] (fn [cursor [x y]]
|
|
(actions/get-script entities
|
|
(if (= :flask-1-strength (:value cursor))
|
|
(common/do-win entities)
|
|
(actions/talk entities :ego "I can't reach it!"))))))))))
|