Alex's Awesome Update (#729)

* Fix chi abilities appearing to strike twice, implement catapult 2.0, and fix water sources being removed by breaking them

* Small changes for loony (visual and time)

* Completely rewrite catapult functions and repair water abilities allowing plant sources to be broken upon selection

* Increase length of moveEarth call in Catapult and add more configuration options

* Fix my dumb mistake of using a bitwise operator

* Allow tempblock usage for iceblast
This commit is contained in:
Alexander Meech 2017-02-16 21:10:08 -05:00 committed by Christopher Martin
parent 2fa49c945c
commit 2cb73c71ec
12 changed files with 173 additions and 204 deletions

View file

@ -168,7 +168,6 @@ import com.projectkorra.projectkorra.waterbending.SurgeWave;
import com.projectkorra.projectkorra.waterbending.Torrent;
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.projectkorra.waterbending.WaterSpoutWave;
import com.projectkorra.projectkorra.waterbending.blood.Bloodbending;
import com.projectkorra.projectkorra.waterbending.healing.HealingWaters;
import com.projectkorra.projectkorra.waterbending.ice.IceBlast;
@ -201,10 +200,22 @@ public class PKListener implements Listener {
Block block = event.getBlock();
Player player = event.getPlayer();
if (SurgeWall.wasBrokenFor(player, block) || OctopusForm.wasBrokenFor(player, block) || Torrent.wasBrokenFor(player, block) || WaterSpoutWave.wasBrokenFor(player, block)) {
String abil = BendingPlayer.getBendingPlayer(player).getBoundAbilityName();
CoreAbility ability = null;
if (abil != null && abil.equalsIgnoreCase("Surge")) {
ability = CoreAbility.getAbility(SurgeWall.class);
}
else if (abil != null && abil.equalsIgnoreCase("Torrent")) {
ability = CoreAbility.getAbility(Torrent.class);
}
else {
ability = CoreAbility.getAbility(abil);
}
if (ability != null && ability instanceof WaterAbility && !((WaterAbility)ability).allowBreakPlants() && WaterAbility.isPlantbendable(player, block.getType(), false)) {
event.setCancelled(true);
return;
}
EarthBlast blast = EarthBlast.getBlastFromSource(block);
if (blast != null) {
blast.remove();
@ -865,10 +876,13 @@ public class PKListener implements Listener {
new Paralyze(sourcePlayer, targetPlayer);
} else if (boundAbil.equalsIgnoreCase("QuickStrike")) {
new QuickStrike(sourcePlayer, targetPlayer);
e.setCancelled(true);
} else if (boundAbil.equalsIgnoreCase("SwiftKick")) {
new SwiftKick(sourcePlayer, targetPlayer);
e.setCancelled(true);
} else if (boundAbil.equalsIgnoreCase("RapidPunch")) {
new RapidPunch(sourcePlayer, targetPlayer);
e.setCancelled(true);
} else {
if (ChiPassive.willChiBlock(sourcePlayer, targetPlayer)) {
ChiPassive.blockChi(targetPlayer);
@ -1335,7 +1349,11 @@ public class PKListener implements Listener {
if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) {
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("EarthBlast")) {
if (abil.equalsIgnoreCase("Catapult"))
{
new Catapult(player);
}
else if (abil.equalsIgnoreCase("EarthBlast")) {
new EarthBlast(player);
} else if (abil.equalsIgnoreCase("EarthArmor")) {
new EarthArmor(player);

View file

@ -126,6 +126,10 @@ public abstract class WaterAbility extends ElementalAbility {
public boolean isWaterbendable(Player player, Block block) {
return isWaterbendable(player, null, block);
}
public boolean allowBreakPlants() {
return true;
}
public static boolean isWaterbendable(Material material) {
return isWater(material) || isIce(material) || isPlant(material) || isSnow(material);

View file

@ -96,5 +96,4 @@ public class QuickStrike extends ChiAbility {
public void setTarget(Entity target) {
this.target = target;
}
}
}

View file

@ -314,8 +314,8 @@ public class ConfigManager {
config.addDefault("Abilities.Water.Passive.Hydrosink.Description", "Hydrosink is a passive ability for waterbenders enabling them to softly land on any waterbendable surface, cancelling all damage.");
config.addDefault("Commands.Help.Elements.Earth", "Earth is the element of substance. Earthbenders share many of the same fundamental techniques as Waterbenders, but their domain is quite different and more readily accessible. Earthbenders dominate the ground and subterranean, having abilities to pull columns of rock straight up from the earth or drill their way through the mountain. They can also launch themselves through the air using pillars of rock, and will not hurt themselves assuming they land on something they can bend. The more skilled Earthbenders can even bend metal.");
config.addDefault("Abilities.Earth.Catapult.Description", "Catapult is the greatest mobility move in an earthbender's arsenal. It requires practice to be able to control yourself to land where you wish, but once mastered it's credibly useful for earthbenders.");
config.addDefault("Abilities.Earth.Catapult.Instructions", "Left click while looking in the direction you want to be launched to be propelled forward. Additionally, you can hold sneak and left click to be propelled with less power.");
config.addDefault("Abilities.Earth.Catapult.Description", "Catapult is an advanced earthbending ability that allows you to forcefully push yourself using earth, reaching great heights. This technique is best used when travelling, but it can also be used to quickly escape a battle.");
config.addDefault("Abilities.Earth.Catapult.Instructions", "Hold sneak until you see particles and hear a sound and then release to be propelled in the direction you're looking. Additionally, you can left-click to be propelled with less power.");
config.addDefault("Abilities.Earth.Collapse.Description", "This ability is a basic earthbending ability that allows the earthbender great utility. It allows them to control earth blocks by compressing earth. Players and mobs can be trapped and killed if earth is collapsed and they're stuck inside it, meaning this move is deadly when in cave systems.");
config.addDefault("Abilities.Earth.Collapse.Instructions", "Left click an earthbendable block. If there's space under that block, it will be collapsed. Alternatively, you can tap sneak to collapse multiple blocks at a time.");
config.addDefault("Abilities.Earth.Collapse.DeathMessage", "{victim} was suffocated by {attacker}'s {ability}");
@ -556,8 +556,7 @@ public class ConfigManager {
config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.Damage", 3);
config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.Range", 16);
config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.Length", 10);
config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.Push", 8);
config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.MaxDistance", 80);
config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.Cooldown", 0);
config.addDefault("Abilities.Avatar.AvatarState.Earth.LavaFlow.ShiftCooldown", 1500);
config.addDefault("Abilities.Avatar.AvatarState.Earth.LavaFlow.ClickLavaCooldown", 1500);
@ -958,10 +957,10 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.Passive.FerroControl.Enabled", true);
config.addDefault("Abilities.Earth.Catapult.Enabled", true);
config.addDefault("Abilities.Earth.Catapult.Length", 6);
config.addDefault("Abilities.Earth.Catapult.Push", 4);
config.addDefault("Abilities.Earth.Catapult.ShiftModifier", 2);
config.addDefault("Abilities.Earth.Catapult.Cooldown", 1500);
config.addDefault("Abilities.Earth.Catapult.MaxDistance", 40);
config.addDefault("Abilities.Earth.Catapult.Cooldown", 7000);
config.addDefault("Abilities.Earth.Catapult.StageMult", 0.25);
config.addDefault("Abilities.Earth.Catapult.StageTimeMult", 2.0);
config.addDefault("Abilities.Earth.Collapse.Enabled", true);
config.addDefault("Abilities.Earth.Collapse.SelectRange", 20);

View file

@ -1,170 +1,135 @@
package com.projectkorra.projectkorra.earthbending;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.EarthAbility;
import java.util.Random;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class Catapult extends EarthAbility {
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.EarthAbility;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ParticleEffect.BlockData;
private boolean catapult;
private boolean moving;
private boolean flying;
private int length;
public class Catapult extends EarthAbility {
private int maxDistance;
private double stageMult;
private double stageTimeMult;
private int distance;
private long cooldown;
private double push;
private double shiftModifier;
private Location origin;
private Location location;
private Vector direction;
private Location target;
private int stage;
private long stageStart;
private boolean charging;
private boolean activationHandled;
public Catapult(Player player) {
super(player);
setFields();
this.origin = player.getEyeLocation().clone();
this.direction = origin.getDirection().clone().normalize();
if (!bPlayer.canBend(this)) {
return;
}
Vector neg = direction.clone().multiply(-1);
Block block;
distance = 0;
for (int i = 0; i <= length; i++) {
location = origin.clone().add(neg.clone().multiply((double) i));
block = location.getBlock();
if (isEarthbendable(block)) {
distance = getEarthbendableBlocksLength(block, neg, length - i);
break;
} else if (!isTransparent(block)) {
break;
}
if (bPlayer.isAvatarState()) {
this.maxDistance = getConfig().getInt("Abilities.Avatar.AvatarState.Earth.Catapult.MaxDistance");
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.Catapult.Cooldown");
}
if (distance != 0) {
if ((double) distance * distance >= location.distanceSquared(origin)) {
catapult = true;
}
if (player.isSneaking()) {
distance = (int) (distance / shiftModifier);
}
moving = true;
if (bPlayer.isAvatarState()) {
this.length = getConfig().getInt("Abilities.Avatar.AvatarState.Earth.Catapult.Length");
this.push = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.Catapult.Push");
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.Catapult.Cooldown");
}
start();
bPlayer.addCooldown(this);
}
}
public Catapult(Player player, Catapult source) {
super(player);
flying = true;
moving = false;
setFields();
location = source.location.clone();
direction = source.direction.clone();
distance = source.distance;
start();
playEarthbendingSound(player.getLocation());
fly();
}
private void setFields() {
this.length = getConfig().getInt("Abilities.Earth.Catapult.Length");
this.push = getConfig().getDouble("Abilities.Earth.Catapult.Push");
this.shiftModifier = getConfig().getDouble("Abilities.Earth.Catapult.ShiftModifier");
this.maxDistance = getConfig().getInt("Abilities.Earth.Catapult.MaxDistance");
this.stageMult = getConfig().getDouble("Abilities.Earth.Catapult.StageMult");
this.stageTimeMult = getConfig().getDouble("Abilities.Earth.Catapult.StageTimeMult");
this.distance = 0;
this.cooldown = getConfig().getLong("Abilities.Earth.Catapult.Cooldown");
this.catapult = false;
this.moving = false;
this.flying = false;
this.activationHandled = false;
this.stage = 1;
this.stageStart = System.currentTimeMillis();
this.charging = true;
}
private void fly() {
if (player.isDead() || !player.isOnline()) {
remove();
return;
} else if (!player.getWorld().equals(location.getWorld())) {
remove();
return;
} else if (player.getLocation().distanceSquared(location) < 9) {
if (!moving) {
flying = false;
}
return;
}
for (Block block : GeneralMethods.getBlocksAroundPoint(player.getLocation(), 1.5)) {
if ((GeneralMethods.isSolid(block) || block.isLiquid())) {
flying = false;
return;
private void moveEarth(Vector apply, Vector direction) {
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(origin, 2)) {
if (entity.getEntityId() != player.getEntityId()) {
entity.setVelocity(apply);
}
}
Vector vector = direction.clone().multiply(push * distance / length);
vector.setY(player.getVelocity().getY());
player.setVelocity(vector);
}
private boolean moveEarth() {
location = location.clone().add(direction);
if (catapult) {
if (location.getWorld().equals(origin.getWorld()) && location.distance(origin) < 0.5) {
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(origin, 2)) {
if (entity instanceof Player) {
Player target = (Player) entity;
new Catapult(target, this);
}
entity.setVelocity(direction.clone().multiply(push * distance / length));
}
return false;
}
} else {
double lengthSquared = (length - distance) * (length - distance);
if (location.distanceSquared(origin) <= lengthSquared) {
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2)) {
entity.setVelocity(direction.clone().multiply(push * distance / length));
}
return false;
}
}
moveEarth(location.clone().subtract(direction), direction, distance, false);
return true;
moveEarth(this.origin.clone().subtract(direction), direction, 3, false);
}
@Override
public void progress() {
if (player.getEyeLocation().getPitch() > -20f) {
remove();
return;
}
if (!bPlayer.canBendIgnoreBindsCooldowns(this)) {
remove();
return;
}
if (moving) {
if (!moveEarth()) {
moving = false;
if (charging)
{
if (stage == 4 || !player.isSneaking())
{
charging = false;
}
else
{
if ((System.currentTimeMillis() - this.stageStart) >= ((Math.max(0, this.stageTimeMult * (this.stage - 1))) * 1000))
{
this.stage++;
this.stageStart = System.currentTimeMillis();
Random random = new Random();
ParticleEffect.BLOCK_DUST.display(new BlockData(Material.DIRT, (byte)0), random.nextFloat(), random.nextFloat(), random.nextFloat(), 0, 20, player.getLocation(), 257);
ParticleEffect.BLOCK_DUST.display(new BlockData(Material.DIRT, (byte)0), random.nextFloat(), random.nextFloat(), random.nextFloat(), 0, 20, player.getLocation().add(0, 0.5, 0), 257);
player.getWorld().playEffect(player.getLocation(), Effect.GHAST_SHOOT, 0, 10);
}
return;
}
}
Vector direction = null;
if (!this.activationHandled)
{
this.origin = player.getLocation().clone();
direction = player.getEyeLocation().getDirection().clone().normalize();
if (flying) {
fly();
} else if (!moving) {
remove();
return;
if (!bPlayer.canBend(this)) {
this.activationHandled = true;
remove();
return;
}
if (isEarthbendable(player.getLocation().getBlock()) || isEarthbendable(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) {
distance = this.maxDistance;
}
if (distance != 0) {
distance = (int) (distance * (this.stageMult * this.stage));
this.activationHandled = true;
bPlayer.addCooldown(this);
} else {
remove();
return;
}
}
Location tar = this.origin.clone();
while (tar.distanceSquared(this.origin) <= Math.pow(this.distance, 2))
{
tar.add(direction.clone().normalize());
}
this.target = tar;
Vector apply = this.target.clone().toVector().subtract(this.origin.clone().toVector());
player.setVelocity(apply);
moveEarth(apply, direction);
remove();
}
@Override
@ -202,45 +167,13 @@ public class Catapult extends EarthAbility {
public void setOrigin(Location origin) {
this.origin = origin;
}
public Vector getDirection() {
return direction;
public Location getTarget() {
return target;
}
public void setDirection(Vector direction) {
this.direction = direction;
}
public boolean isCatapult() {
return catapult;
}
public void setCatapult(boolean catapult) {
this.catapult = catapult;
}
public boolean isMoving() {
return moving;
}
public void setMoving(boolean moving) {
this.moving = moving;
}
public boolean isFlying() {
return flying;
}
public void setFlying(boolean flying) {
this.flying = flying;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
public void setTarget(Location target) {
this.target = target;
}
public int getDistance() {
@ -251,20 +184,7 @@ public class Catapult extends EarthAbility {
this.distance = distance;
}
public double getPush() {
return push;
}
public void setPush(double push) {
this.push = push;
}
public void setLocation(Location location) {
this.location = location;
}
public void setCooldown(long cooldown) {
this.cooldown = cooldown;
}
}
}

View file

@ -8,6 +8,7 @@ import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.Tremorsense;
import com.projectkorra.projectkorra.firebending.Illumination;
public class FirePassive {
@ -23,12 +24,12 @@ public class FirePassive {
player.setFireTicks(80);
}
if (bPlayer != null && !CoreAbility.hasAbility(player, Illumination.class) && bPlayer.canBendIgnoreBinds(CoreAbility.getAbility("Illumination")) && ConfigManager.defaultConfig.get().getBoolean("Abilities.Fire.Illumination.Passive")) {
if (!bPlayer.isTremorSensing()) {
if (bPlayer != null && !CoreAbility.hasAbility(player, Illumination.class) && !CoreAbility.hasAbility(player, Tremorsense.class) && bPlayer.canBendIgnoreBinds(CoreAbility.getAbility("Illumination")) && ConfigManager.defaultConfig.get().getBoolean("Abilities.Fire.Illumination.Passive")) {
if (bPlayer.isIlluminating()) {
new Illumination(player);
}
}
}
}
}
}
}

View file

@ -175,5 +175,4 @@ public class TempBlock {
}.runTaskTimer(ProjectKorra.plugin, 0, 1);
}
}
}

View file

@ -185,6 +185,11 @@ public class OctopusForm extends WaterAbility {
AirAbility.breakBreathbendingHold(entity);
}
}
@Override
public boolean allowBreakPlants() {
return false;
}
@Override
public void progress() {

View file

@ -361,6 +361,11 @@ public class SurgeWall extends WaterAbility {
AFFECTED_BLOCKS.put(block, block);
}
}
@Override
public boolean allowBreakPlants() {
return false;
}
public static void form(Player player) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);

View file

@ -669,6 +669,12 @@ public class Torrent extends WaterAbility {
public boolean isCollidable() {
return forming || formed || launch || launching;
}
@Override
public boolean allowBreakPlants()
{
return false;
}
@Override
public List<Location> getLocations() {
@ -889,5 +895,4 @@ public class Torrent extends WaterAbility {
public void setLocation(Location location) {
this.location = location;
}
}
}

View file

@ -681,5 +681,9 @@ public class WaterSpoutWave extends WaterAbility {
public void setLocation(Location location) {
this.location = location;
}
}
@Override
public boolean allowBreakPlants() {
return false;
}
}

View file

@ -68,7 +68,7 @@ public class IceBlast extends IceAbility {
if (sourceBlock == null) {
return;
} else if (TempBlock.isTempBlock(sourceBlock) || GeneralMethods.isRegionProtectedFromBuild(this, sourceBlock.getLocation())) {
} else if (GeneralMethods.isRegionProtectedFromBuild(this, sourceBlock.getLocation())) {
return;
} else {
prepare(sourceBlock);
@ -195,9 +195,14 @@ public class IceBlast extends IceAbility {
progressing = true;
settingUp = true;
prepared = false;
new TempBlock(sourceBlock, Material.AIR, (byte) 0);
source = new TempBlock(sourceBlock, Material.PACKED_ICE, data);
if (TempBlock.isTempBlock(sourceBlock)) {
TempBlock.get(sourceBlock).setType(Material.PACKED_ICE, data);
source = TempBlock.get(sourceBlock);
} else {
new TempBlock(sourceBlock, Material.AIR, (byte) 0);
source = new TempBlock(sourceBlock, Material.PACKED_ICE, data);
}
}
@Override
@ -285,7 +290,12 @@ public class IceBlast extends IceAbility {
}
sourceBlock = block;
source = new TempBlock(sourceBlock, Material.PACKED_ICE, data);
if (TempBlock.isTempBlock(sourceBlock)) {
TempBlock.get(sourceBlock).setType(Material.PACKED_ICE, data);
source = TempBlock.get(sourceBlock);
} else {
source = new TempBlock(sourceBlock, Material.PACKED_ICE, data);
}
for (int x = 0; x < 10; x++) {
ParticleEffect.ITEM_CRACK.display(new ParticleEffect.ItemData(Material.ICE, (byte) 0), new Vector(((Math.random() - 0.5) * .5), ((Math.random() - 0.5) * .5), ((Math.random() - 0.5) * .5)), .5f, location, 255.0);