Created
May 3, 2012 12:10
-
-
Save bgnori/2585250 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[nori@akagi]~/Desktop/work/cloft/cloft% git diff | |
diff --git a/src/cloft/core.clj b/src/cloft/core.clj | |
index 34ccb7a..80c2fd5 100644 | |
--- a/src/cloft/core.clj | |
+++ b/src/cloft/core.clj | |
@@ -20,6 +20,7 @@ | |
(:import [org.bukkit.potion Potion PotionEffect PotionEffectType]) | |
(:import [org.bukkit.inventory ItemStack])) | |
+ | |
(def NAME-ICON | |
{"ujm" "http://www.gravatar.com/avatar/d9d0ceb387e3b6de5c4562af78e8a910.jpg?s=28\n" | |
"sbwhitecap" "http://www.gravatar.com/avatar/198149c17c72f7db3a15e432b454067e.jpg?s=28\n" | |
@@ -66,6 +67,8 @@ | |
(def anotherbed (org.bukkit.Location. world -237.8704284429714 72.5625 -53.82154923217098 19.349966 -180.45361)) | |
(def player-death-locations (atom {})) | |
+(def last-vertical-shots (atom {})) | |
+ | |
(defn player-teleport-machine [evt player] | |
(when (and | |
(= (.getWorld player) world) | |
@@ -258,6 +261,35 @@ | |
(defn add-bowgun-player [name] | |
(swap! bowgun-players conj name)) | |
+(defn is-arrow-velocity-vertical [arrow] | |
+ (let [v (.getVelocity arrow)] | |
+ ;(prn 'is-arrow-velocity-vertical v) | |
+ (and (> 0.1 (Math/abs (.getX v))) | |
+ (> 0.1 (Math/abs (.getZ v)))))) | |
+ | |
+(defn thuder_mobs_around [player amount] | |
+ (map (fn [x] | |
+ (.world.strikeLightningEffect (.getLocation x)) | |
+ (.damage x amount)) | |
+ (doseq [entity (.getNearbyEntities player 10 10 10)]))) | |
+ | |
+(defn check-and-thunder [triggered-by] | |
+ (let [locations (vals last-vertical-shots) ] | |
+ (if (< 0 ; 2 for more than self + 2, 0 for testing | |
+ (count | |
+ (filter (fn [loc] (> 10.0 ; radius of 10.0 | |
+ (.distance (.getLocation triggered-by) loc))) | |
+ locations))) | |
+ (thuder_mobs_around triggered-by 20)))) | |
+ ; possiblly we need to flush last-vertical-shots, not clear. | |
+ ; i.e. 3 shooters p1, p2, p3 shoot arrows into mid air consecutively, how often thuders(tn)? | |
+ ; A. | |
+ ; p1, p2, p3, p1, p2, p3, | |
+ ; t1 t2 | |
+ ; B. | |
+ ; p1, p2, p3, p1, p2, p3, | |
+ ; t1, t2, t3, t4 | |
+ | |
(defn entity-shoot-bow-event [evt] | |
(let [shooter (.getEntity evt)] | |
(when (instance? Player shooter) | |
@@ -274,6 +306,15 @@ | |
(Thread/sleep 300) (.shootArrow (.getEntity evt)) | |
(Thread/sleep 500) (.shootArrow (.getEntity evt)) | |
)))) | |
+ (when (is-arrow-velocity-vertical (.getProjectile evt)) | |
+ (swap! last-vertical-shots assoc (.getDisplayName shooter) (.getLocation shooter)) | |
+ ;(swap! player-death-locations assoc (.getDisplayName player) (.getLocation player)) | |
+ (future-call #(do | |
+ (check-and-thunder shooter) | |
+ ;may be we need to defn right outside of future-call to have localvals. | |
+ (Thread/sleep 1000) | |
+ (swap! last-vertical-shots dissoc (.getDisplayName shooter)))) | |
+ ) | |
(when (= arrow-skill-shotgun (arrow-skill-of shooter)) | |
(doseq [_ (range 1 80)] | |
(let [rand1 (fn [] (* 0.8 (- (rand) 0.5))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment