Merge pull request #33 from nathank33/master

Added WaterWave, Major Efficiency Changes
This commit is contained in:
MistPhizzle 2014-09-07 13:06:43 -04:00
commit 91f6a0aa2e
11 changed files with 378 additions and 27 deletions

View file

@ -90,6 +90,7 @@ public class AbilityModuleManager {
if (a == StockAbilities.Torrent) shiftabilities.add(a.name());
if (a == StockAbilities.WaterManipulation) shiftabilities.add(a.name());
if (a == StockAbilities.IceSpike) shiftabilities.add(a.name());
if (a == StockAbilities.WaterWave) shiftabilities.add(a.name());
}
}
else if (StockAbilities.isEarthbending(a)) {

View file

@ -18,14 +18,14 @@ public enum StockAbilities {
AvatarState,
// Project Korra
Extraction, Smokescreen, Combustion, LavaSurge, LavaFlow, Suffocate;
Extraction, Smokescreen, Combustion, LavaSurge, LavaFlow, Suffocate, WaterWave;
private enum AirbendingAbilities {
AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst, Suffocate;
}
private enum WaterbendingAbilities {
WaterBubble, PhaseChange, HealingWaters, WaterManipulation, Surge, Bloodbending, WaterSpout, IceSpike, OctopusForm, Torrent;
WaterBubble, PhaseChange, HealingWaters, WaterManipulation, Surge, Bloodbending, WaterSpout, IceSpike, OctopusForm, Torrent, WaterWave;
}
private enum EarthbendingAbilities {

View file

@ -90,6 +90,7 @@ import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
import com.projectkorra.ProjectKorra.earthbending.EarthTunnel;
import com.projectkorra.ProjectKorra.earthbending.LavaFlow;
import com.projectkorra.ProjectKorra.earthbending.Shockwave;
import com.projectkorra.ProjectKorra.earthbending.Tremorsense;
import com.projectkorra.ProjectKorra.firebending.Cook;
@ -1031,22 +1032,21 @@ public class Methods {
return isEarthbendable(player, "RaiseEarth", block);
}
public static boolean isEarthbendable(Player player, String ability,
Block block) {
if (isRegionProtectedFromBuild(player, ability,
block.getLocation()))
return false;
public static boolean isEarthbendable(Player player, String ability, Block block)
{
Material material = block.getType();
for (String s : ProjectKorra.plugin.getConfig().getStringList("Properties.Earth.EarthbendableBlocks")) {
if (material == Material.getMaterial(s)) {
return true;
boolean valid = false;
for (String s : ProjectKorra.plugin.getConfig().getStringList("Properties.Earth.EarthbendableBlocks"))
if (material == Material.getMaterial(s)){
valid = true;
break;
}
}
if(!valid)
return false;
if (!isRegionProtectedFromBuild(player, ability,
block.getLocation()))
return true;
return false;
}
@ -1329,10 +1329,10 @@ public class Methods {
public static boolean isTransparentToEarthbending(Player player,
String ability, Block block) {
if (isRegionProtectedFromBuild(player, ability,
block.getLocation()))
if (!Arrays.asList(transparentToEarthbending).contains(block.getTypeId()))
return false;
if (Arrays.asList(transparentToEarthbending).contains(block.getTypeId()))
if (!isRegionProtectedFromBuild(player, ability,
block.getLocation()))
return true;
return false;
}
@ -1363,8 +1363,13 @@ public class Methods {
public static boolean isLavabendable(Block block, Player player) {
byte full = 0x0;
if (TempBlock.isTempBlock(block)) return false;
if ((block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) && block.getData() == full) return true;
if (TempBlock.isTempBlock(block)){
TempBlock tblock = TempBlock.instances.get(block);
if(tblock == null || !LavaFlow.totalBlocks.contains(tblock))
return false;
}
if ((block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) && block.getData() == full)
return true;
return false;
}

View file

@ -120,6 +120,7 @@ import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
import com.projectkorra.ProjectKorra.waterbending.WaterPassive;
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
import com.projectkorra.ProjectKorra.waterbending.WaterWall;
import com.projectkorra.ProjectKorra.waterbending.WaterWave;
import com.projectkorra.ProjectKorra.waterbending.Wave;
public class PKListener implements Listener {
@ -403,6 +404,9 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("Torrent")) {
Torrent.create(player);
}
if (abil.equalsIgnoreCase("WaterWave")) {
new WaterWave(player, WaterWave.AbilityType.SHIFT);
}
}
if (Methods.isEarthAbility(abil)) {
@ -732,6 +736,9 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("Torrent")) {
new Torrent(player);
}
if (abil.equalsIgnoreCase("WaterWave")) {
new WaterWave(player, WaterWave.AbilityType.CLICK);
}
}
if (Methods.isEarthAbility(abil)) {
@ -958,7 +965,8 @@ public class PKListener implements Listener {
Player player = event.getPlayer();
if (WaterWall.wasBrokenFor(player, block)
|| OctopusForm.wasBrokenFor(player, block)
|| Torrent.wasBrokenFor(player, block)) {
|| Torrent.wasBrokenFor(player, block)
|| WaterWave.wasBrokenFor(player, block)){
event.setCancelled(true);
return;
}

View file

@ -79,6 +79,8 @@ public class AirBubble {
for (Block block : Methods.getBlocksAroundPoint(location, radius)) {
if (waterorigins.containsKey(block))
continue;
if (!Methods.isWater(block))
continue;
if (Methods.isRegionProtectedFromBuild(player, "AirBubble",
block.getLocation()))
continue;

View file

@ -48,8 +48,8 @@ public class LavaFlow
public static double AS_SHIFT_PLATFORM_RADIUS = 3;
public static double AS_SHIFT_MAX_RADIUS = 16;
public static double AS_SHIFT_FLOW_SPEED = 0.2;
public static long AS_SHIFT_REMOVE_SPEED = 6000;
public static double AS_SHIFT_REMOVE_DELAY = 12000;
public static double AS_SHIFT_REMOVE_SPEED = 6.0;
public static long AS_SHIFT_REMOVE_DELAY = 12000;
public static double AS_CLICK_RANGE = 15.0;
public static double AS_CLICK_RADIUS = 8.0;
public static long AS_CLICK_LAVA_DELAY = 2000;
@ -301,7 +301,7 @@ public class LavaFlow
* melting over plants by creating new Plantbending() objects.
* It also appends the TempBlock to our arraylist called totalBlocks.
*
* NOTE: Due to LavaSurge's check on TempBlocks we have to remove
* NOTE: (DISABLED) Due to LavaSurge's check on TempBlocks we have to remove
* our tempblocks from TempBlock.instances so that players will
* be able to LavaSurge our blocks.
*/
@ -319,7 +319,7 @@ public class LavaFlow
TempBlock tblock = new TempBlock(block,Material.STATIONARY_LAVA,(byte) 0);
totalBlocks.add(tblock);
affectedBlocks.add(tblock);
TempBlock.instances.remove(block);
//TempBlock.instances.remove(block);
}
}
public void removeLava(Block testBlock)

View file

@ -46,7 +46,7 @@ public class WaterSpout {
this.player = player;
Block topBlock = Methods.getTopBlock(player.getLocation(), 0, -50);
if(topBlock == null)
return;
topBlock = player.getLocation().getBlock();
Material mat = topBlock.getType();
if(mat != Material.WATER && mat != Material.STATIONARY_WATER
&& mat != Material.ICE && mat != Material.PACKED_ICE && mat != Material.SNOW)

View file

@ -0,0 +1,326 @@
package com.projectkorra.ProjectKorra.waterbending;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.TempBlock;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
public class WaterWave
{
public static enum AbilityType{
CLICK, SHIFT, RELEASE
}
public static enum AnimateState{
RISE, TOWARDPLAYER, CIRCLE, SHRINK
}
public static ArrayList<WaterWave> instances = new ArrayList<WaterWave>();
public static boolean ICE_ONLY = false;
public static double RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.WaterWave.Range");
public static double MAX_SPEED = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.WaterWave.Speed");
public static long CHARGE_TIME = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.WaterWave.ChargeTime");
public static long FLIGHT_TIME = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.WaterWave.FlightTime");
private Player player;
private long time;
private AbilityType type;
private Location origin, currentLoc;
private Vector direction;
private double radius = 3.8;
private boolean charging = false;
private AnimateState anim;
private ConcurrentHashMap<Block, TempBlock> affectedBlocks = new ConcurrentHashMap<Block, TempBlock>();
public WaterWave(Player player, AbilityType type)
{
this.player = player;
this.time = System.currentTimeMillis();
this.type = type;
instances.add(this);
if(type == AbilityType.CLICK)
this.progress();
}
public void progress()
{
if (player.isDead() || !player.isOnline()) {
remove();
return;
}
if(type != AbilityType.RELEASE)
{
if(!Methods.canBend(player.getName(), "WaterWave")){
remove();
return;
}
String ability = Methods.getBoundAbility(player);
if(ability == null || !ability.equalsIgnoreCase("WaterWave")){
remove();
return;
}
}
if(type == AbilityType.CLICK)
{
if(origin == null)
{
removeType(player, AbilityType.CLICK);
instances.add(this);
Block block = Methods.getWaterSourceBlock(player, RANGE, Methods.canPlantbend(player));
if(block == null || block.getLocation().clone().add(0,1,0).getBlock().getType() != Material.AIR){
remove();
return;
}
origin = block.getLocation();
if(!Methods.isWaterbendable(block, player) || Methods.isRegionProtectedFromBuild(player, "WaterWave", origin)){
remove();
return;
}
if(ICE_ONLY && !(block.getType() == Material.ICE || block.getType() == Material.SNOW || block.getType() == Material.PACKED_ICE))
{
remove();
return;
}
}
if(player.getLocation().distance(origin) > RANGE){
remove();
return;
}
Methods.playFocusWaterEffect(origin.getBlock());
}
else if(type == AbilityType.SHIFT)
{
if(!charging)
{
if(!containsType(player, AbilityType.CLICK)){
removeType(player, AbilityType.CLICK);
remove();
return;
}
charging = true;
anim = AnimateState.RISE;
WaterWave clickSpear = getType(player, AbilityType.CLICK).get(0);
origin = clickSpear.origin.clone();
currentLoc = origin.clone();
if(Methods.isPlant(origin.getBlock()))
new Plantbending(origin.getBlock());
else
Methods.addTempAirBlock(origin.getBlock());
}
removeType(player, AbilityType.CLICK);
if(!player.isSneaking()){
if(System.currentTimeMillis() - time > CHARGE_TIME)
{
WaterWave wwave = new WaterWave(player, AbilityType.RELEASE);
wwave.anim = AnimateState.SHRINK;
wwave.direction = direction;
}
remove();
return;
}
double animSpeed = 1.2;
if(anim == AnimateState.RISE){
revertBlocks();
currentLoc.add(0,animSpeed,0);
Block block = currentLoc.getBlock();
if(block.getType() != Material.AIR || Methods.isRegionProtectedFromBuild(player, "WaterWave", block.getLocation())){
remove();
return;
}
createBlock(block, Material.STATIONARY_WATER);
if(currentLoc.distance(origin) > 2)
anim = AnimateState.TOWARDPLAYER;
}
else if(anim == AnimateState.TOWARDPLAYER)
{
revertBlocks();
Location eyeLoc = player.getTargetBlock(null, 2).getLocation();
eyeLoc.setY(player.getEyeLocation().getY());
Vector vec = Methods.getDirection(currentLoc, eyeLoc);
currentLoc.add(vec.normalize().multiply(animSpeed));
Block block = currentLoc.getBlock();
if(block.getType() != Material.AIR || Methods.isRegionProtectedFromBuild(player, "WaterWave", block.getLocation())){
remove();
return;
}
createBlock(block, Material.STATIONARY_WATER);
if(currentLoc.distance(eyeLoc) < 1.3)
{
anim = AnimateState.CIRCLE;
Vector tempDir = player.getLocation().getDirection();
tempDir.setY(0);
direction = tempDir.normalize();
revertBlocks();
}
}
else if(anim == AnimateState.CIRCLE)
{
drawCircle(120,5);
}
}
else if(type == AbilityType.RELEASE)
{
if(anim == AnimateState.SHRINK)
{
radius-=0.20;
drawCircle(360,15);
if(radius < 1){
revertBlocks();
time = System.currentTimeMillis();
anim = null;
}
}
else
{
if((System.currentTimeMillis() - time > FLIGHT_TIME && !AvatarState.isAvatarState(player))
|| player.isSneaking())
{
remove();
return;
}
double currentSpeed = MAX_SPEED - (MAX_SPEED * (double)(System.currentTimeMillis() - time) / (double)FLIGHT_TIME);
double nightSpeed = Methods.waterbendingNightAugment(currentSpeed * 0.9, player.getWorld());
currentSpeed = nightSpeed > currentSpeed ? nightSpeed : currentSpeed;
if(AvatarState.isAvatarState(player))
currentSpeed = Methods.waterbendingNightAugment(MAX_SPEED, player.getWorld());
player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(currentSpeed));
for(Block block : Methods.getBlocksAroundPoint(player.getLocation().add(0,-1,0), 1.5))
if(block.getType() == Material.AIR && !Methods.isRegionProtectedFromBuild(player, "WaterWave", block.getLocation()))
createBlock(block,Material.STATIONARY_WATER,(byte)0);
revertBlocksDelay(20L);
}
}
}
public void drawCircle(double theta, double increment)
{
double rotateSpeed = 45;
revertBlocks();
direction = rotateXZ(direction, rotateSpeed);
for(double i = 0; i < theta; i+=increment)
{
Vector dir = rotateXZ(direction, i - theta / 2).normalize().multiply(radius);
dir.setY(0);
Block block = player.getEyeLocation().add(dir).getBlock();
currentLoc = block.getLocation();
if(block.getType() == Material.AIR && !Methods.isRegionProtectedFromBuild(player, "WaterWave", block.getLocation()))
createBlock(block,Material.STATIONARY_WATER,(byte)8);
}
}
public void remove()
{
instances.remove(this);
revertBlocks();
}
public void createBlock(Block block, Material mat){
createBlock(block,mat,(byte)0);
}
public void createBlock(Block block, Material mat, byte data){
affectedBlocks.put(block, new TempBlock(block, mat, data));
}
public void revertBlocks()
{
Enumeration<Block> keys = affectedBlocks.keys();
while(keys.hasMoreElements())
{
Block block = keys.nextElement();
affectedBlocks.get(block).revertBlock();
affectedBlocks.remove(block);
}
}
public void revertBlocksDelay(long delay)
{
Enumeration<Block> keys = affectedBlocks.keys();
while(keys.hasMoreElements())
{
final Block block = keys.nextElement();
final TempBlock tblock = affectedBlocks.get(block);
affectedBlocks.remove(block);
new BukkitRunnable(){
public void run()
{
tblock.revertBlock();
}
}.runTaskLater(ProjectKorra.plugin, delay);
}
}
public static void progressAll()
{
//Bukkit.broadcastMessage("Instances:" + instances.size());
for(int i = 0; i < instances.size(); i++)
instances.get(i).progress();
}
public static void removeAll()
{
for(int i = 0; i < instances.size(); i++){
instances.get(i).remove();
i--;
}
}
public static boolean containsType(Player player, AbilityType type)
{
for(int i = 0; i < instances.size(); i++){
WaterWave spear = instances.get(i);
if(spear.player.equals(player) && spear.type.equals(type))
return true;
}
return false;
}
public static void removeType(Player player, AbilityType type)
{
for(int i = 0; i < instances.size(); i++){
WaterWave spear = instances.get(i);
if(spear.player.equals(player) && spear.type.equals(type)){
instances.remove(i);
i--;
}
}
}
public static ArrayList<WaterWave> getType(Player player, AbilityType type)
{
ArrayList<WaterWave> list = new ArrayList<WaterWave>();
for(WaterWave spear : instances){
if(spear.player.equals(player) && spear.type.equals(type))
list.add(spear);
}
return list;
}
public static boolean wasBrokenFor(Player player, Block block) {
if (containsType(player,AbilityType.CLICK)) {
WaterWave wwave = getType(player,AbilityType.CLICK).get(0);
if (wwave.origin == null)
return false;
if (wwave.origin.getBlock().equals(block))
return true;
}
return false;
}
public static Vector rotateXZ(Vector vec, double theta)
{
Vector vec2 = vec.clone();
double x = vec2.getX();
double z = vec2.getZ();
vec2.setX(x * Math.cos(Math.toRadians(theta)) - z * Math.sin(Math.toRadians(theta)));
vec2.setZ(x * Math.sin(Math.toRadians(theta)) + z * Math.cos(Math.toRadians(theta)));
return vec2;
}
}

View file

@ -29,6 +29,7 @@ public class WaterbendingManager implements Runnable {
Wave.progressAll();
IceSpike.progressAll();
IceSpike2.progressAll();
WaterWave.progressAll();
}
}

View file

@ -223,6 +223,13 @@ Abilities:
Enabled: true
Description: "To use this ability, click while over or in water. You will spout water up from beneath you to experience controlled levitation. This ability is a toggle, so you can activate it then use other abilities and it will remain on. If you try to spout over an area with no water, snow, or ice, the spout will dissipate and you will fall. Click again with this ability selected to deactivate it."
Height: 20
WaterWave:
Enabled: true
Description: "WaterWave provides a waterbender with extreme mobility and transportation. To use, first click a source block to select it; then hold sneak (Default: Shift) to begin streaming the water around you. While the water is streaming around you let go of sneak and the water will form underneath your feet, blasting you off into the direction that you are facing. Press shift while riding the wave to stop it."
Range: 6
ChargeTime: 1000
FlightTime: 2000
Speed: 1.2
Earth:
Passive:
Duration: 2500

View file

@ -75,6 +75,7 @@ permissions:
bending.ability.WaterManipulation: true
bending.ability.WaterSpout: true
bending.ability.Plantbending: true
bending.ability.WaterWave: true
bending.message.nightmessage: true
bending.water.passive: true
bending.earth: