Search in sources :

Example 51 with Living

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

the class FreakyFourInstance method runCharlotte.

private void runCharlotte() {
    Living boss = getBoss(FreakyFourBoss.CHARLOTTE).get();
    for (int i = Probability.getRandom(10); i > 0; --i) {
        spawnCharlotteMinion(boss.getLocation().getPosition());
    }
    ZoneBoundingBox charlotteRG = regions.get(FreakyFourBoss.CHARLOTTE);
    switch(Probability.getRandom(3)) {
        case 1:
            createWall(charlotteRG, type -> type == BlockTypes.AIR, type -> type == BlockTypes.WEB, BlockTypes.AIR, BlockTypes.WEB, 1, config.charlotteFloorWeb);
            break;
        case 2:
            if (boss instanceof Monster) {
                Optional<Entity> optTarget = ((Monster) boss).getTarget();
                if (optTarget.isPresent() && contains(optTarget.get())) {
                    Entity target = optTarget.get();
                    ZoneBoundingBox targetArea = new ZoneBoundingBox(target.getLocation().getPosition().sub(1, 1, 1).toInt(), new Vector3i(3, 3, 3));
                    targetArea.forAll(pt -> {
                        if (getRegion().getExtent().getBlockType(pt) == BlockTypes.AIR) {
                            getRegion().getExtent().setBlockType(pt, BlockTypes.WEB, Cause.source(SkreePlugin.container()).build());
                        }
                    });
                }
                break;
            }
        case 3:
            charlotteRG.forAll(pt -> {
                if (!Probability.getChance(config.charlotteWebSpider)) {
                    return;
                }
                if (getRegion().getExtent().getBlockType(pt) == BlockTypes.WEB) {
                    getRegion().getExtent().setBlockType(pt, BlockTypes.AIR, Cause.source(SkreePlugin.container()).build());
                    spawnCharlotteMinion(pt.toDouble().add(.5, 0, .5));
                }
            });
            break;
    }
}
Also used : Entity(org.spongepowered.api.entity.Entity) Living(org.spongepowered.api.entity.living.Living) Monster(org.spongepowered.api.entity.living.monster.Monster) Vector3i(com.flowpowered.math.vector.Vector3i) ZoneBoundingBox(com.skelril.skree.service.internal.zone.ZoneBoundingBox)

Example 52 with Living

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

the class RangedSpecialAttackClusterListener method getSource.

public Optional<Clause<Living, ItemStackSnapshot>> getSource(Cause cause) {
    Optional<EntityDamageSource> optEntityDamageSource = cause.first(EntityDamageSource.class);
    if (!optEntityDamageSource.isPresent()) {
        return Optional.empty();
    }
    EntityDamageSource damageSource = optEntityDamageSource.get();
    if (!(damageSource instanceof IndirectEntityDamageSource)) {
        return Optional.empty();
    }
    Entity projectile = damageSource.getSource();
    Entity source = ((IndirectEntityDamageSource) damageSource).getIndirectSource();
    if (!(source instanceof Living)) {
        return Optional.empty();
    }
    return Optional.of(new Clause<>((Living) source, projectile.get(SHOOTING_ITEM_DATA_KEY).map(Optional::get).orElse(null)));
}
Also used : Entity(org.spongepowered.api.entity.Entity) Living(org.spongepowered.api.entity.living.Living) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource)

Example 53 with Living

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

the class DefensiveClusterListener method getSource.

public Optional<Living> getSource(Cause cause) {
    Optional<EntityDamageSource> optEntityDamageSource = cause.first(EntityDamageSource.class);
    if (!optEntityDamageSource.isPresent()) {
        return Optional.empty();
    }
    EntityDamageSource damageSource = optEntityDamageSource.get();
    Entity source;
    if (damageSource instanceof IndirectEntityDamageSource) {
        source = ((IndirectEntityDamageSource) damageSource).getIndirectSource();
    } else {
        source = damageSource.getSource();
    }
    if (!(source instanceof Living)) {
        return Optional.empty();
    }
    return Optional.of((Living) source);
}
Also used : Entity(org.spongepowered.api.entity.Entity) Living(org.spongepowered.api.entity.living.Living) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource)

Example 54 with Living

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

the class DefensiveClusterListener method onPlayerCombat.

@Listener(order = Order.LATE)
public void onPlayerCombat(DamageEntityEvent event) {
    Entity defendingEntity = event.getTargetEntity();
    if (!(defendingEntity instanceof Living)) {
        return;
    }
    Optional<Living> optAttackingEntity = getSource(event.getCause());
    if (!optAttackingEntity.isPresent()) {
        return;
    }
    Living attackingEntity = optAttackingEntity.get();
    if (!applicabilityTest.test((Living) defendingEntity, null)) {
        return;
    }
    if (cooldownHandler.canUseAbility(defendingEntity)) {
        cooldownHandler.useAbility(defendingEntity);
    } else {
        return;
    }
    defensiveCluster.getNextAbilityToUse().run((Living) defendingEntity, attackingEntity, event);
}
Also used : Entity(org.spongepowered.api.entity.Entity) Living(org.spongepowered.api.entity.living.Living) Listener(org.spongepowered.api.event.Listener)

Example 55 with Living

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

the class MeleeAttackClusterListener method onPlayerCombat.

@Listener(order = Order.LATE)
public void onPlayerCombat(DamageEntityEvent event) {
    Entity targetEntity = event.getTargetEntity();
    if (!(targetEntity instanceof Living)) {
        return;
    }
    Optional<Living> optSourceEntity = getSource(event.getCause());
    if (!optSourceEntity.isPresent()) {
        return;
    }
    Living sourceEntity = optSourceEntity.get();
    if (!test(sourceEntity)) {
        return;
    }
    if (cooldownHandler.canUseAbility(sourceEntity)) {
        cooldownHandler.useAbility(sourceEntity);
    } else {
        return;
    }
    attackCluster.getNextAttackToRun().run(sourceEntity, (Living) targetEntity, event);
}
Also used : Entity(org.spongepowered.api.entity.Entity) Living(org.spongepowered.api.entity.living.Living) Listener(org.spongepowered.api.event.Listener)

Aggregations

Living (org.spongepowered.api.entity.living.Living)72 Entity (org.spongepowered.api.entity.Entity)36 Player (org.spongepowered.api.entity.living.player.Player)18 Instruction (com.skelril.openboss.Instruction)15 Listener (org.spongepowered.api.event.Listener)14 ZoneBossDetail (com.skelril.skree.content.zone.ZoneBossDetail)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 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)7 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