Search in sources :

Example 6 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class ZombieNecronomicon method spawnReinforcements.

private void spawnReinforcements(EliteEntity eliteEntity, LivingEntity targetted, ZombieNecronomicon zombieNecronomicon) {
    LivingEntity targetter = eliteEntity.getLivingEntity();
    new BukkitRunnable() {

        final ArrayList<Entity> entityList = new ArrayList<>();

        @Override
        public void run() {
            if (!eliteEntity.isValid() || !targetted.isValid() || !targetter.isValid() || targetted.getWorld() != targetter.getWorld() || targetted.getLocation().distance(targetter.getLocation()) > 30) {
                for (Entity entity : entityList) if (entity.isValid())
                    entity.remove();
                if (eliteEntity.isValid())
                    targetter.setAI(true);
                cancel();
                return;
            }
            int randomizedNumber = ThreadLocalRandom.current().nextInt(5) + 1;
            entityList.removeIf(currentEntity -> !currentEntity.isValid());
            if (entityList.size() < 11) {
                targetter.setAI(false);
                if (!zombieNecronomicon.isFiring())
                    necronomiconVisualEffect(eliteEntity, zombieNecronomicon);
                if (randomizedNumber < 5) {
                    CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity("necronomicon_zombie.yml");
                    if (customBossEntity == null) {
                        new WarningMessage("necronomicon_zombie.yml is not valid!");
                        return;
                    }
                    customBossEntity.spawn(targetter.getLocation(), eliteEntity.getLevel(), false);
                    if (!customBossEntity.getLivingEntity().isValid()) {
                        targetter.setAI(true);
                        cancel();
                        targetter.setAI(true);
                        cancel();
                        return;
                    }
                    customBossEntity.getLivingEntity().setVelocity(new Vector((ThreadLocalRandom.current().nextDouble() - 0.5) / 30, 0.5, (ThreadLocalRandom.current().nextDouble() - 0.5) / 30));
                    eliteEntity.addReinforcement(customBossEntity);
                    entityList.add(customBossEntity.getLivingEntity());
                } else {
                    CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity("necronomicon_skeleton.yml");
                    if (customBossEntity == null) {
                        new WarningMessage("necronomicon_skeleton.yml is not valid!");
                        targetter.setAI(true);
                        cancel();
                        return;
                    }
                    customBossEntity.spawn(targetter.getLocation(), eliteEntity.getLevel(), false);
                    if (!customBossEntity.getLivingEntity().isValid()) {
                        targetter.setAI(true);
                        cancel();
                        return;
                    }
                    customBossEntity.getLivingEntity().setVelocity(new Vector((ThreadLocalRandom.current().nextDouble() - 0.5) / 30, 0.5, (ThreadLocalRandom.current().nextDouble() - 0.5) / 30));
                    eliteEntity.addReinforcement(customBossEntity);
                    entityList.add(customBossEntity.getLivingEntity());
                }
            } else
                targetter.setAI(true);
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 20 * 3L, 20 * 3L);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) Item(org.bukkit.entity.Item) HashMap(java.util.HashMap) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) MobCombatSettingsConfig(com.magmaguy.elitemobs.config.MobCombatSettingsConfig) MajorPower(com.magmaguy.elitemobs.powers.meta.MajorPower) ArrayList(java.util.ArrayList) EventHandler(org.bukkit.event.EventHandler) Location(org.bukkit.Location) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) MetadataHandler(com.magmaguy.elitemobs.MetadataHandler) ChatColorConverter.convert(com.magmaguy.elitemobs.ChatColorConverter.convert) GenericRotationMatrixMath(com.magmaguy.elitemobs.powerstances.GenericRotationMatrixMath) EliteMobDamagedByPlayerEvent(com.magmaguy.elitemobs.api.EliteMobDamagedByPlayerEvent) Material(org.bukkit.Material) Listener(org.bukkit.event.Listener) Entity(org.bukkit.entity.Entity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) VisualItemInitializer(com.magmaguy.elitemobs.powerstances.VisualItemInitializer) EntityTracker(com.magmaguy.elitemobs.entitytracker.EntityTracker) LivingEntity(org.bukkit.entity.LivingEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector) List(java.util.List) PowersConfig(com.magmaguy.elitemobs.config.powers.PowersConfig) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) ArrayList(java.util.ArrayList) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) Vector(org.bukkit.util.Vector)

Example 7 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class Bombardment method activate.

public void activate(EliteEntity eliteEntity) {
    if (isActive)
        return;
    isActive = true;
    task = new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            counter++;
            if (stopCondition(eliteEntity))
                return;
            if (firing || isInCooldown(eliteEntity))
                return;
            if (ThreadLocalRandom.current().nextDouble() > 0.1)
                return;
            if (eliteEntity.getLivingEntity().getType().equals(EntityType.ENDER_DRAGON)) {
                EnderDragon.Phase phase = ((EnderDragon) eliteEntity.getLivingEntity()).getPhase();
                if (phase.equals(EnderDragon.Phase.DYING) || phase.equals(EnderDragon.Phase.HOVER) || phase.equals(EnderDragon.Phase.ROAR_BEFORE_ATTACK) || phase.equals(EnderDragon.Phase.FLY_TO_PORTAL) || phase.equals(EnderDragon.Phase.SEARCH_FOR_BREATH_ATTACK_TARGET)) {
                    return;
                }
            }
            for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(10, 100, 10)) {
                if (entity.getType().equals(EntityType.PLAYER)) {
                    firing = true;
                    fire(eliteEntity);
                    return;
                }
            }
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 5);
}
Also used : Entity(org.bukkit.entity.Entity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) EnderDragon(org.bukkit.entity.EnderDragon) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Example 8 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class CustomSummonPower method onCombatEnterSummonReinforcement.

