use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class OrderOfEviscerate method onActivate.
@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
wp.subtractEnergy(energyCost);
wp.getCooldownManager().removeCooldown(OrderOfEviscerate.class);
wp.getCooldownManager().addCooldown(new RegularCooldown<OrderOfEviscerate>("Order of Eviscerate", "ORDER", OrderOfEviscerate.class, new OrderOfEviscerate(), wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20) {
@Override
public void doBeforeReductionFromSelf(WarlordsDamageHealingEvent event) {
OrderOfEviscerate.removeCloak(wp, false);
}
@Override
public void doBeforeReductionFromAttacker(WarlordsDamageHealingEvent event) {
// mark message here so it displays before damage
WarlordsPlayer victim = event.getPlayer();
if (!Objects.equals(this.getCooldownObject().getMarkedPlayer(), victim)) {
wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You have marked §e" + victim.getName());
}
this.getCooldownObject().setMarkedPlayer(victim);
}
@Override
public float modifyDamageBeforeInterveneFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue) {
if (this.getCooldownObject().getMarkedPlayer().equals(event.getPlayer()) && !Utils.isLineOfSightAssassin(event.getPlayer().getEntity(), event.getAttacker().getEntity())) {
return currentDamageValue * 1.25f;
}
return currentDamageValue;
}
@Override
public void onDeathFromEnemies(WarlordsDamageHealingEvent event, float currentDamageValue, boolean isCrit, boolean isKiller) {
wp.getCooldownManager().removeCooldown(OrderOfEviscerate.class);
wp.getCooldownManager().removeCooldownByName("Cloaked");
if (isKiller) {
wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You killed your mark," + ChatColor.YELLOW + " your cooldowns have been reset" + ChatColor.GRAY + "!");
new GameRunnable(wp.getGame()) {
@Override
public void run() {
wp.getSpec().getPurple().setCurrentCooldown(0);
wp.getSpec().getOrange().setCurrentCooldown(0);
wp.updatePurpleItem();
wp.updateOrangeItem();
wp.subtractEnergy(-wp.getSpec().getOrange().getEnergyCost());
}
}.runTaskLater(2);
} else {
new GameRunnable(wp.getGame()) {
@Override
public void run() {
wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You assisted in killing your mark," + ChatColor.YELLOW + " your cooldowns have been reduced by half" + ChatColor.GRAY + "!");
wp.getSpec().getPurple().setCurrentCooldown(wp.getSpec().getPurple().getCurrentCooldown() / 2);
wp.getSpec().getOrange().setCurrentCooldown(wp.getSpec().getOrange().getCurrentCooldown() / 2);
wp.updatePurpleItem();
wp.updateOrangeItem();
wp.subtractEnergy(-wp.getSpec().getOrange().getEnergyCost() / 2);
}
}.runTaskLater(2);
}
if (wp.getEntity() instanceof Player) {
((Player) wp.getEntity()).playSound(wp.getLocation(), Sound.AMBIENCE_THUNDER, 1, 2);
}
}
});
if (!FlagHolder.isPlayerHolderFlag(wp)) {
wp.getCooldownManager().removeCooldownByName("Cloaked");
wp.getCooldownManager().addRegularCooldown("Cloaked", "INVIS", OrderOfEviscerate.class, new OrderOfEviscerate(), wp, CooldownTypes.BUFF, cooldownManager -> {
}, duration * 20);
player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, duration * 20, 0, true, false), true);
wp.updateArmor();
PlayerFilter.playingGame(wp.getGame()).enemiesOf(wp).forEach(warlordsPlayer -> {
LivingEntity livingEntity = warlordsPlayer.getEntity();
if (livingEntity instanceof Player) {
((Player) livingEntity).hidePlayer(player);
}
});
}
Runnable cancelSpeed = wp.getSpeed().addSpeedModifier("Order of Eviscerate", 40, duration * 20, "BASE");
Utils.playGlobalSound(player.getLocation(), Sound.GHAST_FIREBALL, 2, 0.7f);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (!wp.getCooldownManager().hasCooldown(OrderOfEviscerate.class)) {
this.cancel();
// wp.setMarkedTarget(null);
cancelSpeed.run();
removeCloak(wp, true);
} else {
ParticleEffect.SMOKE_NORMAL.display(0.01f, 0.28f, 0.01f, 0.05f, 6, wp.getLocation(), 500);
Utils.playGlobalSound(wp.getLocation(), Sound.AMBIENCE_CAVE, 0.08f, 2);
}
}
}.runTaskTimer(0, 1);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class PrismGuard method onActivate.
@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
wp.subtractEnergy(energyCost);
PrismGuard tempWideGuard = new PrismGuard();
Set<WarlordsPlayer> isInsideBubble = new HashSet<>();
wp.getCooldownManager().addCooldown(new RegularCooldown<PrismGuard>("Prism Guard", "GUARD", PrismGuard.class, tempWideGuard, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20) {
@Override
public float modifyDamageAfterInterveneFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue) {
String ability = event.getAbility();
if (ability.equals("Fireball") || ability.equals("Frostbolt") || ability.equals("Water Bolt") || ability.equals("Lightning Bolt") || ability.equals("Flame Burst") || ability.equals("Fallen Souls")) {
if (isInsideBubble.contains(event.getAttacker())) {
return currentDamageValue;
} else {
return currentDamageValue * .4f;
}
} else {
return currentDamageValue * .75f;
}
}
});
Utils.playGlobalSound(wp.getLocation(), "mage.timewarp.teleport", 2, 2);
Utils.playGlobalSound(player.getLocation(), "warrior.intervene.impact", 2, 0.1f);
// First Particle Sphere
playSphereAnimation(wp.getLocation(), bubbleRadius + 2.5, 68, 176, 176);
// Second Particle Sphere
new GameRunnable(wp.getGame()) {
@Override
public void run() {
playSphereAnimation(wp.getLocation(), bubbleRadius + 1, 65, 185, 185);
Utils.playGlobalSound(wp.getLocation(), "warrior.intervene.impact", 2, 0.2f);
}
}.runTaskLater(3);
HashMap<WarlordsPlayer, Integer> timeInBubble = new HashMap<>();
// Third Particle Sphere
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (wp.getCooldownManager().hasCooldown(tempWideGuard)) {
playSphereAnimation(wp.getLocation(), bubbleRadius, 190, 190, 190);
Utils.playGlobalSound(wp.getLocation(), Sound.CREEPER_DEATH, 2, 2);
timeInBubble.compute(wp, (k, v) -> v == null ? 1 : v + 1);
isInsideBubble.clear();
for (WarlordsPlayer enemyInsideBubble : PlayerFilter.entitiesAround(wp, bubbleRadius, bubbleRadius, bubbleRadius).aliveEnemiesOf(wp)) {
isInsideBubble.add(enemyInsideBubble);
}
for (WarlordsPlayer bubblePlayer : PlayerFilter.entitiesAround(wp, bubbleRadius, bubbleRadius, bubbleRadius).aliveTeammatesOfExcludingSelf(wp)) {
bubblePlayer.getCooldownManager().removeCooldown(PrismGuard.class);
bubblePlayer.getCooldownManager().addCooldown(new RegularCooldown<PrismGuard>("Prism Guard", "GUARD", PrismGuard.class, tempWideGuard, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, 20) {
@Override
public float modifyDamageAfterInterveneFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue) {
String ability = event.getAbility();
if (ability.equals("Fireball") || ability.equals("Frostbolt") || ability.equals("Water Bolt") || ability.equals("Lightning Bolt") || ability.equals("Flame Burst") || ability.equals("Fallen Souls")) {
if (isInsideBubble.contains(event.getAttacker())) {
return currentDamageValue;
} else {
return currentDamageValue * .4f;
}
} else {
return currentDamageValue * .75f;
}
}
});
timeInBubble.compute(bubblePlayer, (k, v) -> v == null ? 1 : v + 1);
}
} else {
this.cancel();
Utils.playGlobalSound(wp.getLocation(), "paladin.holyradiance.activation", 2, 1.4f);
Utils.playGlobalSound(wp.getLocation(), Sound.AMBIENCE_THUNDER, 2, 1.5f);
for (Map.Entry<WarlordsPlayer, Integer> entry : timeInBubble.entrySet()) {
// 5% missing health * 4
float healingValue = 150 + (entry.getKey().getMaxHealth() - entry.getKey().getHealth()) * 0.05f;
int timeInSeconds = entry.getValue() * 4 / 20;
float totalHealing = (timeInSeconds * healingValue);
entry.getKey().addHealingInstance(wp, name, totalHealing, totalHealing, -1, 100, false, false);
}
CircleEffect circle = new CircleEffect(wp.getGame(), wp.getTeam(), wp.getLocation(), bubbleRadius);
circle.addEffect(new CircumferenceEffect(ParticleEffect.SPELL).particlesPerCircumference(2));
circle.playEffects();
}
}
}.runTaskTimer(5, 4);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class RecklessCharge method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
wp.subtractEnergy(energyCost);
Location location = player.getLocation();
location.setPitch(0);
Location chargeLocation = location.clone();
double chargeDistance;
List<WarlordsPlayer> playersHit = new ArrayList<>();
boolean inAir = false;
if (location.getWorld().getBlockAt(location.clone().add(0, -1, 0)).getType() != Material.AIR) {
inAir = true;
// travels 5 blocks
chargeDistance = 5;
} else {
// travels 7 at peak jump
chargeDistance = Math.max(Math.min(Utils.getDistance(player, .1) * 5, 6.9), 6);
}
if (wp.getCarriedFlag() != null) {
chargeDistance /= 4;
}
boolean finalInAir = inAir;
if (finalInAir) {
new GameRunnable(wp.getGame()) {
@Override
public void run() {
wp.setVelocity(location.getDirection().multiply(2).setY(.2));
}
}.runTaskLater(0);
} else {
player.setVelocity(location.getDirection().multiply(1.5).setY(.2));
}
Utils.playGlobalSound(player.getLocation(), "warrior.seismicwave.activation", 2, 1);
double finalChargeDistance = chargeDistance;
new GameRunnable(wp.getGame()) {
// safety precaution
int maxChargeDuration = 5;
@Override
public void run() {
// cancel charge if hit a block, making the player stand still
if (wp.getLocation().distanceSquared(chargeLocation) > finalChargeDistance * finalChargeDistance || (wp.getEntity().getVelocity().getX() == 0 && wp.getEntity().getVelocity().getZ() == 0) || maxChargeDuration <= 0) {
wp.setVelocity(new Vector(0, 0, 0));
this.cancel();
}
for (int i = 0; i < 4; i++) {
ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(255, 0, 0), wp.getLocation().clone().add((Math.random() * 1.5) - .75, .5 + (Math.random() * 2) - 1, (Math.random() * 1.5) - .75), 500);
}
PlayerFilter.entitiesAround(wp, 2.5, 5, 2.5).excluding(playersHit).aliveEnemiesOf(wp).forEach(enemy -> {
playersHit.add(enemy);
stunnedPlayers.add(enemy.getUuid());
enemy.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
stunnedPlayers.remove(enemy.getUuid());
}
}.runTaskLater(// .5 seconds
getStunTimeInTicks());
if (enemy.getEntity() instanceof Player) {
PacketUtils.sendTitle((Player) enemy.getEntity(), "", "§dIMMOBILIZED", 0, 10, 0);
}
});
maxChargeDuration--;
}
}.runTaskTimer(1, 0);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class SeismicWave method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
wp.subtractEnergy(energyCost);
List<List<Location>> fallingBlockLocations = new ArrayList<>();
List<CustomFallingBlock> customFallingBlocks = new ArrayList<>();
Location location = player.getLocation();
for (int i = 0; i < 8; i++) {
fallingBlockLocations.add(getWave(location, i));
}
Utils.playGlobalSound(player.getLocation(), "warrior.seismicwave.activation", 2, 1);
List<WarlordsPlayer> playersHit = new ArrayList<>();
for (List<Location> fallingBlockLocation : fallingBlockLocations) {
for (Location loc : fallingBlockLocation) {
for (WarlordsPlayer p : PlayerFilter.entitiesAroundRectangle(loc, .6, 4, .6).aliveEnemiesOf(wp).excluding(playersHit).closestFirst(wp)) {
playersHit.add(p);
final Vector v = player.getLocation().toVector().subtract(p.getLocation().toVector()).normalize().multiply(-velocity).setY(0.25);
p.setVelocity(v, false);
p.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
}
}
}
new GameRunnable(wp.getGame()) {
@Override
public void run() {
for (List<Location> fallingBlockLocation : fallingBlockLocations) {
for (Location location : fallingBlockLocation) {
if (location.getWorld().getBlockAt(location.clone().add(0, 1, 0)).getType() == Material.AIR) {
FallingBlock fallingBlock = addFallingBlock(location);
customFallingBlocks.add(new CustomFallingBlock(fallingBlock, wp, SeismicWave.this));
WarlordsEvents.addEntityUUID(fallingBlock);
}
}
fallingBlockLocations.remove(fallingBlockLocation);
break;
}
for (int i = 0; i < customFallingBlocks.size(); i++) {
CustomFallingBlock cfb = customFallingBlocks.get(i);
cfb.setTicksLived(cfb.getTicksLived() + 1);
if (Utils.getDistance(cfb.getFallingBlock().getLocation(), .05) <= .25 || cfb.getTicksLived() > 10) {
cfb.getFallingBlock().remove();
customFallingBlocks.remove(i);
i--;
}
}
if (fallingBlockLocations.isEmpty() && customFallingBlocks.isEmpty()) {
this.cancel();
}
}
}.runTaskTimer(0, 0);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class ShadowStep method onActivate.
@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
Location playerLoc = wp.getLocation();
if (wp.getCarriedFlag() != null) {
player.setVelocity(playerLoc.getDirection().multiply(1).setY(0.35));
player.setFallDistance(-5);
} else {
player.setVelocity(playerLoc.getDirection().multiply(1.5).setY(0.7));
player.setFallDistance(-10);
}
Utils.playGlobalSound(player.getLocation(), "rogue.drainingmiasma.activation", 1, 2);
Utils.playGlobalSound(playerLoc, Sound.AMBIENCE_THUNDER, 2, 2);
FireWorkEffectPlayer.playFirework(wp.getLocation(), FireworkEffect.builder().withColor(Color.BLACK).with(FireworkEffect.Type.BALL).build());
List<WarlordsPlayer> playersHit = new ArrayList<>();
for (WarlordsPlayer assaultTarget : PlayerFilter.entitiesAround(player, 5, 5, 5).aliveEnemiesOf(wp)) {
assaultTarget.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
Utils.playGlobalSound(playerLoc, "warrior.revenant.orbsoflife", 2, 1.9f);
playersHit.add(assaultTarget);
}
new GameRunnable(wp.getGame()) {
double y = playerLoc.getY();
boolean wasOnGround = true;
int counter = 0;
@Override
public void run() {
counter++;
if (counter == 300) {
this.cancel();
}
wp.getLocation(playerLoc);
boolean hitGround = player.isOnGround();
y = playerLoc.getY();
if (wasOnGround && !hitGround) {
wasOnGround = false;
}
if (!wasOnGround && hitGround) {
wasOnGround = true;
for (WarlordsPlayer landingTarget : PlayerFilter.entitiesAround(player, 5, 5, 5).aliveEnemiesOf(wp).excluding(playersHit)) {
landingTarget.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
Utils.playGlobalSound(playerLoc, "warrior.revenant.orbsoflife", 2, 1.9f);
}
FireWorkEffectPlayer.playFirework(wp.getLocation(), FireworkEffect.builder().withColor(Color.BLACK).with(FireworkEffect.Type.BALL).build());
this.cancel();
}
if (wp.isDead()) {
this.cancel();
}
}
}.runTaskTimer(0, 0);
return true;
}
Aggregations