2015-08-02 06:58:35 +00:00
|
|
|
package com.projectkorra.projectkorra.firebending;
|
|
|
|
|
Various Fixes
* Fixed IceBlast Selection Bug
* Added KnockBack to WallOfFire
Also organized imports.
* Fixed WallOfFire Knockback
* Fixed Watermanip creating air pockets.
Also organized imports.
* Fixed surge wall removing leaves, also re-did my fix on WaterManipulation creating air pockets.
I thought I tested my fix for watermanipulation really well, but I
didn't test it as well as I thought, my bad. With my previous fix, it
fixed watermanip's air pockets, but it would create waterblocks if used
from a waterbottle, this is now fixed.
* Changed addWater to a non-static method, also changed player to non-static.
* Changed Extraction to be a metal ability.
* Fixed WaterManipulation for sure this time.
Sorry for all of the fails before, I would fix a problem, then another
one would arise. This has been test, and I haven't found any new issues,
and I have fixed the previous ones.
2016-06-15 20:44:04 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
2015-08-02 06:58:35 +00:00
|
|
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
Various Fixes
* Fixed IceBlast Selection Bug
* Added KnockBack to WallOfFire
Also organized imports.
* Fixed WallOfFire Knockback
* Fixed Watermanip creating air pockets.
Also organized imports.
* Fixed surge wall removing leaves, also re-did my fix on WaterManipulation creating air pockets.
I thought I tested my fix for watermanipulation really well, but I
didn't test it as well as I thought, my bad. With my previous fix, it
fixed watermanip's air pockets, but it would create waterblocks if used
from a waterbottle, this is now fixed.
* Changed addWater to a non-static method, also changed player to non-static.
* Changed Extraction to be a metal ability.
* Fixed WaterManipulation for sure this time.
Sorry for all of the fails before, I would fix a problem, then another
one would arise. This has been test, and I haven't found any new issues,
and I have fixed the previous ones.
2016-06-15 20:44:04 +00:00
|
|
|
import com.projectkorra.projectkorra.GeneralMethods;
|
|
|
|
import com.projectkorra.projectkorra.ability.AirAbility;
|
|
|
|
import com.projectkorra.projectkorra.ability.FireAbility;
|
2017-01-07 06:28:21 +00:00
|
|
|
import com.projectkorra.projectkorra.firebending.util.FireDamageTimer;
|
Various Fixes
* Fixed IceBlast Selection Bug
* Added KnockBack to WallOfFire
Also organized imports.
* Fixed WallOfFire Knockback
* Fixed Watermanip creating air pockets.
Also organized imports.
* Fixed surge wall removing leaves, also re-did my fix on WaterManipulation creating air pockets.
I thought I tested my fix for watermanipulation really well, but I
didn't test it as well as I thought, my bad. With my previous fix, it
fixed watermanip's air pockets, but it would create waterblocks if used
from a waterbottle, this is now fixed.
* Changed addWater to a non-static method, also changed player to non-static.
* Changed Extraction to be a metal ability.
* Fixed WaterManipulation for sure this time.
Sorry for all of the fails before, I would fix a problem, then another
one would arise. This has been test, and I haven't found any new issues,
and I have fixed the previous ones.
2016-06-15 20:44:04 +00:00
|
|
|
import com.projectkorra.projectkorra.util.DamageHandler;
|
|
|
|
import com.projectkorra.projectkorra.util.ParticleEffect;
|
|
|
|
import com.projectkorra.projectkorra.util.TempBlock;
|
2016-01-13 21:14:34 +00:00
|
|
|
|
|
|
|
public class WallOfFire extends FireAbility {
|
|
|
|
|
|
|
|
private boolean active;
|
|
|
|
private int damageTick;
|
|
|
|
private int intervalTick;
|
|
|
|
private int range;
|
|
|
|
private int height;
|
|
|
|
private int width;
|
|
|
|
private int damage;
|
|
|
|
private long cooldown;
|
|
|
|
private long damageInterval;
|
|
|
|
private long duration;
|
|
|
|
private long time;
|
|
|
|
private long interval;
|
|
|
|
private double fireTicks;
|
|
|
|
private double maxAngle;
|
|
|
|
private Random random;
|
2015-08-02 06:58:35 +00:00
|
|
|
private Location origin;
|
2016-01-13 21:14:34 +00:00
|
|
|
private List<Block> blocks;
|
|
|
|
|
2015-08-02 06:58:35 +00:00
|
|
|
public WallOfFire(Player player) {
|
2016-01-13 21:14:34 +00:00
|
|
|
super(player);
|
|
|
|
|
|
|
|
this.active = true;
|
2016-01-16 21:07:14 +00:00
|
|
|
this.maxAngle = getConfig().getDouble("Abilities.Fire.WallOfFire.MaxAngle");
|
|
|
|
this.interval = getConfig().getLong("Abilities.Fire.WallOfFire.Interval");
|
2016-01-13 21:14:34 +00:00
|
|
|
this.range = getConfig().getInt("Abilities.Fire.WallOfFire.Range");
|
|
|
|
this.height = getConfig().getInt("Abilities.Fire.WallOfFire.Height");
|
|
|
|
this.width = getConfig().getInt("Abilities.Fire.WallOfFire.Width");
|
|
|
|
this.damage = getConfig().getInt("Abilities.Fire.WallOfFire.Damage");
|
|
|
|
this.cooldown = getConfig().getLong("Abilities.Fire.WallOfFire.Cooldown");
|
2016-01-16 21:07:14 +00:00
|
|
|
this.damageInterval = getConfig().getLong("Abilities.Fire.WallOfFire.DamageInterval");
|
2016-01-13 21:14:34 +00:00
|
|
|
this.duration = getConfig().getLong("Abilities.Fire.WallOfFire.Duration");
|
|
|
|
this.fireTicks = getConfig().getDouble("Abilities.Fire.WallOfFire.FireTicks");
|
|
|
|
this.random = new Random();
|
|
|
|
this.blocks = new ArrayList<>();
|
|
|
|
|
|
|
|
if (hasAbility(player, WallOfFire.class) && !bPlayer.isAvatarState()) {
|
2015-08-02 06:58:35 +00:00
|
|
|
return;
|
2016-01-13 21:14:34 +00:00
|
|
|
} else if (bPlayer.isOnCooldown(this)) {
|
2015-08-02 06:58:35 +00:00
|
|
|
return;
|
2016-01-13 21:14:34 +00:00
|
|
|
}
|
|
|
|
|
2015-08-02 06:58:35 +00:00
|
|
|
origin = GeneralMethods.getTargetedLocation(player, range);
|
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
if (isDay(player.getWorld())) {
|
|
|
|
width = (int) getDayFactor(width);
|
|
|
|
height = (int) getDayFactor(height);
|
|
|
|
duration = (long) getDayFactor(duration);
|
|
|
|
damage = (int) getDayFactor(damage);
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
time = System.currentTimeMillis();
|
|
|
|
Block block = origin.getBlock();
|
|
|
|
if (block.isLiquid() || GeneralMethods.isSolid(block)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector direction = player.getEyeLocation().getDirection();
|
|
|
|
Vector compare = direction.clone();
|
|
|
|
compare.setY(0);
|
2016-01-13 21:14:34 +00:00
|
|
|
if (Math.abs(direction.angle(compare)) > Math.toRadians(maxAngle)) {
|
2015-08-02 06:58:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
initializeBlocks();
|
2016-01-13 21:14:34 +00:00
|
|
|
start();
|
|
|
|
bPlayer.addCooldown(this);
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void affect(Entity entity) {
|
2016-08-23 19:54:50 +00:00
|
|
|
GeneralMethods.setVelocity(entity, new Vector(0, 0, 0));
|
2015-08-02 06:58:35 +00:00
|
|
|
if (entity instanceof LivingEntity) {
|
2016-01-31 21:02:21 +00:00
|
|
|
Block block = ((LivingEntity) entity).getEyeLocation().getBlock();
|
|
|
|
if (TempBlock.isTempBlock(block) && isIce(block)) {
|
|
|
|
return;
|
|
|
|
}
|
2016-03-03 01:54:15 +00:00
|
|
|
DamageHandler.damageEntity(entity, damage, this);
|
2016-01-13 21:14:34 +00:00
|
|
|
AirAbility.breakBreathbendingHold(entity);
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
2016-01-31 21:02:21 +00:00
|
|
|
entity.setFireTicks((int) (fireTicks * 20));
|
|
|
|
new FireDamageTimer(entity, player);
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void damage() {
|
|
|
|
double radius = height;
|
2016-01-13 21:14:34 +00:00
|
|
|
if (radius < width) {
|
2015-08-02 06:58:35 +00:00
|
|
|
radius = width;
|
2016-01-13 21:14:34 +00:00
|
|
|
}
|
|
|
|
|
2015-08-02 06:58:35 +00:00
|
|
|
radius = radius + 1;
|
|
|
|
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(origin, radius);
|
2016-01-13 21:14:34 +00:00
|
|
|
if (entities.contains(player)) {
|
2015-08-02 06:58:35 +00:00
|
|
|
entities.remove(player);
|
2016-01-13 21:14:34 +00:00
|
|
|
}
|
2015-08-02 06:58:35 +00:00
|
|
|
for (Entity entity : entities) {
|
2016-01-13 21:14:34 +00:00
|
|
|
if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation())) {
|
2015-08-02 06:58:35 +00:00
|
|
|
continue;
|
2016-01-13 21:14:34 +00:00
|
|
|
}
|
2015-08-02 06:58:35 +00:00
|
|
|
for (Block block : blocks) {
|
2016-01-13 21:14:34 +00:00
|
|
|
if (entity.getLocation().distanceSquared(block.getLocation()) <= 1.5 * 1.5) {
|
2015-08-02 06:58:35 +00:00
|
|
|
affect(entity);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void display() {
|
|
|
|
for (Block block : blocks) {
|
2016-01-31 21:02:21 +00:00
|
|
|
if (!isTransparent(block)) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-08-02 22:17:41 +00:00
|
|
|
ParticleEffect.FLAME.display(block.getLocation(), 0.6F, 0.6F, 0.6F, 0, 3);
|
|
|
|
ParticleEffect.SMOKE.display(block.getLocation(), 0.6F, 0.6F, 0.6F, 0, 1);
|
2015-08-02 06:58:35 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
if (random.nextInt(7) == 0) {
|
|
|
|
playFirebendingSound(block.getLocation());
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initializeBlocks() {
|
|
|
|
Vector direction = player.getEyeLocation().getDirection();
|
|
|
|
direction = direction.normalize();
|
|
|
|
|
|
|
|
Vector ortholr = GeneralMethods.getOrthogonalVector(direction, 0, 1);
|
|
|
|
ortholr = ortholr.normalize();
|
|
|
|
|
|
|
|
Vector orthoud = GeneralMethods.getOrthogonalVector(direction, 90, 1);
|
|
|
|
orthoud = orthoud.normalize();
|
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
double w = width;
|
|
|
|
double h = height;
|
2015-08-02 06:58:35 +00:00
|
|
|
|
|
|
|
for (double i = -w; i <= w; i++) {
|
|
|
|
for (double j = -h; j <= h; j++) {
|
|
|
|
Location location = origin.clone().add(orthoud.clone().multiply(j));
|
|
|
|
location = location.add(ortholr.clone().multiply(i));
|
2016-01-13 21:14:34 +00:00
|
|
|
if (GeneralMethods.isRegionProtectedFromBuild(this, location)) {
|
2015-08-02 06:58:35 +00:00
|
|
|
continue;
|
2016-01-13 21:14:34 +00:00
|
|
|
}
|
2015-08-02 06:58:35 +00:00
|
|
|
Block block = location.getBlock();
|
2016-01-13 21:14:34 +00:00
|
|
|
if (!blocks.contains(block)) {
|
2015-08-02 06:58:35 +00:00
|
|
|
blocks.add(block);
|
2016-01-13 21:14:34 +00:00
|
|
|
}
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
@Override
|
|
|
|
public void progress() {
|
2015-08-02 06:58:35 +00:00
|
|
|
time = System.currentTimeMillis();
|
|
|
|
|
2016-10-24 06:23:02 +00:00
|
|
|
if (time - getStartTime() > cooldown) {
|
2015-08-02 06:58:35 +00:00
|
|
|
remove();
|
2016-01-13 21:14:34 +00:00
|
|
|
return;
|
|
|
|
} else if (!active) {
|
|
|
|
return;
|
2016-10-24 06:23:02 +00:00
|
|
|
} else if (time - getStartTime() > duration) {
|
2015-08-02 06:58:35 +00:00
|
|
|
active = false;
|
2016-01-13 21:14:34 +00:00
|
|
|
return;
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
|
2016-10-24 06:23:02 +00:00
|
|
|
if (time - getStartTime() > intervalTick * interval) {
|
2016-01-13 21:14:34 +00:00
|
|
|
intervalTick++;
|
2015-08-02 06:58:35 +00:00
|
|
|
display();
|
|
|
|
}
|
|
|
|
|
2016-10-24 06:23:02 +00:00
|
|
|
if (time - getStartTime() > damageTick * damageInterval) {
|
2016-01-13 21:14:34 +00:00
|
|
|
damageTick++;
|
2015-08-02 06:58:35 +00:00
|
|
|
damage();
|
|
|
|
}
|
|
|
|
}
|
2015-11-11 23:22:27 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return "WallOfFire";
|
2015-11-11 20:19:45 +00:00
|
|
|
}
|
2015-11-11 23:22:27 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
@Override
|
|
|
|
public Location getLocation() {
|
|
|
|
return origin;
|
2015-11-11 09:26:39 +00:00
|
|
|
}
|
2015-11-11 23:22:27 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
@Override
|
|
|
|
public long getCooldown() {
|
|
|
|
return cooldown;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isSneakAbility() {
|
|
|
|
return false;
|
2015-11-11 20:19:45 +00:00
|
|
|
}
|
2015-08-02 06:58:35 +00:00
|
|
|
|
|
|
|
@Override
|
2016-01-13 21:14:34 +00:00
|
|
|
public boolean isHarmlessAbility() {
|
|
|
|
return false;
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
2016-10-24 06:23:02 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<Location> getLocations() {
|
|
|
|
ArrayList<Location> locations = new ArrayList<>();
|
|
|
|
for (Block block : blocks) {
|
|
|
|
locations.add(block.getLocation());
|
|
|
|
}
|
|
|
|
return locations;
|
|
|
|
}
|
2015-08-02 06:58:35 +00:00
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
public boolean isActive() {
|
|
|
|
return active;
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
public void setActive(boolean active) {
|
|
|
|
this.active = active;
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
public int getDamageTick() {
|
|
|
|
return damageTick;
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
public void setDamageTick(int damageTick) {
|
|
|
|
this.damageTick = damageTick;
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
public int getIntervalTick() {
|
|
|
|
return intervalTick;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setIntervalTick(int intervalTick) {
|
|
|
|
this.intervalTick = intervalTick;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getRange() {
|
|
|
|
return range;
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setRange(int range) {
|
|
|
|
this.range = range;
|
|
|
|
}
|
|
|
|
|
2016-01-13 21:14:34 +00:00
|
|
|
public int getHeight() {
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setHeight(int height) {
|
|
|
|
this.height = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getWidth() {
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2015-08-02 06:58:35 +00:00
|
|
|
public void setWidth(int width) {
|
|
|
|
this.width = width;
|
|
|
|
}
|
2016-01-13 21:14:34 +00:00
|
|
|
|
|
|
|
public int getDamage() {
|
|
|
|
return damage;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDamage(int damage) {
|
|
|
|
this.damage = damage;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getDamageInterval() {
|
|
|
|
return damageInterval;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDamageInterval(long damageInterval) {
|
|
|
|
this.damageInterval = damageInterval;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getDuration() {
|
|
|
|
return duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDuration(long duration) {
|
|
|
|
this.duration = duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getTime() {
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTime(long time) {
|
|
|
|
this.time = time;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getInterval() {
|
|
|
|
return interval;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setInterval(long interval) {
|
|
|
|
this.interval = interval;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double getFireTicks() {
|
|
|
|
return fireTicks;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFireTicks(double fireTicks) {
|
|
|
|
this.fireTicks = fireTicks;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double getMaxAngle() {
|
|
|
|
return maxAngle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMaxAngle(double maxAngle) {
|
|
|
|
this.maxAngle = maxAngle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Location getOrigin() {
|
|
|
|
return origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOrigin(Location origin) {
|
|
|
|
this.origin = origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Block> getBlocks() {
|
|
|
|
return blocks;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCooldown(long cooldown) {
|
|
|
|
this.cooldown = cooldown;
|
|
|
|
}
|
|
|
|
|
2015-08-02 06:58:35 +00:00
|
|
|
}
|