use of com.ebicep.warlords.effects.circle.DoubleLineEffect in project Warlords by ebicep.
the class Consecrate method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
wp.subtractEnergy(energyCost);
Utils.playGlobalSound(player.getLocation(), "paladin.consecrate.activation", 2, 1);
Location location = player.getLocation().clone();
ArmorStand consecrate = player.getLocation().getWorld().spawn(player.getLocation().clone().add(0, -2, 0), ArmorStand.class);
consecrate.setMetadata("Consecrate - " + player.getName(), new FixedMetadataValue(Warlords.getInstance(), true));
consecrate.setGravity(false);
consecrate.setVisible(false);
consecrate.setMarker(true);
CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), location, radius, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new DoubleLineEffect(ParticleEffect.SPELL));
BukkitTask task = Bukkit.getScheduler().runTaskTimer(Warlords.getInstance(), circleEffect::playEffects, 0, 1);
new GameRunnable(wp.getGame()) {
int timeLeft = 5;
@Override
public void run() {
timeLeft--;
PlayerFilter.entitiesAround(location, radius, 6, radius).aliveEnemiesOf(wp).forEach(warlordsPlayer -> {
warlordsPlayer.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
});
if (timeLeft == 0) {
consecrate.remove();
this.cancel();
task.cancel();
}
}
}.runTaskTimer(0, 20);
return true;
}
use of com.ebicep.warlords.effects.circle.DoubleLineEffect in project Warlords by ebicep.
the class DeathsDebt method onActivation.
@Override
protected void onActivation(WarlordsPlayer wp, Player player, ArmorStand totemStand) {
final int ticksLeft = (4 + (2 * (int) Math.round((double) wp.getHealth() / wp.getMaxHealth()))) * 20;
DeathsDebt tempDeathsDebt = new DeathsDebt();
CircleEffect circle = new CircleEffect(wp, totemStand.getLocation().clone().add(0, 1.25, 0), respiteRadius);
circle.addEffect(new CircumferenceEffect(ParticleEffect.SPELL));
circle.addEffect(new DoubleLineEffect(ParticleEffect.REDSTONE));
BukkitTask particles = Bukkit.getScheduler().runTaskTimer(Warlords.getInstance(), circle::playEffects, 0, 1);
AtomicReference<RegularCooldown<DeathsDebt>> deathsDebtCooldown = new AtomicReference<>();
RegularCooldown<DeathsDebt> spiritRespiteCooldown = new RegularCooldown<DeathsDebt>("Spirits Respite", "RESP", DeathsDebt.class, tempDeathsDebt, wp, CooldownTypes.ABILITY, cooldownManagerRespite -> {
tempDeathsDebt.setInDebt(true);
// beginning debt
deathsDebtCooldown.set(new RegularCooldown<>(name, "DEBT", DeathsDebt.class, tempDeathsDebt, wp, CooldownTypes.ABILITY, cooldownManagerDebt -> {
// final damage tick
wp.getWorld().spigot().strikeLightningEffect(totemStand.getLocation(), false);
// Enemy damage
PlayerFilter.entitiesAround(totemStand, debtRadius, debtRadius - 1, debtRadius).aliveEnemiesOf(wp).forEach((nearPlayer) -> {
nearPlayer.addDamageInstance(wp, name, tempDeathsDebt.getDelayedDamage() * .15f, tempDeathsDebt.getDelayedDamage() * .15f, critChance, critMultiplier, false);
});
// 6 damage waves, stop the function
totemStand.remove();
particles.cancel();
}, 6 * 20));
wp.getCooldownManager().addCooldown(deathsDebtCooldown.get());
if (!tempDeathsDebt.playerInRadius) {
wp.sendMessage("§7You walked outside your §dDeath's Debt §7radius");
} else {
wp.sendMessage("§c\u00AB §2Spirit's Respite §7delayed §c" + Math.round(tempDeathsDebt.getDelayedDamage()) + " §7damage. §dYour debt must now be paid.");
}
circle.replaceEffects(e -> e instanceof DoubleLineEffect, new DoubleLineEffect(ParticleEffect.SPELL_WITCH));
circle.setRadius(debtRadius);
// blue to purple totem
totemStand.setHelmet(new ItemStack(Material.DARK_OAK_FENCE_GATE));
}, ticksLeft) {
@Override
public void onDamageFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue, boolean isCrit) {
tempDeathsDebt.addDelayedDamage(currentDamageValue);
}
};
wp.getCooldownManager().addCooldown(spiritRespiteCooldown);
new GameRunnable(wp.getGame()) {
int counter = 0;
@Override
public void run() {
if (wp.isDead()) {
totemStand.remove();
particles.cancel();
this.cancel();
} else {
if (wp.getWorld() != totemStand.getWorld()) {
totemStand.remove();
particles.cancel();
this.cancel();
return;
}
boolean isPlayerInRadius = wp.getLocation().distanceSquared(totemStand.getLocation()) < respiteRadius * respiteRadius;
if (!isPlayerInRadius && wp.getCooldownManager().hasCooldown(tempDeathsDebt) && !tempDeathsDebt.isInDebt()) {
tempDeathsDebt.setInDebt(true);
tempDeathsDebt.setPlayerInRadius(false);
spiritRespiteCooldown.setTicksLeft(0);
}
// every second
if (counter % 20 == 0) {
if (!tempDeathsDebt.isInDebt()) {
// respite
Utils.playGlobalSound(totemStand.getLocation(), "shaman.earthlivingweapon.impact", 2, 1.5F);
wp.sendMessage(ChatColor.GREEN + "\u00BB §2Spirit's Respite §7delayed §c" + Math.round(tempDeathsDebt.getDelayedDamage()) + " §7damage. §6" + Math.round(spiritRespiteCooldown.getTicksLeft() / 20f) + " §7seconds left.");
} else {
// during debt
onDebtTick(wp, totemStand, tempDeathsDebt);
}
}
counter++;
if (deathsDebtCooldown.get() == null) {
return;
}
if (!wp.getCooldownManager().hasCooldown(deathsDebtCooldown.get())) {
totemStand.remove();
particles.cancel();
this.cancel();
}
}
}
}.runTaskTimer(2, 0);
}
Aggregations