private void onCombatEnterSummonReinforcement(EliteEntity spawningEntity) {
    for (CustomBossReinforcement customBossReinforcement : customBossReinforcements) {
        if (!customBossReinforcement.summonType.equals(SummonType.ON_COMBAT_ENTER))
            continue;
        if (customBossReinforcement.bossFileName != null) {
            summonReinforcement(spawningEntity, customBossReinforcement);
        } else {
            Location spawnLocation = getFinalSpawnLocation(spawningEntity, customBossReinforcement.spawnLocationOffset);
            Entity entity = spawnLocation.getWorld().spawnEntity(spawnLocation, customBossReinforcement.entityType);
            entity.getPersistentDataContainer().set(new NamespacedKey(MetadataHandler.PLUGIN, "eliteCrystal"), PersistentDataType.STRING, "eliteCrystal");
            entity.setPersistent(false);
            CrashFix.persistentTracker(entity);
            if (entity instanceof Mob && !spawningEntity.getDamagers().isEmpty()) {
                Player target = null;
                double damageDealt = 0;
                for (Player player : spawningEntity.getDamagers().keySet()) {
                    if (spawningEntity.getDamagers().get(player) < damageDealt)
                        continue;
                    target = player;
                    damageDealt = spawningEntity.getDamagers().get(player);
                }
                if (target != null)
                    ((Mob) entity).setTarget(target);
            }
            if (customBossReinforcement.isLightningRod)
                new EnderCrystalLightningRod(spawningEntity, (EnderCrystal) entity);
            customBossReinforcement.isSummoned = true;
            spawningEntity.addReinforcement(entity);
        }
    }
}
Also used : EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) RegionalBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity) NamespacedKey(org.bukkit.NamespacedKey) EnderCrystalLightningRod(com.magmaguy.elitemobs.powers.specialpowers.EnderCrystalLightningRod) Location(org.bukkit.Location)

Example 9 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class Thunderstorm method doThunderstorm.

public static void doThunderstorm(EliteEntity eliteEntity) {
    if (eliteEntity == null || !eliteEntity.getLivingEntity().isValid())
        return;
    eliteEntity.getLivingEntity().setAI(false);
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            counter++;
            if (counter > 20 * 5 || eliteEntity == null || !eliteEntity.getLivingEntity().isValid()) {
                cancel();
                eliteEntity.getLivingEntity().setAI(true);
                return;
            }
            if (counter % 2 == 0) {
                Location randomLocation = eliteEntity.getLivingEntity().getLocation().clone().add(new Vector(ThreadLocalRandom.current().nextInt(-20, 20), 0, ThreadLocalRandom.current().nextInt(-20, 20)));
                lightningTask(randomLocation);
            }
            if (counter % 20 == 0) {
                for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(20, 20, 20)) if (entity.getType().equals(EntityType.PLAYER))
                    lightningTask(entity.getLocation());
            }
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
Also used : Entity(org.bukkit.entity.Entity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 10 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class EnderDragonEmpoweredLightning method fireLightning.

public void fireLightning(EliteEntity eliteEntity) {
    doCooldown(eliteEntity);
    for (Entity entity : eliteEntity.getLivingEntity().getLocation().getWorld().getNearbyEntities(eliteEntity.getLivingEntity().getLocation(), 150, 150, 150)) if (entity.getType().equals(EntityType.PLAYER))
        lightningTask(entity.getLocation().clone());
    for (int i = 0; i < 50; i++) {
        Location randomLocation = locationRandomizer(eliteEntity.getLivingEntity().getLocation(), 0);
        if (randomLocation == null)
            continue;
        new BukkitRunnable() {

            @Override
            public void run() {
                lightningTask(randomLocation);
            }
        }.runTaskLater(MetadataHandler.PLUGIN, ThreadLocalRandom.current().nextInt(20 * 5));
    }
}
Also used : Entity(org.bukkit.entity.Entity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Location(org.bukkit.Location)

Aggregations

EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)29 Entity (org.bukkit.entity.Entity)16 LivingEntity (org.bukkit.entity.LivingEntity)12 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)10 EventHandler (org.bukkit.event.EventHandler)8 Vector (org.bukkit.util.Vector)8 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)7 Location (org.bukkit.Location)7 Player (org.bukkit.entity.Player)6 ArrayList (java.util.ArrayList)3 Block (org.bukkit.block.Block)3 RegionalBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)2 ElitePower (com.magmaguy.elitemobs.powers.meta.ElitePower)2 PotionEffect (org.bukkit.potion.PotionEffect)2 ChatColorConverter.convert (com.magmaguy.elitemobs.ChatColorConverter.convert)1 MetadataHandler (com.magmaguy.elitemobs.MetadataHandler)1 EliteExplosionEvent (com.magmaguy.elitemobs.api.EliteExplosionEvent)1 EliteMobDamagedByPlayerEvent (com.magmaguy.elitemobs.api.EliteMobDamagedByPlayerEvent)1 EliteMobExitCombatEvent (com.magmaguy.elitemobs.api.EliteMobExitCombatEvent)1 EliteProjectile (com.magmaguy.elitemobs.combatsystem.EliteProjectile)1