Search in sources :

Example 31 with Living

use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.

the class ArrowFishingHandler method onProjectileTickEvent.

@Listener
public void onProjectileTickEvent(ProjectileTickEvent event) {
    Projectile projectile = event.getTargetEntity();
    if (!(projectile instanceof Arrow) || Probability.getChance(3)) {
        return;
    }
    Location<World> loc = projectile.getLocation();
    if (MultiTypeRegistry.isWater(loc.getBlockType()) && checkVelocity(projectile.getVelocity())) {
        ProjectileSource source = projectile.getShooter();
        double modifier = 1;
        if (source instanceof Living) {
            modifier = 50;
        }
        Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class);
        int rolls = 1;
        if (optService.isPresent() && optService.get().isActive(UBER_ARROW_FISHING)) {
            if (source instanceof Living) {
                rolls = 15;
            } else {
                rolls = 5;
            }
        }
        new ItemDropper(loc).dropStacks(dropTable.getDrops(rolls, modifier), SpawnTypes.DROPPED_ITEM);
    }
}
Also used : Arrow(org.spongepowered.api.entity.projectile.arrow.Arrow) ItemDropper(com.skelril.nitro.item.ItemDropper) Living(org.spongepowered.api.entity.living.Living) ProjectileSource(org.spongepowered.api.entity.projectile.source.ProjectileSource) ModifierService(com.skelril.skree.service.ModifierService) World(org.spongepowered.api.world.World) Projectile(org.spongepowered.api.entity.projectile.Projectile) Listener(org.spongepowered.api.event.Listener)

Example 32 with Living

use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.

the class SnipeeBossManager method handleBinds.

private void handleBinds() {
    List<Instruction<BindCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> bindProcessor = getBindProcessor();
    bindProcessor.add(new NamedBindInstruction<>("Snipee"));
    bindProcessor.add(new HealthBindInstruction<>(config.snipeeHP));
    bindProcessor.add((condition, boss) -> {
        Living entity = boss.getTargetEntity().get();
        if (entity instanceof ArmorEquipable) {
            ((ArmorEquipable) entity).setItemInHand(HandTypes.MAIN_HAND, newItemStack(ItemTypes.BOW));
        }
        return Optional.empty();
    });
}
Also used : ArmorEquipable(org.spongepowered.api.entity.ArmorEquipable) Living(org.spongepowered.api.entity.living.Living) NamedBindInstruction(com.skelril.skree.content.zone.group.catacombs.instruction.bossmove.NamedBindInstruction) Instruction(com.skelril.openboss.Instruction) HealthBindInstruction(com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.HealthBindInstruction) HealableInstruction(com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.HealableInstruction) BackTeleportInstruction(com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.BackTeleportInstruction) ZoneBossDetail(com.skelril.skree.content.zone.ZoneBossDetail)

Example 33 with Living

use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.

the class SnipeeBossManager method handleDamage.

private void handleDamage() {
    List<Instruction<DamageCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> damageProcessor = getDamageProcessor();
    damageProcessor.add((condition, boss) -> {
        Entity attacked = condition.getAttacked();
        if (attacked instanceof Living) {
            EntityHealthUtil.forceDamage((Living) attacked, EntityHealthUtil.getMaxHealth((Living) attacked) * config.snipeeDamage);
            condition.getEvent().setBaseDamage(0);
        }
        return Optional.empty();
    });
}
Also used : Entity(org.spongepowered.api.entity.Entity) Living(org.spongepowered.api.entity.living.Living) NamedBindInstruction(com.skelril.skree.content.zone.group.catacombs.instruction.bossmove.NamedBindInstruction) Instruction(com.skelril.openboss.Instruction) HealthBindInstruction(com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.HealthBindInstruction) HealableInstruction(com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.HealableInstruction) BackTeleportInstruction(com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.BackTeleportInstruction) ZoneBossDetail(com.skelril.skree.content.zone.ZoneBossDetail)

Example 34 with Living

use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.

the class BackTeleportInstruction method apply.

@Override
public Optional<Instruction<DamagedCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> apply(DamagedCondition damagedCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>> livingZoneBossDetailBoss) {
    DamageEntityEvent event = damagedCondition.getEvent();
    new PlayerCombatParser() {

        @Override
        public void processPlayerAttack(Player attacker, Living defender) {
            boolean backTeleport = Probability.getChance(config.backTeleport);
            if (backTeleport || damagedCondition.getDamageSource().get() instanceof IndirectEntityDamageSource) {
                double distSQ = 2;
                double maxDist = 1;
                if (defender instanceof Skeleton) {
                    distSQ = defender.getLocation().getPosition().distanceSquared(attacker.getLocation().getPosition());
                    maxDist = config.snipeeTeleportDist;
                }
                if (backTeleport || distSQ > Math.pow(maxDist, 2)) {
                    final Entity finalDamager = attacker;
                    Task.builder().execute(() -> {
                        defender.setLocation(finalDamager.getLocation());
                        throwBack(defender);
                    }).delayTicks(1).submit(SkreePlugin.inst());
                }
            }
        }
    }.parse(event);
    return Optional.empty();
}
Also used : DamageEntityEvent(org.spongepowered.api.event.entity.DamageEntityEvent) Entity(org.spongepowered.api.entity.Entity) Player(org.spongepowered.api.entity.living.player.Player) Living(org.spongepowered.api.entity.living.Living) Skeleton(org.spongepowered.api.entity.living.monster.Skeleton) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource) PlayerCombatParser(com.skelril.nitro.combat.PlayerCombatParser)

Example 35 with Living

use of org.spongepowered.api.entity.living.Living in project Skree by Skelril.

the class CharlotteBossManager method handleUnbinds.

private void handleUnbinds() {
    List<Instruction<UnbindCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> unbindProcessor = getUnbindProcessor();
    unbindProcessor.add(new FreakyFourBossDeath());
}
Also used : Living(org.spongepowered.api.entity.living.Living) FreakyFourBossDeath(com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.FreakyFourBossDeath) NamedBindInstruction(com.skelril.skree.content.zone.group.catacombs.instruction.bossmove.NamedBindInstruction) Instruction(com.skelril.openboss.Instruction) HealthBindInstruction(com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.HealthBindInstruction) ZoneBossDetail(com.skelril.skree.content.zone.ZoneBossDetail)

Aggregations

Living (org.spongepowered.api.entity.living.Living)63 Entity (org.spongepowered.api.entity.Entity)34 Player (org.spongepowered.api.entity.living.player.Player)16 Instruction (com.skelril.openboss.Instruction)15 ZoneBossDetail (com.skelril.skree.content.zone.ZoneBossDetail)13 Listener (org.spongepowered.api.event.Listener)13 World (org.spongepowered.api.world.World)12 NamedBindInstruction (com.skelril.skree.content.zone.group.catacombs.instruction.bossmove.NamedBindInstruction)10 HealthBindInstruction (com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.HealthBindInstruction)10 DamageEntityEvent (org.spongepowered.api.event.entity.DamageEntityEvent)8 EntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource)7 Vector3d (com.flowpowered.math.vector.Vector3d)6 PlayerCombatParser (com.skelril.nitro.combat.PlayerCombatParser)6 CuboidContainmentPredicate (com.skelril.nitro.position.CuboidContainmentPredicate)6 BackTeleportInstruction (com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.BackTeleportInstruction)6 HealableInstruction (com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.HealableInstruction)6 IndirectEntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource)6 Vector3i (com.flowpowered.math.vector.Vector3i)5 IntegratedRunnable (com.skelril.nitro.time.IntegratedRunnable)5 TimedRunnable (com.skelril.nitro.time.TimedRunnable)5