Search in sources :

Example 1 with Matrix4d

use of com.ebicep.warlords.util.bukkit.Matrix4d in project Warlords by ebicep.

the class HeartToHeart method onActivate.

@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
    if (wp.getCarriedFlag() != null) {
        radius = 7;
        verticalRadius = 3;
    } else {
        radius = 15;
        verticalRadius = 15;
    }
    for (WarlordsPlayer heartTarget : PlayerFilter.entitiesAround(wp, radius, verticalRadius, radius).aliveTeammatesOfExcludingSelf(wp).requireLineOfSight(wp).lookingAtFirst(wp).limit(1)) {
        Utils.playGlobalSound(player.getLocation(), "rogue.hearttoheart.activation", 2, 1);
        Utils.playGlobalSound(player.getLocation(), "rogue.hearttoheart.activation.alt", 2, 1.2f);
        HeartToHeart tempHeartToHeart = new HeartToHeart();
        wp.subtractEnergy(energyCost);
        // remove other instances of vindicate buff to override
        heartTarget.getCooldownManager().removeCooldownByName("Vindicate Debuff Immunity");
        heartTarget.getCooldownManager().addRegularCooldown("Vindicate Debuff Immunity", "VIND", HeartToHeart.class, tempHeartToHeart, wp, CooldownTypes.BUFF, cooldownManager -> {
        }, vindDuration * 20);
        wp.getCooldownManager().removeCooldownByName("Vindicate Debuff Immunity");
        wp.getCooldownManager().addRegularCooldown("Vindicate Debuff Immunity", "VIND", HeartToHeart.class, tempHeartToHeart, wp, CooldownTypes.BUFF, cooldownManager -> {
        }, vindDuration * 20);
        new BukkitRunnable() {

            final Location playerLoc = wp.getLocation();

            int timer = 0;

            @Override
            public void run() {
                timer++;
                if (timer >= 8 || (heartTarget.isDead() || wp.isDead())) {
                    this.cancel();
                }
                double target = timer / 8D;
                Location targetLoc = heartTarget.getLocation();
                Location newLocation = new Location(playerLoc.getWorld(), Utils.lerp(playerLoc.getX(), targetLoc.getX(), target), Utils.lerp(playerLoc.getY(), targetLoc.getY(), target), Utils.lerp(playerLoc.getZ(), targetLoc.getZ(), target), targetLoc.getYaw(), targetLoc.getPitch());
                EffectUtils.playChainAnimation(wp, heartTarget, new ItemStack(Material.LEAVES, 1, (short) 1), timer);
                wp.teleportLocationOnly(newLocation);
                player.setFallDistance(-5);
                newLocation.add(0, 1, 0);
                Matrix4d center = new Matrix4d(newLocation);
                for (float i = 0; i < 6; i++) {
                    double angle = Math.toRadians(i * 90) + timer * 0.6;
                    double width = 1.5D;
                    ParticleEffect.SPELL_WITCH.display(0, 0, 0, 0, 1, center.translateVector(playerLoc.getWorld(), 0, Math.sin(angle) * width, Math.cos(angle) * width), 500);
                }
                if (timer >= 8) {
                    wp.setVelocity(playerLoc.getDirection().multiply(0.4).setY(0.2));
                    wp.addHealingInstance(wp, name, 400, 400, -1, 100, false, false);
                }
            }
        }.runTaskTimer(Warlords.getInstance(), 0, 1);
        return true;
    }
    return false;
}
Also used : Matrix4d(com.ebicep.warlords.util.bukkit.Matrix4d) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ItemStack(org.bukkit.inventory.ItemStack) Location(org.bukkit.Location)

Example 2 with Matrix4d

use of com.ebicep.warlords.util.bukkit.Matrix4d in project Warlords by ebicep.

the class SniperShot method playEffect.

@Override
protected void playEffect(@Nonnull Location currentLocation, int ticksLived) {
    Matrix4d center = new Matrix4d(currentLocation);
    for (float i = 0; i < 4; i++) {
        double angle = Math.toRadians(i * 90) + ticksLived * 0.45;
        double width = 0.12D;
        ParticleEffect.FLAME.display(0, 0, 0, 0, 2, center.translateVector(currentLocation.getWorld(), 0, Math.sin(angle) * width, Math.cos(angle) * width), 500);
    }
}
Also used : Matrix4d(com.ebicep.warlords.util.bukkit.Matrix4d)

Example 3 with Matrix4d

