Search in sources :

Example 1 with CuboidContainmentPredicate

use of com.skelril.nitro.position.CuboidContainmentPredicate in project Skree by Skelril.

the class DamageNearby method apply.

@Override
public Optional<Instruction<DamagedCondition, T>> apply(DamagedCondition damagedCondition, T bossDetail) {
    Living boss = bossDetail.getTargetEntity().get();
    CuboidContainmentPredicate predicate = new CuboidContainmentPredicate(boss.getLocation().getPosition(), 2, 2, 2);
    boss.getNearbyEntities(e -> predicate.test(e.getLocation().getPosition())).stream().filter(e -> e instanceof Living).map(e -> (Living) e).filter(e -> checkTarget(bossDetail, e)).forEach(e -> damage(bossDetail, e));
    return Optional.empty();
}
Also used : CuboidContainmentPredicate(com.skelril.nitro.position.CuboidContainmentPredicate) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) CuboidContainmentPredicate(com.skelril.nitro.position.CuboidContainmentPredicate) Boss(com.skelril.openboss.Boss) DamagedCondition(com.skelril.openboss.condition.DamagedCondition) Optional(java.util.Optional) Instruction(com.skelril.openboss.Instruction) DamageTypes(org.spongepowered.api.event.cause.entity.damage.DamageTypes) Living(org.spongepowered.api.entity.living.Living) EntityDetail(com.skelril.openboss.EntityDetail) Living(org.spongepowered.api.entity.living.Living)

Example 2 with CuboidContainmentPredicate

use of com.skelril.nitro.position.CuboidContainmentPredicate 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 3 with CuboidContainmentPredicate

use of com.skelril.nitro.position.CuboidContainmentPredicate in project Skree by Skelril.

the class JungleRaidEffectListener method onProjectileHit.

@Listener
public void onProjectileHit(CollideEvent.Impact event, @First Entity entity) {
    Optional<JungleRaidInstance> optInst = manager.getApplicableZone(entity);
    if (!optInst.isPresent()) {
        return;
    }
    JungleRaidInstance inst = optInst.get();
    if (inst.getState() != JungleRaidState.IN_PROGRESS) {
        return;
    }
    int explosionSize = 2;
    if (entity.getType() == EntityTypes.TIPPED_ARROW) {
        if (inst.isFlagEnabled(JungleRaidFlag.TORMENT_ARROWS)) {
            ProjectileSource shooter = ((Arrow) entity).getShooter();
            CuboidContainmentPredicate predicate = new CuboidContainmentPredicate(entity.getLocation().getPosition(), 4, 4, 4);
            for (Entity e : entity.getNearbyEntities(en -> predicate.test(en.getLocation().getPosition()))) {
                if (e.equals(shooter)) {
                    continue;
                }
                if (e instanceof Living && shooter instanceof Living) {
                    e.damage(1, IndirectEntityDamageSource.builder().type(DamageTypes.PROJECTILE).entity(entity).proxySource((Living) shooter).build());
                    if (Probability.getChance(5)) {
                        EntityHealthUtil.heal((Living) shooter, 1);
                    }
                }
            }
        }
        if (inst.isFlagEnabled(JungleRaidFlag.EXPLOSIVE_ARROWS)) {
            if (inst.isFlagEnabled(JungleRaidFlag.SUPER)) {
                explosionSize = 4;
            }
        } else {
            return;
        }
    }
    if (entity instanceof Snowball) {
        if (inst.isFlagEnabled(JungleRaidFlag.GRENADES)) {
            if (inst.isFlagEnabled(JungleRaidFlag.SUPER)) {
                explosionSize = 10;
            } else {
                explosionSize = 6;
            }
        } else {
            return;
        }
    }
    if (entity instanceof ThrownPotion) {
        return;
    }
    entity.getLocation().getExtent().triggerExplosion(Explosion.builder().radius(explosionSize).location(entity.getLocation()).shouldDamageEntities(true).shouldBreakBlocks(true).build(), Cause.source(SkreePlugin.container()).build());
}
Also used : Arrow(org.spongepowered.api.entity.projectile.arrow.Arrow) CuboidContainmentPredicate(com.skelril.nitro.position.CuboidContainmentPredicate) Entity(org.spongepowered.api.entity.Entity) Snowball(org.spongepowered.api.entity.projectile.Snowball) Living(org.spongepowered.api.entity.living.Living) ThrownPotion(org.spongepowered.api.entity.projectile.ThrownPotion) ProjectileSource(org.spongepowered.api.entity.projectile.source.ProjectileSource) Listener(org.spongepowered.api.event.Listener)

Aggregations

CuboidContainmentPredicate (com.skelril.nitro.position.CuboidContainmentPredicate)3 Living (org.spongepowered.api.entity.living.Living)3 Instruction (com.skelril.openboss.Instruction)2 Entity (org.spongepowered.api.entity.Entity)2 Boss (com.skelril.openboss.Boss)1 EntityDetail (com.skelril.openboss.EntityDetail)1 DamagedCondition (com.skelril.openboss.condition.DamagedCondition)1 WildernessBossDetail (com.skelril.skree.content.world.wilderness.WildernessBossDetail)1 Optional (java.util.Optional)1 PotionEffectData (org.spongepowered.api.data.manipulator.mutable.PotionEffectData)1 Spider (org.spongepowered.api.entity.living.monster.Spider)1 Snowball (org.spongepowered.api.entity.projectile.Snowball)1 ThrownPotion (org.spongepowered.api.entity.projectile.ThrownPotion)1 Arrow (org.spongepowered.api.entity.projectile.arrow.Arrow)1 ProjectileSource (org.spongepowered.api.entity.projectile.source.ProjectileSource)1 Listener (org.spongepowered.api.event.Listener)1 DamageTypes (org.spongepowered.api.event.cause.entity.damage.DamageTypes)1 EntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource)1 DamageEntityEvent (org.spongepowered.api.event.entity.DamageEntityEvent)1