Search in sources :

Example 1 with AreaEffect

use of com.ebicep.warlords.effects.circle.AreaEffect in project Warlords by ebicep.

the class SoothingPuddle method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    wp.subtractEnergy(energyCost);
    Location location = player.getLocation();
    Vector speed = player.getLocation().getDirection().multiply(SPEED);
    ArmorStand stand = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);
    stand.setHelmet(new ItemStack(Material.STAINED_GLASS, 1, (short) 6));
    stand.setGravity(false);
    stand.setVisible(false);
    new GameRunnable(wp.getGame()) {

        int timer = 0;

        @Override
        public void run() {
            quarterStep(false);
            quarterStep(false);
            quarterStep(false);
            quarterStep(false);
            quarterStep(false);
            quarterStep(false);
            quarterStep(true);
        }

        private void quarterStep(boolean last) {
            if (!stand.isValid()) {
                this.cancel();
                return;
            }
            speed.add(new Vector(0, GRAVITY * SPEED, 0));
            Location newLoc = stand.getLocation();
            newLoc.add(speed);
            stand.teleport(newLoc);
            newLoc.add(0, 1.75, 0);
            stand.setHeadPose(new EulerAngle(-speed.getY() * 3, 0, 0));
            boolean shouldExplode;
            timer++;
            if (last) {
                Matrix4d center = new Matrix4d(newLoc);
                for (float i = 0; i < 6; i++) {
                    double angle = Math.toRadians(i * 90) + timer * 0.3;
                    double width = 0.4D;
                    ParticleEffect.VILLAGER_HAPPY.display(0, 0, 0, 0, 2, center.translateVector(newLoc.getWorld(), 0, Math.sin(angle) * width, Math.cos(angle) * width), 500);
                }
            }
            WarlordsPlayer directHit;
            if (!newLoc.getBlock().isEmpty() && newLoc.getBlock().getType() != Material.GRASS && newLoc.getBlock().getType() != Material.BARRIER && newLoc.getBlock().getType() != Material.VINE) {
                // Explode based on collision
                shouldExplode = true;
            } else {
                directHit = PlayerFilter.entitiesAroundRectangle(newLoc, 1, 2, 1).aliveTeammatesOfExcludingSelf(wp).findFirstOrNull();
                shouldExplode = directHit != null;
                newLoc.add(0, -1, 0);
            }
            newLoc.add(0, 1, 0);
            if (shouldExplode) {
                stand.remove();
                Utils.playGlobalSound(newLoc, "rogue.healingremedy.impact", 1.5f, 0.2f);
                Utils.playGlobalSound(newLoc, Sound.GLASS, 1.5f, 0.7f);
                Utils.playGlobalSound(newLoc, "mage.waterbolt.impact", 1.5f, 0.3f);
                FireWorkEffectPlayer.playFirework(newLoc, FireworkEffect.builder().withColor(Color.WHITE).with(FireworkEffect.Type.BURST).build());
                for (WarlordsPlayer nearEntity : PlayerFilter.entitiesAround(newLoc, HITBOX, HITBOX, HITBOX).aliveTeammatesOf(wp)) {
                    nearEntity.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
                }
                CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), newLoc, HITBOX, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new AreaEffect(1, ParticleEffect.DRIP_WATER).particlesPerSurface(0.025));
                BukkitTask task = Bukkit.getScheduler().runTaskTimer(Warlords.getInstance(), circleEffect::playEffects, 0, 1);
                wp.getGame().registerGameTask(task);
                new GameRunnable(wp.getGame()) {

                    int timeLeft = 4;

                    @Override
                    public void run() {
                        PlayerFilter.entitiesAround(newLoc, HITBOX, HITBOX, HITBOX).aliveTeammatesOf(wp).forEach((ally) -> ally.addHealingInstance(wp, name, puddleMinHealing, puddleMaxHealing, critChance, critMultiplier, false, false));
                        timeLeft--;
                        if (timeLeft < 0) {
                            this.cancel();
                            task.cancel();
                        }
                    }
                }.runTaskTimer(20, 20);
                this.cancel();
            }
        }
    }.runTaskTimer(0, 1);
    Utils.playGlobalSound(player.getLocation(), "mage.frostbolt.activation", 2, 0.7f);
    return true;
}
Also used : AreaEffect(com.ebicep.warlords.effects.circle.AreaEffect) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) BukkitTask(org.bukkit.scheduler.BukkitTask) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Matrix4d(com.ebicep.warlords.util.bukkit.Matrix4d) ArmorStand(org.bukkit.entity.ArmorStand) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) ItemStack(org.bukkit.inventory.ItemStack) EulerAngle(org.bukkit.util.EulerAngle) Vector(org.bukkit.util.Vector)

Example 2 with AreaEffect

use of com.ebicep.warlords.effects.circle.AreaEffect in project Warlords by ebicep.

the class HealingRain method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    if (player.getTargetBlock((Set<Material>) null, 25).getType() == Material.AIR)
        return false;
    Location location = player.getTargetBlock((Set<Material>) null, 25).getLocation().clone();
    wp.subtractEnergy(energyCost);
    wp.getCooldownManager().addRegularCooldown(name, "RAIN", HealingRain.class, new HealingRain(), wp, CooldownTypes.ABILITY, cooldownManager -> {
    }, duration * 20);
    wp.getSpec().getOrange().setCurrentCooldown((float) (cooldown * wp.getCooldownModifier()));
    Utils.playGlobalSound(location, "mage.healingrain.impact", 2, 1);
    CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), location, radius, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new AreaEffect(5, ParticleEffect.CLOUD).particlesPerSurface(0.025), new AreaEffect(5, ParticleEffect.DRIP_WATER).particlesPerSurface(0.025));
    BukkitTask task = wp.getGame().registerGameTask(circleEffect::playEffects, 0, 1);
    location.add(0, 1, 0);
    BukkitTask rainSneakAbility = new GameRunnable(wp.getGame()) {

        boolean wasSneaking = false;

        @Override
        public void run() {
            if (wp.isAlive() && wp.isSneaking() && !wasSneaking) {
                wp.playSound(wp.getLocation(), "mage.timewarp.teleport", 2, 1.35f);
                wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + " §7You moved your §aHealing Rain §7to your current location.");
                location.setX(wp.getLocation().getX());
                location.setY(wp.getLocation().getY());
                location.setZ(wp.getLocation().getZ());
            }
            wasSneaking = wp.isSneaking();
        }
    }.runTaskTimer(0, 0);
    new GameRunnable(wp.getGame()) {

        int counter = 0;

        int timeLeft = duration;

        @Override
        public void run() {
            if (counter % 10 == 0) {
                for (WarlordsPlayer teammateInRain : PlayerFilter.entitiesAround(location, radius, radius, radius).aliveTeammatesOf(wp)) {
                    teammateInRain.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
                    if (teammateInRain != wp) {
                        teammateInRain.getCooldownManager().removeCooldown(Overheal.OVERHEAL_MARKER);
                        teammateInRain.getCooldownManager().addRegularCooldown("Overheal", "OVERHEAL", Overheal.class, Overheal.OVERHEAL_MARKER, wp, CooldownTypes.BUFF, cooldownManager -> {
                        }, Overheal.OVERHEAL_DURATION * 20);
                    }
                }
                if (timeLeft < 0) {
                    this.cancel();
                    task.cancel();
                    rainSneakAbility.cancel();
                }
            }
            if (counter % 20 == 0) {
                timeLeft--;
            }
            counter--;
        }
    }.runTaskTimer(0, 0);
    return true;
}
Also used : Overheal(com.ebicep.warlords.abilties.internal.Overheal) Utils(com.ebicep.warlords.util.warlords.Utils) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Set(java.util.Set) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) Player(org.bukkit.entity.Player) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) Location(org.bukkit.Location) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) BukkitTask(org.bukkit.scheduler.BukkitTask) AreaEffect(com.ebicep.warlords.effects.circle.AreaEffect) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) ParticleEffect(com.ebicep.warlords.effects.ParticleEffect) Material(org.bukkit.Material) AreaEffect(com.ebicep.warlords.effects.circle.AreaEffect) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) BukkitTask(org.bukkit.scheduler.BukkitTask) Material(org.bukkit.Material) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Overheal(com.ebicep.warlords.abilties.internal.Overheal) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) Location(org.bukkit.Location)

Aggregations

AreaEffect (com.ebicep.warlords.effects.circle.AreaEffect)2 CircleEffect (com.ebicep.warlords.effects.circle.CircleEffect)2 CircumferenceEffect (com.ebicep.warlords.effects.circle.CircumferenceEffect)2 WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)2 GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)2 BukkitTask (org.bukkit.scheduler.BukkitTask)2 Overheal (com.ebicep.warlords.abilties.internal.Overheal)1 AbstractAbility (com.ebicep.warlords.classes.AbstractAbility)1 ParticleEffect (com.ebicep.warlords.effects.ParticleEffect)1 CooldownTypes (com.ebicep.warlords.player.cooldowns.CooldownTypes)1 Matrix4d (com.ebicep.warlords.util.bukkit.Matrix4d)1 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)1 Utils (com.ebicep.warlords.util.warlords.Utils)1 Set (java.util.Set)1 Location (org.bukkit.Location)1 Material (org.bukkit.Material)1 ArmorStand (org.bukkit.entity.ArmorStand)1 Player (org.bukkit.entity.Player)1 ItemStack (org.bukkit.inventory.ItemStack)1 EulerAngle (org.bukkit.util.EulerAngle)1