Search in sources :

Example 21 with Entity

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

the class PlayerCombatParser method parse.

default default void parse(DamageEntityEvent event) {
    Entity entity = event.getTargetEntity();
    if (!(entity instanceof Living)) {
        return;
    }
    Optional<DamageSource> optDamageSource = event.getCause().first(DamageSource.class);
    if (optDamageSource.isPresent()) {
        Entity srcEntity = null;
        Entity indirectSrcEntity = null;
        if (optDamageSource.get() instanceof IndirectEntityDamageSource) {
            srcEntity = ((IndirectEntityDamageSource) optDamageSource.get()).getIndirectSource();
            indirectSrcEntity = ((IndirectEntityDamageSource) optDamageSource.get()).getSource();
        } else if (optDamageSource.get() instanceof EntityDamageSource) {
            srcEntity = ((EntityDamageSource) optDamageSource.get()).getSource();
        }
        if (!(srcEntity instanceof Living)) {
            if (entity instanceof Player) {
                processNonLivingAttack(optDamageSource.get(), (Player) entity);
            }
            return;
        }
        Living living = (Living) srcEntity;
        if (verify(living)) {
            if (entity instanceof Player && living instanceof Player) {
                processPvP((Player) living, (Player) entity);
                processPvP((Player) living, (Player) entity, indirectSrcEntity);
            } else if (entity instanceof Player) {
                processMonsterAttack(living, (Player) entity);
            } else if (living instanceof Player) {
                processPlayerAttack((Player) living, (Living) entity);
            }
        }
    }
}
Also used : Entity(org.spongepowered.api.entity.Entity) Player(org.spongepowered.api.entity.living.player.Player) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource) DamageSource(org.spongepowered.api.event.cause.entity.damage.source.DamageSource) 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 22 with Entity

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

the class PlayerCombatParser method parse.

default default void parse(CollideEntityEvent.Impact event) {
    Optional<Projectile> optProjectile = event.getCause().first(Projectile.class);
    if (!optProjectile.isPresent()) {
        return;
    }
    Projectile projectile = optProjectile.get();
    ProjectileSource source = optProjectile.get().getShooter();
    if (!(source instanceof Player)) {
        return;
    }
    Player attacker = (Player) source;
    for (Entity anEntity : event.getEntities()) {
        if (anEntity instanceof Player) {
            Player defender = (Player) anEntity;
            processPvP(attacker, defender);
            processPvP(attacker, defender, projectile);
        }
    }
}
Also used : Entity(org.spongepowered.api.entity.Entity) Player(org.spongepowered.api.entity.living.player.Player) ProjectileSource(org.spongepowered.api.entity.projectile.source.ProjectileSource) Projectile(org.spongepowered.api.entity.projectile.Projectile)

Example 23 with Entity

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

the class ThorAttack method apply.

@Override
public Optional<Instruction<DamageCondition, Boss<Zombie, CatacombsBossDetail>>> apply(DamageCondition damageCondition, Boss<Zombie, CatacombsBossDetail> zombieCatacombsBossDetailBoss) {
    Living bossEnt = zombieCatacombsBossDetailBoss.getTargetEntity().get();
    Entity toHit = damageCondition.getAttacked();
    toHit.setVelocity(EntityDirectionUtil.getFacingVector(bossEnt).mul(2));
    Task.builder().execute(() -> {
        Location<World> targetLoc = toHit.getLocation();
        Task.builder().execute(() -> {
            Lightning lightning = (Lightning) toHit.getWorld().createEntity(EntityTypes.LIGHTNING, targetLoc.getPosition());
            toHit.getWorld().spawnEntity(lightning, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
        }).delay(750, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
    }).delay(1500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
    return Optional.empty();
}
Also used : Entity(org.spongepowered.api.entity.Entity) Living(org.spongepowered.api.entity.living.Living) Lightning(org.spongepowered.api.entity.weather.Lightning) World(org.spongepowered.api.world.World)

Example 24 with Entity

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

the class FreakyFourInstance method spawnCharlotteMinion.

private void spawnCharlotteMinion(Vector3d position) {
    Entity entity = getRegion().getExtent().createEntity(EntityTypes.CAVE_SPIDER, position);
    getRegion().getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
    Boss<CaveSpider, ZoneBossDetail<FreakyFourInstance>> boss = new Boss<>((CaveSpider) entity, new ZoneBossDetail<>(this));
    charlotteMinions.add(boss);
    charlotteManager.getMinionManager().bind(boss);
}
Also used : Entity(org.spongepowered.api.entity.Entity) Boss(com.skelril.openboss.Boss) CaveSpider(org.spongepowered.api.entity.living.monster.CaveSpider) ZoneBossDetail(com.skelril.skree.content.zone.ZoneBossDetail)

Example 25 with Entity

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

the class FrimusBossManager 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, Math.max(1, Probability.getRandom(EntityHealthUtil.getHealth((Living) attacked)) - 5));
            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) ZoneBossDetail(com.skelril.skree.content.zone.ZoneBossDetail)

Aggregations

Entity (org.spongepowered.api.entity.Entity)59 Player (org.spongepowered.api.entity.living.player.Player)23 World (org.spongepowered.api.world.World)19 Living (org.spongepowered.api.entity.living.Living)17 Listener (org.spongepowered.api.event.Listener)13 Vector3d (com.flowpowered.math.vector.Vector3d)10 ArrayList (java.util.ArrayList)8 DamageSource (org.spongepowered.api.event.cause.entity.damage.source.DamageSource)8 Instruction (com.skelril.openboss.Instruction)7 ItemStack (org.spongepowered.api.item.inventory.ItemStack)7 Location (org.spongepowered.api.world.Location)7 Zombie (org.spongepowered.api.entity.living.monster.Zombie)6 IndirectEntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource)6 ZoneBossDetail (com.skelril.skree.content.zone.ZoneBossDetail)5 PotionEffect (org.spongepowered.api.effect.potion.PotionEffect)5 EntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource)5 DamageEntityEvent (org.spongepowered.api.event.entity.DamageEntityEvent)5 TileEntity (org.spongepowered.api.block.tileentity.TileEntity)4 Vector3i (com.flowpowered.math.vector.Vector3i)3 PlayerCombatParser (com.skelril.nitro.combat.PlayerCombatParser)3