use of com.ebicep.warlords.util.bukkit.Matrix4d 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 4 with Matrix4d

use of com.ebicep.warlords.util.bukkit.Matrix4d in project Warlords by ebicep.

the class UndyingArmy method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    wp.subtractEnergy(energyCost);
    UndyingArmy tempUndyingArmy = new UndyingArmy();
    int numberOfPlayersWithArmy = 0;
    for (WarlordsPlayer teammate : PlayerFilter.entitiesAround(wp, radius, radius, radius).aliveTeammatesOf(wp).closestFirst(wp)) {
        tempUndyingArmy.getPlayersPopped().put(teammate, false);
        if (teammate != wp) {
            wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " Your " + ChatColor.YELLOW + "Undying Army" + ChatColor.GRAY + " is now protecting " + teammate.getName() + ChatColor.GRAY + ".");
            teammate.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " " + ChatColor.GRAY + wp.getName() + "'s " + ChatColor.YELLOW + "Undying Army" + ChatColor.GRAY + " is now protecting you for " + ChatColor.GOLD + duration + ChatColor.GRAY + " seconds.");
        }
        teammate.getCooldownManager().addRegularCooldown(name, "ARMY", UndyingArmy.class, tempUndyingArmy, wp, CooldownTypes.ABILITY, cooldownManager -> {
        }, duration * 20);
        new GameRunnable(wp.getGame()) {

            @Override
            public void run() {
                Optional<UndyingArmy> optionalUndyingArmy = new CooldownFilter<>(teammate, RegularCooldown.class).findFirstObject(tempUndyingArmy, UndyingArmy.class);
                if (optionalUndyingArmy.isPresent()) {
                    if (!(optionalUndyingArmy.get()).isArmyDead(teammate)) {
                        float healAmount = 100 + (teammate.getMaxHealth() - teammate.getHealth()) * 0.035f;
                        teammate.addHealingInstance(wp, name, healAmount, healAmount, -1, 100, false, false);
                        teammate.playSound(teammate.getLocation(), "paladin.holyradiance.activation", 0.1f, 0.7f);
                        // particles
                        Location playerLoc = teammate.getLocation();
                        playerLoc.add(0, 2.1, 0);
                        Location particleLoc = playerLoc.clone();
                        for (int i = 0; i < 1; i++) {
                            for (int j = 0; j < 10; j++) {
                                double angle = j / 10D * Math.PI * 2;
                                double width = 0.5;
                                particleLoc.setX(playerLoc.getX() + Math.sin(angle) * width);
                                particleLoc.setY(playerLoc.getY() + i / 5D);
                                particleLoc.setZ(playerLoc.getZ() + Math.cos(angle) * width);
                                ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(255, 255, 255), particleLoc, 500);
                            }
                        }
                    } else {
                        this.cancel();
                    }
                } else {
                    this.cancel();
                }
            }
        }.runTaskTimer(0, 20);
        numberOfPlayersWithArmy++;
        if (numberOfPlayersWithArmy >= maxArmyAllies) {
            break;
        }
    }
    Utils.playGlobalSound(player.getLocation(), Sound.ZOMBIE_IDLE, 2, 0.3f);
    Utils.playGlobalSound(player.getLocation(), Sound.AMBIENCE_THUNDER, 2, 0.9f);
    // particles
    Location loc = player.getEyeLocation();
    loc.setPitch(0);
    loc.setYaw(0);
    Matrix4d matrix = new Matrix4d();
    for (int i = 0; i < 9; i++) {
        loc.setYaw(loc.getYaw() + 360F / 9F);
        matrix.updateFromLocation(loc);
        for (int c = 0; c < 30; c++) {
            double angle = c / 30D * Math.PI * 2;
            double width = 1.5;
            ParticleEffect.ENCHANTMENT_TABLE.display(0, 0.1f, 0, 0, 1, matrix.translateVector(player.getWorld(), radius, Math.sin(angle) * width, Math.cos(angle) * width), 500);
        }
        for (int c = 0; c < 15; c++) {
            double angle = c / 15D * Math.PI * 2;
            double width = 0.6;
            ParticleEffect.SPELL.display(0, 0, 0, 0, 1, matrix.translateVector(player.getWorld(), radius, Math.sin(angle) * width, Math.cos(angle) * width), 500);
        }
    }
    CircleEffect circle = new CircleEffect(wp.getGame(), wp.getTeam(), player.getLocation(), radius);
    circle.addEffect(new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE).particlesPerCircumference(2));
    circle.playEffects();
    return true;
}
Also used : CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) Optional(java.util.Optional) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Matrix4d(com.ebicep.warlords.util.bukkit.Matrix4d) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) Location(org.bukkit.Location)

