Search in sources :

Example 1 with WarlordsPlayer

use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.

the class Berserk method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    Berserk tempBerserk = new Berserk();
    wp.subtractEnergy(energyCost);
    Runnable cancelSpeed = wp.getSpeed().addSpeedModifier(name, speedBuff, duration * 20, "BASE");
    wp.getCooldownManager().addCooldown(new RegularCooldown<Berserk>(name, "BERS", Berserk.class, tempBerserk, wp, CooldownTypes.ABILITY, cooldownManager -> {
    }, duration * 20) {

        @Override
        public float modifyDamageBeforeInterveneFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue) {
            return currentDamageValue * (1 + damageTakenIncrease / 100);
        }

        @Override
        public float modifyDamageBeforeInterveneFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue) {
            return currentDamageValue * (1 + damageIncrease / 100);
        }
    });
    Utils.playGlobalSound(player.getLocation(), "warrior.berserk.activation", 2, 1);
    new GameRunnable(wp.getGame()) {

        @Override
        public void run() {
            if (wp.getCooldownManager().hasCooldown(tempBerserk)) {
                Location location = wp.getLocation();
                location.add(0, 2.1, 0);
                ParticleEffect.VILLAGER_ANGRY.display(0, 0, 0, 0.1F, 1, location, 500);
            } else {
                cancelSpeed.run();
                this.cancel();
            }
        }
    }.runTaskTimer(0, 3);
    return true;
}
Also used : Utils(com.ebicep.warlords.util.warlords.Utils) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) Location(org.bukkit.Location) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) Player(org.bukkit.entity.Player) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) ParticleEffect(com.ebicep.warlords.effects.ParticleEffect) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) Location(org.bukkit.Location)

Example 2 with WarlordsPlayer

use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.

the class DrainingMiasma method onActivate.

@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
    wp.subtractEnergy(energyCost);
    Utils.playGlobalSound(player.getLocation(), "rogue.drainingmiasma.activation", 2, 1.7f);
    Utils.playGlobalSound(player.getLocation(), "shaman.earthlivingweapon.activation", 2, 0.65f);
    EffectUtils.playSphereAnimation(player, 6, ParticleEffect.SLIME, 1);
    FireWorkEffectPlayer.playFirework(wp.getLocation(), FireworkEffect.builder().withColor(Color.LIME).with(FireworkEffect.Type.BALL_LARGE).build());
    DrainingMiasma tempDrainingMiasma = new DrainingMiasma();
    for (WarlordsPlayer miasmaTarget : PlayerFilter.entitiesAround(wp, getEnemyHitRadius(), getEnemyHitRadius(), getEnemyHitRadius()).aliveEnemiesOf(wp)) {
        miasmaTarget.getCooldownManager().addRegularCooldown("Draining Miasma", "MIASMA", DrainingMiasma.class, tempDrainingMiasma, wp, CooldownTypes.DEBUFF, cooldownManager -> {
        }, duration * 20);
        miasmaTarget.getSpeed().addSpeedModifier("Draining Miasma Slow", -25, 3 * 20, "BASE");
        new GameRunnable(wp.getGame()) {

            float totalDamage = 0;

            @Override
            public void run() {
                float healthDamage = miasmaTarget.getMaxHealth() * maxHealthDamage / 100f;
                if (miasmaTarget.getCooldownManager().hasCooldown(tempDrainingMiasma)) {
                    // 4% current health damage.
                    miasmaTarget.addDamageInstance(wp, name, 50 + healthDamage, 50 + healthDamage, -1, 100, false);
                    totalDamage += healthDamage;
                    Utils.playGlobalSound(miasmaTarget.getLocation(), Sound.DIG_SNOW, 2, 0.4f);
                    for (int i = 0; i < 3; i++) {
                        ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(30, 200, 30), miasmaTarget.getLocation().clone().add((Math.random() * 2) - 1, 1.2 + (Math.random() * 2) - 1, (Math.random() * 2) - 1), 500);
                    }
                    for (WarlordsPlayer ally : PlayerFilter.entitiesAround(wp, getAllyHitRadius(), getAllyHitRadius(), getAllyHitRadius()).aliveTeammatesOf(wp)) {
                        ally.addHealingInstance(wp, name, totalDamage * damageDealtHealing / 100f, totalDamage * damageDealtHealing / 100f, -1, 100, false, false);
                        totalDamage = 0;
                        ally.getSpeed().addSpeedModifier("Draining Miasma Speed", 30, 2 * 20, "BASE");
                    }
                } else {
                    this.cancel();
                }
            }
        }.runTaskTimer(0, 20);
    }
    return true;
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable)

