mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 03:30:10 +00:00
AirBurst
Also reworked damaging passives. (No Fall Damage / Decreased Fall Damage)
This commit is contained in:
parent
ead0c812d1
commit
47c78ef8d0
3 changed files with 290 additions and 29 deletions
|
@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirBlast;
|
import com.projectkorra.ProjectKorra.airbending.AirBlast;
|
||||||
|
import com.projectkorra.ProjectKorra.airbending.AirBurst;
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirPassive;
|
import com.projectkorra.ProjectKorra.airbending.AirPassive;
|
||||||
import com.projectkorra.ProjectKorra.airbending.Tornado;
|
import com.projectkorra.ProjectKorra.airbending.Tornado;
|
||||||
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
|
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
|
||||||
|
@ -57,6 +58,7 @@ public class BendingManager implements Runnable {
|
||||||
FirePassive.handlePassive();
|
FirePassive.handlePassive();
|
||||||
EarthPassive.revertSands();
|
EarthPassive.revertSands();
|
||||||
Plantbending.regrow();
|
Plantbending.regrow();
|
||||||
|
AirBurst.progressAll();
|
||||||
handleDayNight();
|
handleDayNight();
|
||||||
for (int ID: Tornado.instances.keySet()) {
|
for (int ID: Tornado.instances.keySet()) {
|
||||||
Tornado.progress(ID);
|
Tornado.progress(ID);
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.kitteh.tag.AsyncPlayerReceiveNameTagEvent;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirBlast;
|
import com.projectkorra.ProjectKorra.airbending.AirBlast;
|
||||||
|
import com.projectkorra.ProjectKorra.airbending.AirBurst;
|
||||||
import com.projectkorra.ProjectKorra.airbending.Tornado;
|
import com.projectkorra.ProjectKorra.airbending.Tornado;
|
||||||
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
|
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
||||||
|
@ -105,12 +106,15 @@ public class PKListener implements Listener {
|
||||||
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
|
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (abil == "Tornado") {
|
if (abil.equalsIgnoreCase("Tornado")) {
|
||||||
new Tornado(player);
|
new Tornado(player);
|
||||||
}
|
}
|
||||||
if (abil == "AirBlast") {
|
if (abil.equalsIgnoreCase("AirBlast")) {
|
||||||
AirBlast.setOrigin(player);
|
AirBlast.setOrigin(player);
|
||||||
}
|
}
|
||||||
|
if (abil.equalsIgnoreCase("AirBurst")) {
|
||||||
|
new AirBurst(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,16 +129,19 @@ public class PKListener implements Listener {
|
||||||
String abil = Methods.getBoundAbility(player);
|
String abil = Methods.getBoundAbility(player);
|
||||||
if (abil == null) return;
|
if (abil == null) return;
|
||||||
if (Methods.canBend(player.getName(), abil)) {
|
if (Methods.canBend(player.getName(), abil)) {
|
||||||
if (abil == "AvatarState") {
|
if (abil.equalsIgnoreCase("AvatarState")) {
|
||||||
new AvatarState(player);
|
new AvatarState(player);
|
||||||
}
|
}
|
||||||
if (Methods.isAirAbility(abil)) {
|
if (Methods.isAirAbility(abil)) {
|
||||||
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
|
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (abil == "AirBlast") {
|
if (abil.equalsIgnoreCase("AirBlast")) {
|
||||||
new AirBlast(player);
|
new AirBlast(player);
|
||||||
}
|
}
|
||||||
|
if (abil.equalsIgnoreCase("AirBurst")) {
|
||||||
|
AirBurst.coneBurst(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,6 +167,7 @@ public class PKListener implements Listener {
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onEntityDamageEvent(EntityDamageEvent event) {
|
public void onEntityDamageEvent(EntityDamageEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (event.getCause() == DamageCause.FIRE && FireStream.ignitedblocks.containsKey(entity.getLocation().getBlock())) {
|
if (event.getCause() == DamageCause.FIRE && FireStream.ignitedblocks.containsKey(entity.getLocation().getBlock())) {
|
||||||
new Enflamed(entity, FireStream.ignitedblocks.get(entity.getLocation().getBlock()));
|
new Enflamed(entity, FireStream.ignitedblocks.get(entity.getLocation().getBlock()));
|
||||||
}
|
}
|
||||||
|
@ -203,33 +211,76 @@ public class PKListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onPlayerDamage(EntityDamageEvent e) {
|
public void onPlayerDamage(EntityDamageEvent event) {
|
||||||
Entity en = e.getEntity();
|
if (event.getEntity() instanceof Player) {
|
||||||
if (en instanceof Player) { // Player is the one being hurt.
|
Player player = (Player) event.getEntity();
|
||||||
Player p = (Player) en;
|
|
||||||
if (e.getCause() == DamageCause.FALL) { // Result is Fall Damage
|
if (Methods.isBender(player.getName(), Element.Earth) && event.getCause() == DamageCause.FALL) {
|
||||||
if (Methods.canBendPassive(p.getName(), Element.Air)) {
|
Shockwave.fallShockwave(player);
|
||||||
e.setDamage(0.0);
|
}
|
||||||
}
|
|
||||||
if (Methods.canBendPassive(p.getName(), Element.Chi)) {
|
if (Methods.isBender(player.getName(), Element.Air) && event.getCause() == DamageCause.FALL && Methods.canBendPassive(player.getName(), Element.Air)) {
|
||||||
double initdamage = e.getDamage();
|
new Flight(player);
|
||||||
double newdamage = e.getDamage() * ChiPassive.FallReductionFactor;
|
player.setAllowFlight(true);
|
||||||
double finaldamage = initdamage - newdamage;
|
AirBurst.fallBurst(player);
|
||||||
e.setDamage(finaldamage);
|
player.setFallDistance(0);
|
||||||
}
|
event.setDamage(0);
|
||||||
if (Methods.canBendPassive(p.getName(), Element.Water)) {
|
event.setCancelled(true);
|
||||||
if (WaterPassive.applyNoFall(p)) {
|
}
|
||||||
e.setDamage(0.0);
|
|
||||||
}
|
if (!event.isCancelled() && Methods.isBender(player.getName(), Element.Water) && event.getCause() == DamageCause.FALL && Methods.canBendPassive(player.getName(), Element.Water)) {
|
||||||
}
|
if (WaterPassive.applyNoFall(player)) {
|
||||||
|
new Flight(player);
|
||||||
if (Methods.canBendPassive(p.getName(), Element.Earth)) {
|
player.setAllowFlight(true);
|
||||||
if (EarthPassive.softenLanding(p)) {
|
player.setFallDistance(0);
|
||||||
e.setDamage(0.0);
|
event.setDamage(0);
|
||||||
}
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!event.isCancelled()
|
||||||
|
&& Methods.isBender(player.getName(), Element.Earth)
|
||||||
|
&& event.getCause() == DamageCause.FALL
|
||||||
|
&& Methods.canBendPassive(player.getName(), Element.Earth)) {
|
||||||
|
if (EarthPassive.softenLanding(player)) {
|
||||||
|
new Flight(player);
|
||||||
|
player.setAllowFlight(true);
|
||||||
|
player.setFallDistance(0);
|
||||||
|
event.setDamage(0);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!event.isCancelled()
|
||||||
|
&& Methods.isBender(player.getName(), Element.Chi)
|
||||||
|
&& event.getCause() == DamageCause.FALL
|
||||||
|
&& Methods.canBendPassive(player.getName(), Element.Chi)) {
|
||||||
|
double initdamage = event.getDamage();
|
||||||
|
double newdamage = event.getDamage() * ChiPassive.FallReductionFactor;
|
||||||
|
double finaldamage = initdamage - newdamage;
|
||||||
|
event.setDamage(finaldamage);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!event.isCancelled() && event.getCause() == DamageCause.FALL) {
|
||||||
|
Player source = Flight.getLaunchedBy(player);
|
||||||
|
if (source != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
Methods.damageEntity(source, player, event.getDamage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Methods.canBendPassive(player.getName(), Element.Fire)
|
||||||
|
&& Methods.isBender(player.getName(), Element.Fire)
|
||||||
|
&& (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) {
|
||||||
|
event.setCancelled(!Extinguish.canBurn(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Methods.isBender(player.getName(), Element.Earth)
|
||||||
|
&& event.getCause() == DamageCause.SUFFOCATION && TempBlock.isTempBlock(player.getEyeLocation().getBlock())) {
|
||||||
|
event.setDamage(0);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
208
src/com/projectkorra/ProjectKorra/airbending/AirBurst.java
Normal file
208
src/com/projectkorra/ProjectKorra/airbending/AirBurst.java
Normal file
|
@ -0,0 +1,208 @@
|
||||||
|
package com.projectkorra.ProjectKorra.airbending;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import com.projectkorra.ProjectKorra.Methods;
|
||||||
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
|
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||||
|
|
||||||
|
public class AirBurst {
|
||||||
|
|
||||||
|
private static ConcurrentHashMap<Player, AirBurst> instances = new ConcurrentHashMap<Player, AirBurst>();
|
||||||
|
private static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
|
||||||
|
|
||||||
|
private static double threshold = 10;
|
||||||
|
private static double pushfactor = 1.5;
|
||||||
|
private static double deltheta = 10;
|
||||||
|
private static double delphi = 10;
|
||||||
|
|
||||||
|
private Player player;
|
||||||
|
private long starttime;
|
||||||
|
private long chargetime = 1750;
|
||||||
|
private boolean charged = false;
|
||||||
|
|
||||||
|
private ArrayList<Entity> affectedentities = new ArrayList<Entity>();
|
||||||
|
|
||||||
|
public AirBurst(Player player) {
|
||||||
|
if (cooldowns.containsKey(player.getName())) {
|
||||||
|
if (cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
cooldowns.remove(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (instances.containsKey(player))
|
||||||
|
return;
|
||||||
|
starttime = System.currentTimeMillis();
|
||||||
|
if (AvatarState.isAvatarState(player))
|
||||||
|
chargetime = 0;
|
||||||
|
this.player = player;
|
||||||
|
instances.put(player, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AirBurst() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void coneBurst(Player player) {
|
||||||
|
if (instances.containsKey(player))
|
||||||
|
instances.get(player).coneBurst();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void coneBurst() {
|
||||||
|
if (charged) {
|
||||||
|
Location location = player.getEyeLocation();
|
||||||
|
Vector vector = location.getDirection();
|
||||||
|
double angle = Math.toRadians(30);
|
||||||
|
double x, y, z;
|
||||||
|
double r = 1;
|
||||||
|
for (double theta = 0; theta <= 180; theta += deltheta) {
|
||||||
|
double dphi = delphi / Math.sin(Math.toRadians(theta));
|
||||||
|
for (double phi = 0; phi < 360; phi += dphi) {
|
||||||
|
double rphi = Math.toRadians(phi);
|
||||||
|
double rtheta = Math.toRadians(theta);
|
||||||
|
x = r * Math.cos(rphi) * Math.sin(rtheta);
|
||||||
|
y = r * Math.sin(rphi) * Math.sin(rtheta);
|
||||||
|
z = r * Math.cos(rtheta);
|
||||||
|
Vector direction = new Vector(x, z, y);
|
||||||
|
if (direction.angle(vector) <= angle) {
|
||||||
|
// Methods.verbose(direction.angle(vector));
|
||||||
|
// Methods.verbose(direction);
|
||||||
|
new AirBlast(location, direction.normalize(), player,
|
||||||
|
pushfactor, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Methods.verbose("--" + AirBlast.instances.size() + "--");
|
||||||
|
instances.remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sphereBurst() {
|
||||||
|
if (charged) {
|
||||||
|
Location location = player.getEyeLocation();
|
||||||
|
double x, y, z;
|
||||||
|
double r = 1;
|
||||||
|
for (double theta = 0; theta <= 180; theta += deltheta) {
|
||||||
|
double dphi = delphi / Math.sin(Math.toRadians(theta));
|
||||||
|
for (double phi = 0; phi < 360; phi += dphi) {
|
||||||
|
double rphi = Math.toRadians(phi);
|
||||||
|
double rtheta = Math.toRadians(theta);
|
||||||
|
x = r * Math.cos(rphi) * Math.sin(rtheta);
|
||||||
|
y = r * Math.sin(rphi) * Math.sin(rtheta);
|
||||||
|
z = r * Math.cos(rtheta);
|
||||||
|
Vector direction = new Vector(x, z, y);
|
||||||
|
new AirBlast(location, direction.normalize(), player,
|
||||||
|
pushfactor, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Methods.verbose("--" + AirBlast.instances.size() + "--");
|
||||||
|
instances.remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fallBurst(Player player) {
|
||||||
|
if (!Methods.canBend(player.getName(), "AirBurst")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (player.getFallDistance() < threshold) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Methods.getBoundAbility(player) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (instances.containsKey(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Methods.getBoundAbility(player).equalsIgnoreCase("AirBurst")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location location = player.getLocation();
|
||||||
|
double x, y, z;
|
||||||
|
double r = 1;
|
||||||
|
for (double theta = 75; theta < 105; theta += deltheta) {
|
||||||
|
double dphi = delphi / Math.sin(Math.toRadians(theta));
|
||||||
|
for (double phi = 0; phi < 360; phi += dphi) {
|
||||||
|
double rphi = Math.toRadians(phi);
|
||||||
|
double rtheta = Math.toRadians(theta);
|
||||||
|
x = r * Math.cos(rphi) * Math.sin(rtheta);
|
||||||
|
y = r * Math.sin(rphi) * Math.sin(rtheta);
|
||||||
|
z = r * Math.cos(rtheta);
|
||||||
|
Vector direction = new Vector(x, z, y);
|
||||||
|
new AirBlast(location, direction.normalize(), player,
|
||||||
|
pushfactor, new AirBurst());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void addAffectedEntity(Entity entity) {
|
||||||
|
affectedentities.add(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isAffectedEntity(Entity entity) {
|
||||||
|
return affectedentities.contains(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void progress() {
|
||||||
|
if (!Methods.canBend(player.getName(), "AirBurst")) {
|
||||||
|
instances.remove(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Methods.getBoundAbility(player) == null) {
|
||||||
|
instances.remove(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Methods.getBoundAbility(player).equalsIgnoreCase("AirBurst")) {
|
||||||
|
instances.remove(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (System.currentTimeMillis() > starttime + chargetime && !charged) {
|
||||||
|
charged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!player.isSneaking()) {
|
||||||
|
if (charged) {
|
||||||
|
sphereBurst();
|
||||||
|
} else {
|
||||||
|
instances.remove(player);
|
||||||
|
}
|
||||||
|
} else if (charged) {
|
||||||
|
Location location = player.getEyeLocation();
|
||||||
|
// location = location.add(location.getDirection().normalize());
|
||||||
|
location.getWorld().playEffect(
|
||||||
|
location,
|
||||||
|
Effect.SMOKE,
|
||||||
|
Methods.getIntCardinalDirection(player.getEyeLocation()
|
||||||
|
.getDirection()), 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void progressAll() {
|
||||||
|
for (Player player : instances.keySet())
|
||||||
|
instances.get(player).progress();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDescription() {
|
||||||
|
return "AirBurst is one of the most powerful abilities in the airbender's arsenal. "
|
||||||
|
+ "To use, press and hold sneak to charge your burst. "
|
||||||
|
+ "Once charged, you can either release sneak to launch a cone-shaped burst "
|
||||||
|
+ "of air in front of you, or click to release the burst in a sphere around you. "
|
||||||
|
+ "Additionally, having this ability selected when you land on the ground from a "
|
||||||
|
+ "large enough fall will create a burst of air around you.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeAll() {
|
||||||
|
instances.clear();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue