Search in sources :

Example 1 with WildernessBossDetail

use of com.skelril.skree.content.world.wilderness.WildernessBossDetail in project Skree by Skelril.

the class Fangz method setupFangz.

private void setupFangz() {
    Sponge.getEventManager().registerListeners(SkreePlugin.inst(), new BossListener<>(bossManager, Spider.class));
    List<Instruction<BindCondition, Boss<Spider, WildernessBossDetail>>> bindProcessor = bossManager.getBindProcessor();
    bindProcessor.add((condition, boss) -> {
        Optional<Spider> optBossEnt = boss.getTargetEntity();
        if (optBossEnt.isPresent()) {
            Spider bossEnt = optBossEnt.get();
            bossEnt.offer(Keys.DISPLAY_NAME, Text.of("Fangz"));
            bossEnt.offer(Keys.CUSTOM_NAME_VISIBLE, true);
            double bossHealth = 20 * 50 * boss.getDetail().getLevel();
            setMaxHealth(bossEnt, bossHealth, true);
        }
        return Optional.empty();
    });
    List<Instruction<UnbindCondition, Boss<Spider, WildernessBossDetail>>> unbindProcessor = bossManager.getUnbindProcessor();
    unbindProcessor.add((condition, boss) -> {
        Optional<Spider> optBossEnt = boss.getTargetEntity();
        if (optBossEnt.isPresent()) {
            Spider bossEnt = optBossEnt.get();
            CuboidContainmentPredicate predicate = new CuboidContainmentPredicate(bossEnt.getLocation().getPosition(), 3, 2, 3);
            for (Entity aEntity : bossEnt.getNearbyEntities((entity) -> predicate.test(entity.getLocation().getPosition()))) {
                Optional<PotionEffectData> optPotionEffects = aEntity.getOrCreate(PotionEffectData.class);
                if (!optPotionEffects.isPresent()) {
                    continue;
                }
                PotionEffectData potionEffects = optPotionEffects.get();
                potionEffects.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 2, 20 * 30));
                potionEffects.addElement(PotionEffect.of(PotionEffectTypes.POISON, 2, 20 * 30));
                aEntity.offer(potionEffects);
            }
        }
        return Optional.empty();
    });
    List<Instruction<DamageCondition, Boss<Spider, WildernessBossDetail>>> damageProcessor = bossManager.getDamageProcessor();
    damageProcessor.add((condition, boss) -> {
        Optional<Spider> optBossEnt = boss.getTargetEntity();
        if (optBossEnt.isPresent()) {
            Spider bossEnt = optBossEnt.get();
            Entity eToHit = condition.getAttacked();
            if (!(eToHit instanceof Living)) {
                return Optional.empty();
            }
            Living toHit = (Living) eToHit;
            DamageEntityEvent event = condition.getEvent();
            event.setBaseDamage(event.getBaseDamage() * 2);
            EntityHealthUtil.heal(bossEnt, event.getBaseDamage());
            Optional<PotionEffectData> optPotionEffects = toHit.getOrCreate(PotionEffectData.class);
            if (!optPotionEffects.isPresent()) {
                return Optional.empty();
            }
            PotionEffectData potionEffects = optPotionEffects.get();
            potionEffects.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 1, 20 * 15));
            potionEffects.addElement(PotionEffect.of(PotionEffectTypes.POISON, 1, 20 * 15));
            toHit.offer(potionEffects);
        }
        return Optional.empty();
    });
}
Also used : CuboidContainmentPredicate(com.skelril.nitro.position.CuboidContainmentPredicate) DamageEntityEvent(org.spongepowered.api.event.entity.DamageEntityEvent) Entity(org.spongepowered.api.entity.Entity) WildernessBossDetail(com.skelril.skree.content.world.wilderness.WildernessBossDetail) Living(org.spongepowered.api.entity.living.Living) Instruction(com.skelril.openboss.Instruction) Spider(org.spongepowered.api.entity.living.monster.Spider) PotionEffectData(org.spongepowered.api.data.manipulator.mutable.PotionEffectData)

Example 2 with WildernessBossDetail

use of com.skelril.skree.content.world.wilderness.WildernessBossDetail in project Skree by Skelril.

the class GraveDigger method setupGraveDigger.

private void setupGraveDigger() {
    Sponge.getEventManager().registerListeners(SkreePlugin.inst(), new BossListener<>(bossManager, Skeleton.class));
    List<Instruction<BindCondition, Boss<Skeleton, WildernessBossDetail>>> bindProcessor = bossManager.getBindProcessor();
    bindProcessor.add((condition, boss) -> {
        Optional<Skeleton> optBossEnt = boss.getTargetEntity();
        if (optBossEnt.isPresent()) {
            Skeleton bossEnt = optBossEnt.get();
            bossEnt.offer(Keys.DISPLAY_NAME, Text.of("Grave Digger"));
            bossEnt.offer(Keys.CUSTOM_NAME_VISIBLE, true);
            double bossHealth = 20 * 43 * boss.getDetail().getLevel();
            setMaxHealth(bossEnt, bossHealth, true);
        }
        return Optional.empty();
    });
    List<Instruction<DamageCondition, Boss<Skeleton, WildernessBossDetail>>> damageProcessor = bossManager.getDamageProcessor();
    damageProcessor.add((condition, boss) -> {
        Entity eToHit = condition.getAttacked();
        if (!(eToHit instanceof Living)) {
            return Optional.empty();
        }
        Living toHit = (Living) eToHit;
        Location<World> targetLocation = toHit.getLocation();
        makeExplosiveTomb(targetLocation, boss);
        return Optional.empty();
    });
    List<Instruction<DamagedCondition, Boss<Skeleton, WildernessBossDetail>>> damagedProcessor = bossManager.getDamagedProcessor();
    damagedProcessor.add((condition, boss) -> {
        Optional<DamageSource> optDamageSource = condition.getDamageSource();
        if (optDamageSource.isPresent()) {
            DamageSource damageSource = optDamageSource.get();
            // Explosions are show up as custom instead of Explosion
            if (damageSource.getType() == DamageTypes.CUSTOM) {
                condition.getEvent().setCancelled(true);
            }
            if (!(damageSource instanceof IndirectEntityDamageSource)) {
                return Optional.empty();
            }
            Entity source = ((IndirectEntityDamageSource) damageSource).getIndirectSource();
            Location<World> targetLocation = source.getLocation();
            makeExplosiveTomb(targetLocation, boss);
        }
        return Optional.empty();
    });
}
Also used : Entity(org.spongepowered.api.entity.Entity) WildernessBossDetail(com.skelril.skree.content.world.wilderness.WildernessBossDetail) DamageSource(org.spongepowered.api.event.cause.entity.damage.source.DamageSource) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource) Living(org.spongepowered.api.entity.living.Living) Instruction(com.skelril.openboss.Instruction) World(org.spongepowered.api.world.World) Skeleton(org.spongepowered.api.entity.living.monster.Skeleton) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource)

Example 3 with WildernessBossDetail

use of com.skelril.skree.content.world.wilderness.WildernessBossDetail in project Skree by Skelril.

the class StormBringer method setupStormBringer.

private void setupStormBringer() {
    Sponge.getEventManager().registerListeners(SkreePlugin.inst(), new BossListener<>(bossManager, Skeleton.class));
    List<Instruction<BindCondition, Boss<Skeleton, WildernessBossDetail>>> bindProcessor = bossManager.getBindProcessor();
    bindProcessor.add((condition, boss) -> {
        Optional<Skeleton> optBossEnt = boss.getTargetEntity();
        if (optBossEnt.isPresent()) {
            Skeleton bossEnt = optBossEnt.get();
            bossEnt.offer(Keys.DISPLAY_NAME, Text.of("Storm Bringer"));
            bossEnt.offer(Keys.CUSTOM_NAME_VISIBLE, true);
            double bossHealth = 20 * 30 * boss.getDetail().getLevel();
            setMaxHealth(bossEnt, bossHealth, true);
        }
        return Optional.empty();
    });
    List<Instruction<DamageCondition, Boss<Skeleton, WildernessBossDetail>>> damageProcessor = bossManager.getDamageProcessor();
    damageProcessor.add((condition, boss) -> {
        Entity eToHit = condition.getAttacked();
        if (!(eToHit instanceof Living)) {
            return Optional.empty();
        }
        Living toHit = (Living) eToHit;
        Location<World> targetLocation = toHit.getLocation();
        for (int i = boss.getDetail().getLevel() * Probability.getRangedRandom(1, 10); i >= 0; --i) {
            Task.builder().execute(() -> {
                Entity lightning = targetLocation.getExtent().createEntity(EntityTypes.LIGHTNING, targetLocation.getPosition());
                targetLocation.getExtent().spawnEntity(lightning, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
            }).delayTicks(5 * (6 + i)).submit(SkreePlugin.inst());
        }
        return Optional.empty();
    });
}
Also used : Entity(org.spongepowered.api.entity.Entity) WildernessBossDetail(com.skelril.skree.content.world.wilderness.WildernessBossDetail) Living(org.spongepowered.api.entity.living.Living) Instruction(com.skelril.openboss.Instruction) World(org.spongepowered.api.world.World) Skeleton(org.spongepowered.api.entity.living.monster.Skeleton)

Aggregations

Instruction (com.skelril.openboss.Instruction)3 WildernessBossDetail (com.skelril.skree.content.world.wilderness.WildernessBossDetail)3 Entity (org.spongepowered.api.entity.Entity)3 Living (org.spongepowered.api.entity.living.Living)3 Skeleton (org.spongepowered.api.entity.living.monster.Skeleton)2 World (org.spongepowered.api.world.World)2 CuboidContainmentPredicate (com.skelril.nitro.position.CuboidContainmentPredicate)1 PotionEffectData (org.spongepowered.api.data.manipulator.mutable.PotionEffectData)1 Spider (org.spongepowered.api.entity.living.monster.Spider)1 DamageSource (org.spongepowered.api.event.cause.entity.damage.source.DamageSource)1 IndirectEntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource)1 DamageEntityEvent (org.spongepowered.api.event.entity.DamageEntityEvent)1