Example 3 with WarlordsPlayer

use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.

the class Fireball method onHit.

@Override
protected void onHit(@Nonnull WarlordsPlayer shooter, @Nonnull Location currentLocation, @Nonnull Location startingLocation, WarlordsPlayer victim) {
    ParticleEffect.EXPLOSION_LARGE.display(0, 0, 0, 0.5F, 1, currentLocation, 500);
    ParticleEffect.LAVA.display(0.5F, 0, 0.5F, 1.5f, 10, currentLocation, 500);
    ParticleEffect.CLOUD.display(0.3F, 0.3F, 0.3F, 1F, 3, currentLocation, 500);
    Utils.playGlobalSound(currentLocation, "mage.fireball.impact", 2, 1);
    double distanceSquared = startingLocation.distanceSquared(currentLocation);
    double toReduceBy = MAX_FULL_DAMAGE_DISTANCE * MAX_FULL_DAMAGE_DISTANCE > distanceSquared ? 1 : 1 - (Math.sqrt(distanceSquared) - MAX_FULL_DAMAGE_DISTANCE) / 75;
    if (toReduceBy < .2)
        toReduceBy = .2;
    if (victim != null) {
        victim.addDamageInstance(shooter, name, (float) (minDamageHeal * DIRECT_HIT_MULTIPLIER * toReduceBy), (float) (maxDamageHeal * DIRECT_HIT_MULTIPLIER * toReduceBy), critChance, critMultiplier, false);
    }
    for (WarlordsPlayer nearEntity : PlayerFilter.entitiesAround(currentLocation, HITBOX, HITBOX, HITBOX).excluding(victim).aliveEnemiesOf(shooter)) {
        nearEntity.addDamageInstance(shooter, name, (float) (minDamageHeal * toReduceBy), (float) (maxDamageHeal * toReduceBy), critChance, critMultiplier, false);
    }
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer)

Example 4 with WarlordsPlayer

use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.

the class GroundSlam method onActivate.

@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
    wp.subtractEnergy(energyCost);
    List<List<Location>> fallingBlockLocations = new ArrayList<>();
    List<CustomFallingBlock> customFallingBlocks = new ArrayList<>();
    List<WarlordsPlayer> playersHit = new ArrayList<>();
    Location location = player.getLocation();
    for (int i = 0; i < 6; i++) {
        fallingBlockLocations.add(getCircle(location, i, (i * ((int) (Math.PI * 2)))));
    }
    fallingBlockLocations.get(0).add(player.getLocation());
    Utils.playGlobalSound(player.getLocation(), "warrior.groundslam.activation", 2, 1);
    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.clone());
                        customFallingBlocks.add(new CustomFallingBlock(fallingBlock, wp, GroundSlam.this));
                        WarlordsEvents.addEntityUUID(fallingBlock);
                    }
                    // ParticleEffect.VILLAGER_HAPPY.display(0 , 0 ,0, 0, 10, location.getBlock().getLocation(), 1000);
                    // ParticleEffect.FLAME.display(0 , 0 ,0, 0, 10, location, 1000);
                    // DAMAGE
                    PlayerFilter.entitiesAroundRectangle(location.clone().add(0, -.75, 0), 0.75, 4.5, 0.75).enemiesOf(wp).forEach(enemy -> {
                        if (!playersHit.contains(enemy)) {
                            playersHit.add(enemy);
                            final Location loc = enemy.getLocation();
                            final Vector v = wp.getLocation().toVector().subtract(loc.toVector()).normalize().multiply(-1.25).setY(0.25);
                            enemy.setVelocity(v, false);
                            enemy.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
                        }
                    });
                }
                fallingBlockLocations.remove(fallingBlockLocation);
                break;
            }
            if (fallingBlockLocations.isEmpty()) {
                this.cancel();
            }
        }
    }.runTaskTimer(0, 2);
    new GameRunnable(wp.getGame()) {

        @Override
        public void run() {
            for (int i = 0; i < customFallingBlocks.size(); i++) {
                CustomFallingBlock customFallingBlock = customFallingBlocks.get(i);
                customFallingBlock.setTicksLived(customFallingBlock.getTicksLived() + 1);
                if (Utils.getDistance(customFallingBlock.getFallingBlock().getLocation(), .05) <= .25 || customFallingBlock.getTicksLived() > 10) {
                    customFallingBlock.getFallingBlock().remove();
                    customFallingBlocks.remove(i);
                    i--;
                }
            }
            if (fallingBlockLocations.isEmpty() && customFallingBlocks.isEmpty()) {
                this.cancel();
            }
        }
    }.runTaskTimer(0, 0);
    return true;
}
Also used : Utils(com.ebicep.warlords.util.warlords.Utils) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Player(org.bukkit.entity.Player) CustomFallingBlock(com.ebicep.customentities.CustomFallingBlock) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) ArrayList(java.util.ArrayList) Vector(org.bukkit.util.Vector) List(java.util.List) Location(org.bukkit.Location) World(org.bukkit.World) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) WarlordsEvents(com.ebicep.warlords.events.WarlordsEvents) FallingBlock(org.bukkit.entity.FallingBlock) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) Material(org.bukkit.Material) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) ArrayList(java.util.ArrayList) CustomFallingBlock(com.ebicep.customentities.CustomFallingBlock) FallingBlock(org.bukkit.entity.FallingBlock) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CustomFallingBlock(com.ebicep.customentities.CustomFallingBlock) ArrayList(java.util.ArrayList) List(java.util.List) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 5 with WarlordsPlayer

