Search in sources :

Example 1 with DoubleLineEffect

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;
}
Also used : Utils(com.ebicep.warlords.util.warlords.Utils) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Warlords(com.ebicep.warlords.Warlords) Player(org.bukkit.entity.Player) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) DoubleLineEffect(com.ebicep.warlords.effects.circle.DoubleLineEffect) Location(org.bukkit.Location) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) ArmorStand(org.bukkit.entity.ArmorStand) BukkitTask(org.bukkit.scheduler.BukkitTask) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) ParticleEffect(com.ebicep.warlords.effects.ParticleEffect) Bukkit(org.bukkit.Bukkit) DoubleLineEffect(com.ebicep.warlords.effects.circle.DoubleLineEffect) ArmorStand(org.bukkit.entity.ArmorStand) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) BukkitTask(org.bukkit.scheduler.BukkitTask) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Location(org.bukkit.Location)

Example 2 with DoubleLineEffect

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);
}
Also used : Utils(com.ebicep.warlords.util.warlords.Utils) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) AbstractTotemBase(com.ebicep.warlords.abilties.internal.AbstractTotemBase) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Warlords(com.ebicep.warlords.Warlords) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) Player(org.bukkit.entity.Player) AtomicReference(java.util.concurrent.atomic.AtomicReference) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) ItemStack(org.bukkit.inventory.ItemStack) DoubleLineEffect(com.ebicep.warlords.effects.circle.DoubleLineEffect) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) Location(org.bukkit.Location) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) ArmorStand(org.bukkit.entity.ArmorStand) BukkitTask(org.bukkit.scheduler.BukkitTask) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) ChatColor(org.bukkit.ChatColor) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) ParticleEffect(com.ebicep.warlords.effects.ParticleEffect) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) DoubleLineEffect(com.ebicep.warlords.effects.circle.DoubleLineEffect) BukkitTask(org.bukkit.scheduler.BukkitTask) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) AtomicReference(java.util.concurrent.atomic.AtomicReference) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

Warlords (com.ebicep.warlords.Warlords)2 ParticleEffect (com.ebicep.warlords.effects.ParticleEffect)2 CircleEffect (com.ebicep.warlords.effects.circle.CircleEffect)2 CircumferenceEffect (com.ebicep.warlords.effects.circle.CircumferenceEffect)2 DoubleLineEffect (com.ebicep.warlords.effects.circle.DoubleLineEffect)2 WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)2 GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)2 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)2 Utils (com.ebicep.warlords.util.warlords.Utils)2 Bukkit (org.bukkit.Bukkit)2 Location (org.bukkit.Location)2 ArmorStand (org.bukkit.entity.ArmorStand)2 Player (org.bukkit.entity.Player)2 BukkitTask (org.bukkit.scheduler.BukkitTask)2 AbstractTotemBase (com.ebicep.warlords.abilties.internal.AbstractTotemBase)1 AbstractAbility (com.ebicep.warlords.classes.AbstractAbility)1 WarlordsDamageHealingEvent (com.ebicep.warlords.events.WarlordsDamageHealingEvent)1 CooldownFilter (com.ebicep.warlords.player.cooldowns.CooldownFilter)1 CooldownTypes (com.ebicep.warlords.player.cooldowns.CooldownTypes)1 RegularCooldown (com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown)1