diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index 1fc00a1e..eb105842 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -1447,8 +1447,6 @@ public class PKListener implements Listener { } else if (abil.equalsIgnoreCase("AirScooter")) { new AirScooter(player); - player.sendMessage("Pitch: " + player.getLocation().getPitch()); - player.sendMessage("Yaw: " + player.getLocation().getYaw()); } else if (abil.equalsIgnoreCase("AirSpout")) { new AirSpout(player); diff --git a/src/com/projectkorra/projectkorra/airbending/AirScooter.java b/src/com/projectkorra/projectkorra/airbending/AirScooter.java index bdf4bdbd..3748f3fb 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirScooter.java +++ b/src/com/projectkorra/projectkorra/airbending/AirScooter.java @@ -1,9 +1,7 @@ package com.projectkorra.projectkorra.airbending; -import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.ability.AirAbility; -import com.projectkorra.projectkorra.ability.WaterAbility; -import com.projectkorra.projectkorra.util.Flight; +import java.util.ArrayList; +import java.util.Random; import org.bukkit.Location; import org.bukkit.block.Block; @@ -12,8 +10,10 @@ import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; -import java.util.ArrayList; -import java.util.Random; +import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.ability.AirAbility; +import com.projectkorra.projectkorra.ability.WaterAbility; +import com.projectkorra.projectkorra.util.Flight; public class AirScooter extends AirAbility { @@ -28,7 +28,8 @@ public class AirScooter extends AirAbility { private boolean canFly; private boolean hadFly; - + private double phi = 0; + public AirScooter(Player player) { super(player); @@ -55,7 +56,9 @@ public class AirScooter extends AirAbility { new Flight(player); player.setAllowFlight(true); player.setFlying(true); + player.setSprinting(false); + player.setSneaking(false); for (int i = 0; i < 5; i++) { angles.add((double) (60 * i)); @@ -78,6 +81,10 @@ public class AirScooter extends AirAbility { return false; } + /* + * Looks for a block under the player and sets "floorBlock" to a block + * under the player if it within the maximum height + */ private void getFloor() { floorblock = null; for (int i = 0; i <= maxHeightFromGround; i++) { @@ -102,24 +109,28 @@ public class AirScooter extends AirAbility { return; } - Vector velocity = player.getEyeLocation().getDirection().clone(); - velocity.setY(0); + Vector velocity = player.getEyeLocation().getDirection().clone().normalize(); velocity = velocity.clone().normalize().multiply(speed); - + /* + * checks the players speed and ends the move if they are going too slow + */ if (System.currentTimeMillis() > startTime + interval) { - if (player.getVelocity().length() < speed * .5) { + if (player.getVelocity().length() < speed * 0.3) { remove(); return; } spinScooter(); } - + /* + * Checks for how far the ground is away from the player + * it elevates or lowers the player based on their distance from the ground. + */ double distance = player.getLocation().getY() - (double) floorblock.getY(); double dx = Math.abs(distance - 2.4); if (distance > 2.75) { - velocity.setY(-.25 * dx * dx); + velocity.setY(-.40 * dx * dx); } else if (distance < 2) { - velocity.setY(.25 * dx * dx); + velocity.setY(.40 * dx * dx); } else { velocity.setY(0); } @@ -130,38 +141,58 @@ public class AirScooter extends AirAbility { } else { return; } - + player.setSprinting(false); player.removePotionEffect(PotionEffectType.SPEED); player.setVelocity(velocity); + if (random.nextInt(4) == 0) { playAirbendingSound(player.getLocation()); } } + /* + * Updates the players flight, also adds the cooldown. + */ @Override public void remove() { super.remove(); - bPlayer.addCooldown(this); player.setAllowFlight(canFly); player.setFlying(hadFly); + bPlayer.addCooldown(this); } + /* + * The particles used for AirScooter + * phi = how many rings of particles the sphere has. + * theta = how dense the rings are. + * r = Radius of the sphere + */ private void spinScooter() { - Location origin = player.getLocation().clone(); - origin.add(0, -radius, 0); - - for (int i = 0; i < 5; i++) { - double x = Math.cos(Math.toRadians(angles.get(i))) * radius; - double y = ((double) i) / 2 * radius - radius; - double z = Math.sin(Math.toRadians(angles.get(i))) * radius; - playAirbendingParticles(origin.clone().add(x, y, z), 7); + Location origin = player.getLocation(); + Location origin2 = player.getLocation(); + phi += Math.PI/10*4; + for(double theta = 0; theta <= 2*Math.PI; theta += Math.PI/10) { + double r = 0.6; + double x = r*Math.cos(theta)*Math.sin(phi); + double y = r*Math.cos(phi); + double z = r*Math.sin(theta)*Math.sin(phi); + origin.add(x, y, z); + playAirbendingParticles(origin, 1, 0F, 0F, 0F); + origin.subtract(x, y, z); } - for (int i = 0; i < 5; i++) { - angles.set(i, angles.get(i) + 10); + for(double theta = 0; theta <= 2*Math.PI; theta += Math.PI/10) { + double r = 0.6; + double x = r*Math.cos(theta)*Math.sin(phi); + double y = r*Math.cos(phi); + double z = r*Math.sin(theta)*Math.sin(phi); + origin2.subtract(x, y, z); + playAirbendingParticles(origin2, 1, 0F, 0F, 0F); + origin2.add(x, y, z); } } + @Override public String getName() { return "AirScooter";