use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.

the class HammerOfLight 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().add(1, 0, 1).clone();
    ArmorStand hammer = spawnHammer(location, wp);
    wp.subtractEnergy(energyCost);
    wp.getSpec().getOrange().setCurrentCooldown((float) (cooldown * wp.getCooldownModifier()));
    HammerOfLight tempHammerOfLight = new HammerOfLight();
    wp.getCooldownManager().addRegularCooldown(name, "HAMMER", HammerOfLight.class, tempHammerOfLight, wp, CooldownTypes.ABILITY, cooldownManager -> {
    }, duration * 20);
    Utils.playGlobalSound(player.getLocation(), "paladin.hammeroflight.impact", 2, 0.85f);
    CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), location, radius, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new LineEffect(location.clone().add(0, 2.3, 0), ParticleEffect.SPELL));
    BukkitTask task = wp.getGame().registerGameTask(circleEffect::playEffects, 0, 1);
    location.add(0, 1, 0);
    final int[] timeLeftHammer = { duration };
    new GameRunnable(wp.getGame()) {

        int counter = 0;

        @Override
        public void run() {
            if (counter % 20 == 0) {
                timeLeftHammer[0]--;
                for (WarlordsPlayer warlordsPlayer : PlayerFilter.entitiesAround(location, radius, radius, radius).isAlive()) {
                    if (wp.isTeammateAlive(warlordsPlayer)) {
                        warlordsPlayer.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
                    } else {
                        warlordsPlayer.addDamageInstance(wp, name, 178, 244, critChance, critMultiplier, false);
                    }
                }
            }
            if (timeLeftHammer[0] <= 0) {
                hammer.remove();
                this.cancel();
                task.cancel();
            }
            counter++;
        }
    }.runTaskTimer(0, 0);
    new GameRunnable(wp.getGame()) {

        boolean wasSneaking = false;

        @Override
        public void run() {
            if (wp.isAlive() && wp.isSneaking() && !wasSneaking) {
                tempHammerOfLight.setCrownOfLight(true);
                new CooldownFilter<>(wp, RegularCooldown.class).filterCooldownObject(tempHammerOfLight).findAny().ifPresent(regularCooldown -> {
                    regularCooldown.setNameAbbreviation("CROWN");
                });
                Utils.playGlobalSound(wp.getLocation(), "warrior.revenant.orbsoflife", 2, 0.15f);
                Utils.playGlobalSound(wp.getLocation(), "mage.firebreath.activation", 2, 0.25f);
                BukkitTask particles = new GameRunnable(wp.getGame()) {

                    @Override
                    public void run() {
                        double angle = 0;
                        for (int i = 0; i < 9; i++) {
                            double x = .4 * Math.cos(angle);
                            double z = .4 * Math.sin(angle);
                            angle += 40;
                            Vector v = new Vector(x, 2, z);
                            Location loc = wp.getLocation().clone().add(v);
                            ParticleEffect.SPELL.display(0, 0, 0, 0f, 1, loc, 500);
                        }
                        CircleEffect circle = new CircleEffect(wp.getGame(), wp.getTeam(), wp.getLocation().add(0, 0.75f, 0), radius / 2f);
                        circle.addEffect(new CircumferenceEffect(ParticleEffect.SPELL).particlesPerCircumference(0.5f));
                        circle.playEffects();
                    }
                }.runTaskTimer(0, 6);
                new GameRunnable(wp.getGame()) {

                    int timeLeft = timeLeftHammer[0];

                    @Override
                    public void run() {
                        PlayerFilter.entitiesAround(wp.getLocation(), radius, radius, radius).aliveTeammatesOf(wp).forEach(teammate -> teammate.addHealingInstance(wp, "Crown of Light", minDamageHeal * 1.5f, maxDamageHeal * 1.5f, critChance, critMultiplier, false, false));
                        timeLeft--;
                        if (timeLeft <= 0 || wp.isDead()) {
                            this.cancel();
                            particles.cancel();
                        }
                    }
                }.runTaskTimer(2, 20);
                this.cancel();
                timeLeftHammer[0] = 0;
            }
            wasSneaking = wp.isSneaking();
            if (wp.isDead() || timeLeftHammer[0] <= 0) {
                this.cancel();
            }
        }
    }.runTaskTimer(0, 0);
    return true;
}
Also used : Utils(com.ebicep.warlords.util.warlords.Utils) Player(org.bukkit.entity.Player) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) ArrayList(java.util.ArrayList) Location(org.bukkit.Location) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) AbstractAbility(com.ebicep.warlords.classes.AbstractAbility) ParticleEffect(com.ebicep.warlords.effects.ParticleEffect) Material(org.bukkit.Material) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Entity(org.bukkit.entity.Entity) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) Set(java.util.Set) Warlords(com.ebicep.warlords.Warlords) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) LineEffect(com.ebicep.warlords.effects.circle.LineEffect) EntityType(org.bukkit.entity.EntityType) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector) List(java.util.List) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) EulerAngle(org.bukkit.util.EulerAngle) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) ArmorStand(org.bukkit.entity.ArmorStand) BukkitTask(org.bukkit.scheduler.BukkitTask) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) Protector(com.ebicep.warlords.classes.paladin.specs.Protector) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) Set(java.util.Set) LineEffect(com.ebicep.warlords.effects.circle.LineEffect) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) BukkitTask(org.bukkit.scheduler.BukkitTask) Material(org.bukkit.Material) CircumferenceEffect(com.ebicep.warlords.effects.circle.CircumferenceEffect) ArmorStand(org.bukkit.entity.ArmorStand) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CircleEffect(com.ebicep.warlords.effects.circle.CircleEffect) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Aggregations

WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)80 GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)43 Location (org.bukkit.Location)37 Player (org.bukkit.entity.Player)36 Utils (com.ebicep.warlords.util.warlords.Utils)26 RegularCooldown (com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown)21 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)21 AbstractAbility (com.ebicep.warlords.classes.AbstractAbility)20 ParticleEffect (com.ebicep.warlords.effects.ParticleEffect)20 CooldownTypes (com.ebicep.warlords.player.cooldowns.CooldownTypes)20 WarlordsDamageHealingEvent (com.ebicep.warlords.events.WarlordsDamageHealingEvent)17 ItemStack (org.bukkit.inventory.ItemStack)16 ChatColor (org.bukkit.ChatColor)15 Nonnull (javax.annotation.Nonnull)14 Warlords (com.ebicep.warlords.Warlords)13 Nullable (javax.annotation.Nullable)13 Material (org.bukkit.Material)13 Vector (org.bukkit.util.Vector)13 List (java.util.List)11 CircleEffect (com.ebicep.warlords.effects.circle.CircleEffect)10