Example 5 with Matrix4d

use of com.ebicep.warlords.util.bukkit.Matrix4d in project Warlords by ebicep.

the class WaterBreath method onActivate.

@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
    wp.subtractEnergy(energyCost);
    wp.getCooldownManager().removeDebuffCooldowns();
    wp.getSpeed().removeSlownessModifiers();
    wp.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
    Location playerLoc = player.getLocation();
    playerLoc.setPitch(0);
    playerLoc.add(0, 1.7, 0);
    Vector viewDirection = playerLoc.getDirection();
    Location hitbox = player.getLocation();
    hitbox.setPitch(0);
    hitbox.add(hitbox.getDirection().multiply(-1));
    PlayerFilter.entitiesAroundRectangle(playerLoc, 7.5, 10, 7.5).excluding(wp).forEach(target -> {
        Vector direction = target.getLocation().subtract(hitbox).toVector().normalize();
        if (viewDirection.dot(direction) > .68) {
            if (wp.isTeammateAlive(target)) {
                target.getCooldownManager().removeDebuffCooldowns();
                target.getSpeed().removeSlownessModifiers();
                target.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
                target.getCooldownManager().removeCooldown(Overheal.OVERHEAL_MARKER);
                target.getCooldownManager().addRegularCooldown("Overheal", "OVERHEAL", Overheal.class, Overheal.OVERHEAL_MARKER, wp, CooldownTypes.BUFF, cooldownManager -> {
                }, Overheal.OVERHEAL_DURATION * 20);
            } else {
                final Location loc = target.getLocation();
                final Vector v = player.getLocation().toVector().subtract(loc.toVector()).normalize().multiply(-1.1).setY(0.2);
                target.setVelocity(v);
            }
        }
    });
    Utils.playGlobalSound(player.getLocation(), "mage.waterbreath.activation", 2, 1);
    ParticleEffect.HEART.display(0.6f, 0.6f, 0.6f, 1, 2, player.getLocation().add(0, 0.7, 0), 500);
    new GameRunnable(wp.getGame()) {

        @Override
        public void run() {
            this.playEffect();
            this.playEffect();
        }

        int animationTimer = 0;

        final Matrix4d center = new Matrix4d(playerLoc);

        public void playEffect() {
            if (animationTimer > 12) {
                this.cancel();
            }
            for (int i = 0; i < 4; i++) {
                double angle = Math.toRadians(i * 90) + animationTimer * 0.15;
                double width = animationTimer * 0.3;
                ParticleEffect.DRIP_WATER.display(0, 0, 0, 0, 1, center.translateVector(wp.getWorld(), animationTimer / 2D, Math.sin(angle) * width, Math.cos(angle) * width), 500);
                ParticleEffect.ENCHANTMENT_TABLE.display(0, 0, 0, 0, 1, center.translateVector(wp.getWorld(), animationTimer / 2D, Math.sin(angle) * width, Math.cos(angle) * width), 500);
                ParticleEffect.VILLAGER_HAPPY.display(0, 0, 0, 0, 1, center.translateVector(wp.getWorld(), animationTimer / 2D, Math.sin(angle) * width, Math.cos(angle) * width), 500);
            }
            animationTimer++;
        }
    }.runTaskTimer(0, 1);
    return true;
}
Also used : Matrix4d(com.ebicep.warlords.util.bukkit.Matrix4d) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Aggregations

Matrix4d (com.ebicep.warlords.util.bukkit.Matrix4d)8 Location (org.bukkit.Location)5 WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)4 GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)4 Vector (org.bukkit.util.Vector)3 CircleEffect (com.ebicep.warlords.effects.circle.CircleEffect)2 CircumferenceEffect (com.ebicep.warlords.effects.circle.CircumferenceEffect)2 ItemStack (org.bukkit.inventory.ItemStack)2 AbstractAbility (com.ebicep.warlords.classes.AbstractAbility)1 EffectUtils (com.ebicep.warlords.effects.EffectUtils)1 ParticleEffect (com.ebicep.warlords.effects.ParticleEffect)1 AreaEffect (com.ebicep.warlords.effects.circle.AreaEffect)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 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)1 Utils (com.ebicep.warlords.util.warlords.Utils)1 Optional (java.util.Optional)1 ChatColor (org.bukkit.ChatColor)1