mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-10-31 17:29:25 +00:00
Fix config issues in AirBlast, AirSuction, and EarthSmash (#1008)
## Additions * Adds self/others options for AirSuction ## Fixes * Fixes AirBlast push self and others being mixed up * Fixes AirBlast not using self push at all * #1006 * Fixes EarthSmash using nonexistent AvatarState config options ## Removals * Removes unnecessary arithmetic from AirBlast and AirSuction in determining knockback power * Defaults in config have been changed to make up for removing the arithmetic
This commit is contained in:
parent
5637750166
commit
3972104586
|
@ -141,8 +141,8 @@ public class AirBlast extends AirAbility {
|
|||
this.speed = getConfig().getDouble("Abilities.Air.AirBlast.Speed");
|
||||
this.range = getConfig().getDouble("Abilities.Air.AirBlast.Range");
|
||||
this.radius = getConfig().getDouble("Abilities.Air.AirBlast.Radius");
|
||||
this.pushFactor = getConfig().getDouble("Abilities.Air.AirBlast.Push.Entities");
|
||||
this.pushFactorForOthers = getConfig().getDouble("Abilities.Air.AirBlast.Push.Self");
|
||||
this.pushFactor = getConfig().getDouble("Abilities.Air.AirBlast.Push.Self");
|
||||
this.pushFactorForOthers = getConfig().getDouble("Abilities.Air.AirBlast.Push.Entities");
|
||||
this.canFlickLevers = getConfig().getBoolean("Abilities.Air.AirBlast.CanFlickLevers");
|
||||
this.canOpenDoors = getConfig().getBoolean("Abilities.Air.AirBlast.CanOpenDoors");
|
||||
this.canPressButtons = getConfig().getBoolean("Abilities.Air.AirBlast.CanPressButtons");
|
||||
|
@ -212,14 +212,26 @@ public class AirBlast extends AirAbility {
|
|||
}
|
||||
|
||||
private void affect(final Entity entity) {
|
||||
final boolean isUser = entity.getUniqueId() == this.player.getUniqueId();
|
||||
|
||||
if (!isUser || this.isFromOtherOrigin) {
|
||||
this.pushFactor = this.pushFactorForOthers;
|
||||
final Vector velocity = entity.getVelocity();
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!affectedEntities.contains(entity)) {
|
||||
final boolean isUser = entity.getUniqueId() == this.player.getUniqueId();
|
||||
double knockback = this.pushFactorForOthers;
|
||||
|
||||
if (isUser) {
|
||||
if (isFromOtherOrigin) {
|
||||
knockback = this.pushFactor;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final double max = this.speed / this.speedFactor;
|
||||
double factor = this.pushFactor;
|
||||
|
||||
|
||||
final Vector push = this.direction.clone();
|
||||
if (Math.abs(push.getY()) > max && !isUser) {
|
||||
if (push.getY() < 0) {
|
||||
|
@ -228,56 +240,46 @@ public class AirBlast extends AirAbility {
|
|||
push.setY(max);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.location.getWorld().equals(this.origin.getWorld())) {
|
||||
factor *= 1 - this.location.distance(this.origin) / (2 * this.range);
|
||||
knockback *= 1 - this.location.distance(this.origin) / (2 * this.range);
|
||||
}
|
||||
|
||||
if (isUser && GeneralMethods.isSolid(this.player.getLocation().add(0, -.5, 0).getBlock())) {
|
||||
factor *= .5;
|
||||
|
||||
if (GeneralMethods.isSolid(entity.getLocation().add(0, -.5, 0).getBlock())) {
|
||||
knockback *= .5;
|
||||
}
|
||||
|
||||
final double comp = velocity.dot(push.clone().normalize());
|
||||
if (comp > factor) {
|
||||
velocity.multiply(.5);
|
||||
velocity.add(push.clone().normalize().multiply(velocity.clone().dot(push.clone().normalize())));
|
||||
} else if (comp + factor * .5 > factor) {
|
||||
velocity.add(push.clone().multiply(factor - comp));
|
||||
} else {
|
||||
velocity.add(push.clone().multiply(factor * .5));
|
||||
|
||||
push.normalize().multiply(knockback);
|
||||
|
||||
if (Math.abs(entity.getVelocity().dot(push)) > knockback) {
|
||||
push.normalize().add(entity.getVelocity()).multiply(knockback);
|
||||
}
|
||||
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Double.isNaN(velocity.length())) {
|
||||
return;
|
||||
}
|
||||
|
||||
GeneralMethods.setVelocity(entity, velocity);
|
||||
|
||||
GeneralMethods.setVelocity(entity, push);
|
||||
|
||||
if (this.source != null) {
|
||||
new HorizontalVelocityTracker(entity, this.player, 200l, this.source);
|
||||
} else {
|
||||
new HorizontalVelocityTracker(entity, this.player, 200l, this);
|
||||
}
|
||||
|
||||
if (entity.getFireTicks() > 0) {
|
||||
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
|
||||
}
|
||||
|
||||
entity.setFireTicks(0);
|
||||
breakBreathbendingHold(entity);
|
||||
|
||||
if (this.source != null && (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player) && !this.affectedEntities.contains(entity))) {
|
||||
DamageHandler.damageEntity(entity, this.damage, this.source);
|
||||
this.affectedEntities.add(entity);
|
||||
} else if (this.source == null && (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player) && !this.affectedEntities.contains(entity))) {
|
||||
DamageHandler.damageEntity(entity, this.damage, this);
|
||||
this.affectedEntities.add(entity);
|
||||
|
||||
if (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player)) {
|
||||
if (this.source != null) {
|
||||
DamageHandler.damageEntity(entity, this.damage, this.source);
|
||||
} else {
|
||||
DamageHandler.damageEntity(entity, this.damage, this);
|
||||
}
|
||||
}
|
||||
|
||||
this.affectedEntities.add(entity);
|
||||
}
|
||||
|
||||
if (entity.getFireTicks() > 0) {
|
||||
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
|
||||
}
|
||||
|
||||
entity.setFireTicks(0);
|
||||
breakBreathbendingHold(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,6 +42,8 @@ public class AirSuction extends AirAbility {
|
|||
private double radius;
|
||||
@Attribute(Attribute.KNOCKBACK)
|
||||
private double pushFactor;
|
||||
@Attribute(Attribute.KNOCKBACK + "Others")
|
||||
private double pushFactorForOthers;
|
||||
private Random random;
|
||||
private Location location;
|
||||
private Location origin;
|
||||
|
@ -76,7 +78,8 @@ public class AirSuction extends AirAbility {
|
|||
this.speed = getConfig().getDouble("Abilities.Air.AirSuction.Speed");
|
||||
this.range = getConfig().getDouble("Abilities.Air.AirSuction.Range");
|
||||
this.radius = getConfig().getDouble("Abilities.Air.AirSuction.Radius");
|
||||
this.pushFactor = getConfig().getDouble("Abilities.Air.AirSuction.Push");
|
||||
this.pushFactor = getConfig().getDouble("Abilities.Air.AirSuction.Push.Self");
|
||||
this.pushFactorForOthers = getConfig().getDouble("Abilities.Air.AirSuction.Push.Others");
|
||||
this.cooldown = getConfig().getLong("Abilities.Air.AirSuction.Cooldown");
|
||||
this.random = new Random();
|
||||
this.origin = this.getTargetLocation();
|
||||
|
@ -201,10 +204,15 @@ public class AirSuction extends AirAbility {
|
|||
if ((entity.getEntityId() == this.player.getEntityId()) && !this.canAffectSelf) {
|
||||
continue;
|
||||
}
|
||||
final Vector velocity = entity.getVelocity();
|
||||
|
||||
double knockback = this.pushFactor;
|
||||
|
||||
if (entity.getEntityId() != player.getEntityId()) {
|
||||
knockback = this.pushFactorForOthers;
|
||||
}
|
||||
|
||||
final double max = this.speed;
|
||||
final Vector push = this.direction.clone();
|
||||
double factor = this.pushFactor;
|
||||
|
||||
if (Math.abs(push.getY()) > max) {
|
||||
if (push.getY() < 0) {
|
||||
|
@ -215,20 +223,16 @@ public class AirSuction extends AirAbility {
|
|||
}
|
||||
|
||||
if (this.location.getWorld().equals(this.origin.getWorld())) {
|
||||
factor *= 1 - this.location.distance(this.origin) / (2 * this.range);
|
||||
knockback *= 1 - this.location.distance(this.origin) / (2 * this.range);
|
||||
}
|
||||
|
||||
push.normalize().multiply(knockback);
|
||||
|
||||
if (Math.abs(entity.getVelocity().dot(push)) > knockback) {
|
||||
push.normalize().add(entity.getVelocity()).multiply(knockback);
|
||||
}
|
||||
|
||||
final double comp = velocity.dot(push.clone().normalize());
|
||||
if (comp > factor) {
|
||||
velocity.multiply(.5);
|
||||
velocity.add(push.clone().normalize().multiply(velocity.clone().dot(push.clone().normalize())));
|
||||
} else if (comp + factor * .5 > factor) {
|
||||
velocity.add(push.clone().multiply(factor - comp));
|
||||
} else {
|
||||
velocity.add(push.clone().multiply(factor * .5));
|
||||
}
|
||||
|
||||
GeneralMethods.setVelocity(entity, velocity);
|
||||
GeneralMethods.setVelocity(entity, push.normalize().multiply(knockback));
|
||||
new HorizontalVelocityTracker(entity, this.player, 200l, this);
|
||||
entity.setFallDistance(0);
|
||||
|
||||
|
|
|
@ -802,8 +802,8 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Air.AirBlast.SelectParticles", 4);
|
||||
config.addDefault("Abilities.Air.AirBlast.Particles", 6);
|
||||
config.addDefault("Abilities.Air.AirBlast.Cooldown", 500);
|
||||
config.addDefault("Abilities.Air.AirBlast.Push.Self", 2.5);
|
||||
config.addDefault("Abilities.Air.AirBlast.Push.Entities", 3.5);
|
||||
config.addDefault("Abilities.Air.AirBlast.Push.Self", 2.0);
|
||||
config.addDefault("Abilities.Air.AirBlast.Push.Entities", 1.6);
|
||||
config.addDefault("Abilities.Air.AirBlast.CanFlickLevers", true);
|
||||
config.addDefault("Abilities.Air.AirBlast.CanOpenDoors", true);
|
||||
config.addDefault("Abilities.Air.AirBlast.CanPressButtons", true);
|
||||
|
@ -850,7 +850,8 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Air.AirSuction.Range", 20);
|
||||
config.addDefault("Abilities.Air.AirSuction.SelectRange", 10);
|
||||
config.addDefault("Abilities.Air.AirSuction.Radius", 2);
|
||||
config.addDefault("Abilities.Air.AirSuction.Push", 2.5);
|
||||
config.addDefault("Abilities.Air.AirSuction.Push.Self", 2.0);
|
||||
config.addDefault("Abilities.Air.AirSuction.Push.Others", 1.3);
|
||||
config.addDefault("Abilities.Air.AirSuction.Cooldown", 500);
|
||||
config.addDefault("Abilities.Air.AirSuction.Particles", 6);
|
||||
config.addDefault("Abilities.Air.AirSuction.SelectParticles", 6);
|
||||
|
|
|
@ -163,14 +163,14 @@ public class EarthSmash extends EarthAbility {
|
|||
|
||||
if (bPlayer.isAvatarState()) {
|
||||
this.selectRange = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.SelectRange");
|
||||
this.grabRange = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.Grab.Range");
|
||||
this.grabRange = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.GrabRange");
|
||||
this.chargeTime = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthSmash.ChargeTime");
|
||||
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthSmash.Cooldown");
|
||||
this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.Damage");
|
||||
this.knockback = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.Knockback");
|
||||
this.flightSpeed = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.Flight.Speed");
|
||||
this.flightDuration = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthSmash.Flight.Duration");
|
||||
this.shootRange = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.Shoot.Range");
|
||||
this.flightSpeed = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.FlightSpeed");
|
||||
this.flightDuration = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthSmash.FlightTimer");
|
||||
this.shootRange = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthSmash.ShootRange");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue