Catapult Fix (#732)

* Reload changes

* Catapult Fixes

* Catapult Adjustment

* Changes
This commit is contained in:
Simplicitee 2017-02-17 01:13:38 -05:00 committed by Christopher Martin
parent f2889b7fd4
commit ca6ca2b08a
5 changed files with 76 additions and 92 deletions

View file

@ -204,18 +204,16 @@ public class PKListener implements Listener {
CoreAbility ability = null; CoreAbility ability = null;
if (abil != null && abil.equalsIgnoreCase("Surge")) { if (abil != null && abil.equalsIgnoreCase("Surge")) {
ability = CoreAbility.getAbility(SurgeWall.class); ability = CoreAbility.getAbility(SurgeWall.class);
} } else if (abil != null && abil.equalsIgnoreCase("Torrent")) {
else if (abil != null && abil.equalsIgnoreCase("Torrent")) {
ability = CoreAbility.getAbility(Torrent.class); ability = CoreAbility.getAbility(Torrent.class);
} } else {
else {
ability = CoreAbility.getAbility(abil); ability = CoreAbility.getAbility(abil);
} }
if (ability != null && ability instanceof WaterAbility && !((WaterAbility)ability).allowBreakPlants() && WaterAbility.isPlantbendable(player, block.getType(), false)) { if (ability != null && ability instanceof WaterAbility && !((WaterAbility) ability).allowBreakPlants() && WaterAbility.isPlantbendable(player, block.getType(), false)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
EarthBlast blast = EarthBlast.getBlastFromSource(block); EarthBlast blast = EarthBlast.getBlastFromSource(block);
if (blast != null) { if (blast != null) {
blast.remove(); blast.remove();
@ -1349,11 +1347,9 @@ public class PKListener implements Listener {
if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) { if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) {
if (bPlayer.canCurrentlyBendWithWeapons()) { if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("Catapult")) if (abil.equalsIgnoreCase("Catapult")) {
{ new Catapult(player, true);
new Catapult(player); } else if (abil.equalsIgnoreCase("EarthBlast")) {
}
else if (abil.equalsIgnoreCase("EarthBlast")) {
new EarthBlast(player); new EarthBlast(player);
} else if (abil.equalsIgnoreCase("EarthArmor")) { } else if (abil.equalsIgnoreCase("EarthArmor")) {
new EarthArmor(player); new EarthArmor(player);
@ -1545,7 +1541,7 @@ public class PKListener implements Listener {
if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) { if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) {
if (bPlayer.canCurrentlyBendWithWeapons()) { if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("Catapult")) { if (abil.equalsIgnoreCase("Catapult")) {
new Catapult(player); new Catapult(player, false);
} else if (abil.equalsIgnoreCase("EarthBlast")) { } else if (abil.equalsIgnoreCase("EarthBlast")) {
EarthBlast.throwEarth(player); EarthBlast.throwEarth(player);
} else if (abil.equalsIgnoreCase("RaiseEarth")) { } else if (abil.equalsIgnoreCase("RaiseEarth")) {

View file

@ -78,27 +78,48 @@ public class DisplayCommand extends PKCommand {
elementName = "avatarpassive"; elementName = "avatarpassive";
Element element = Element.fromString(elementName.replace("combos", "").replace("combo", "").replace("passives", "").replace("passive", "")); Element element = Element.fromString(elementName.replace("combos", "").replace("combo", "").replace("passives", "").replace("passive", ""));
//combos //combos
if (element != null && elementName.contains("combo")) { if (elementName.contains("combo")) {
ChatColor color = element != null ? element.getColor() : null; if (element == null) {
ArrayList<String> combos = ComboManager.getCombosForElement(element); for (Element e : Element.getAllElements()) {
ChatColor color = e != null ? e.getColor() : null;
ArrayList<String> combos = ComboManager.getCombosForElement(e);
for (String comboAbil : combos) {
ChatColor comboColor = color;
if (!sender.hasPermission("bending.ability." + comboAbil)) {
continue;
}
if (combos.isEmpty()) { CoreAbility coreAbil = CoreAbility.getAbility(comboAbil);
GeneralMethods.sendBrandingMessage(sender, color + noCombosAvailable.replace("{element}", element.getName())); if (coreAbil != null) {
comboColor = coreAbil.getElement().getColor();
}
sender.sendMessage(comboColor + comboAbil);
}
}
return;
} else {
ChatColor color = element != null ? element.getColor() : null;
ArrayList<String> combos = ComboManager.getCombosForElement(element);
if (combos.isEmpty()) {
GeneralMethods.sendBrandingMessage(sender, color + noCombosAvailable.replace("{element}", element.getName()));
return;
}
for (String comboMove : combos) {
ChatColor comboColor = color;
if (!sender.hasPermission("bending.ability." + comboMove)) {
continue;
}
CoreAbility coreAbil = CoreAbility.getAbility(comboMove);
if (coreAbil != null) {
comboColor = coreAbil.getElement().getColor();
}
sender.sendMessage(comboColor + comboMove);
}
return; return;
} }
for (String comboMove : combos) {
ChatColor comboColor = color;
if (!sender.hasPermission("bending.ability." + comboMove)) {
continue;
}
CoreAbility coreAbil = CoreAbility.getAbility(comboMove);
if (coreAbil != null) {
comboColor = coreAbil.getElement().getColor();
}
sender.sendMessage(comboColor + comboMove);
}
return;
//passives //passives
} else if (elementName.contains("passive")) { } else if (elementName.contains("passive")) {
if (element == null) { if (element == null) {
@ -341,4 +362,4 @@ public class DisplayCommand extends PKCommand {
return list; return list;
} }
} }

View file

@ -957,9 +957,7 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.Passive.FerroControl.Enabled", true); config.addDefault("Abilities.Earth.Passive.FerroControl.Enabled", true);
config.addDefault("Abilities.Earth.Catapult.Enabled", true); config.addDefault("Abilities.Earth.Catapult.Enabled", true);
config.addDefault("Abilities.Earth.Catapult.MaxDistance", 40);
config.addDefault("Abilities.Earth.Catapult.Cooldown", 7000); 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.Catapult.StageTimeMult", 2.0);
config.addDefault("Abilities.Earth.Collapse.Enabled", true); config.addDefault("Abilities.Earth.Collapse.Enabled", true);

View file

@ -16,43 +16,39 @@ import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ParticleEffect.BlockData; import com.projectkorra.projectkorra.util.ParticleEffect.BlockData;
public class Catapult extends EarthAbility { public class Catapult extends EarthAbility {
private int maxDistance;
private double stageMult;
private double stageTimeMult; private double stageTimeMult;
private int distance;
private long cooldown; private long cooldown;
private Location origin; private Location origin;
private Location target; private Location target;
private int stage; private int stage;
private long stageStart; private long stageStart;
private boolean charging; private boolean charging;
private boolean activationHandled; private boolean activationHandled;
public Catapult(Player player) { public Catapult(Player player, boolean sneak) {
super(player); super(player);
setFields(); setFields();
if (!isEarthbendable(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) {
return;
}
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
return; return;
} }
if (bPlayer.isAvatarState()) { if (bPlayer.isAvatarState()) {
this.maxDistance = getConfig().getInt("Abilities.Avatar.AvatarState.Earth.Catapult.MaxDistance");
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.Catapult.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.Catapult.Cooldown");
} }
this.charging = sneak;
start(); start();
} }
private void setFields() { private void setFields() {
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.stageTimeMult = getConfig().getDouble("Abilities.Earth.Catapult.StageTimeMult");
this.distance = 0;
this.cooldown = getConfig().getLong("Abilities.Earth.Catapult.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Earth.Catapult.Cooldown");
this.activationHandled = false; this.activationHandled = false;
this.stage = 1; this.stage = 1;
this.stageStart = System.currentTimeMillis(); this.stageStart = System.currentTimeMillis();
this.charging = true;
} }
private void moveEarth(Vector apply, Vector direction) { private void moveEarth(Vector apply, Vector direction) {
@ -74,31 +70,25 @@ public class Catapult extends EarthAbility {
remove(); remove();
return; return;
} }
if (charging) if (charging) {
{ if (stage == 4 || !player.isSneaking()) {
if (stage == 4 || !player.isSneaking())
{
charging = false; charging = false;
} } else {
else if ((System.currentTimeMillis() - this.stageStart) >= ((Math.max(0, this.stageTimeMult * (this.stage - 1))) * 1000)) {
{
if ((System.currentTimeMillis() - this.stageStart) >= ((Math.max(0, this.stageTimeMult * (this.stage - 1))) * 1000))
{
this.stage++; this.stage++;
this.stageStart = System.currentTimeMillis(); this.stageStart = System.currentTimeMillis();
Random random = new Random(); 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(), 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); 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); player.getWorld().playEffect(player.getLocation(), Effect.GHAST_SHOOT, 0, 10);
} }
return;
} }
return;
} }
Vector direction = null; Vector direction = null;
if (!this.activationHandled) if (!this.activationHandled) {
{
this.origin = player.getLocation().clone(); this.origin = player.getLocation().clone();
direction = player.getEyeLocation().getDirection().clone().normalize(); direction = player.getEyeLocation().getDirection().clone().normalize();
@ -107,24 +97,10 @@ public class Catapult extends EarthAbility {
remove(); remove();
return; return;
} }
this.activationHandled = true;
if (isEarthbendable(player.getLocation().getBlock()) || isEarthbendable(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) { bPlayer.addCooldown(this);
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());
} }
Location tar = this.origin.clone().add(direction.clone().normalize().multiply(this.stage + 0.5));
this.target = tar; this.target = tar;
Vector apply = this.target.clone().toVector().subtract(this.origin.clone().toVector()); Vector apply = this.target.clone().toVector().subtract(this.origin.clone().toVector());
player.setVelocity(apply); player.setVelocity(apply);
@ -167,24 +143,16 @@ public class Catapult extends EarthAbility {
public void setOrigin(Location origin) { public void setOrigin(Location origin) {
this.origin = origin; this.origin = origin;
} }
public Location getTarget() { public Location getTarget() {
return target; return target;
} }
public void setTarget(Location target) { public void setTarget(Location target) {
this.target = target; this.target = target;
} }
public int getDistance() {
return distance;
}
public void setDistance(int distance) {
this.distance = distance;
}
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
} }

View file

@ -313,7 +313,7 @@ public class OctopusForm extends WaterAbility {
} }
} }
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
freezeBellow(player.getLocation().add(i / 3 - 1, 0, i % 3 - 1).getBlock()); freezeBelow(player.getLocation().add(i / 3 - 1, 0, i / 3 - 1).getBlock());
} }
Vector eyeDir = player.getEyeLocation().getDirection(); Vector eyeDir = player.getEyeLocation().getDirection();
@ -404,15 +404,16 @@ public class OctopusForm extends WaterAbility {
} }
newBlocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8)); newBlocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8));
} }
freezeBelow(block);
} }
private void addBaseWater(Block block) { private void addBaseWater(Block block) {
freezeBellow(block); freezeBelow(block);
addWater(block); addWater(block);
} }
private void freezeBellow(Block block) { private void freezeBelow(Block block) {
if (isWater(block.getRelative(BlockFace.DOWN)) && !GeneralMethods.isSolid(block) && !isWater(block)) {//&& !TempBlock.isTempBlock(block)) { if (isWater(block.getRelative(BlockFace.DOWN)) && !TempBlock.isTempBlock(block)) {
if (hasAbility(player, PhaseChange.class)) { if (hasAbility(player, PhaseChange.class)) {
getAbility(player, PhaseChange.class).freeze(block); getAbility(player, PhaseChange.class).freeze(block);
} else { } else {