Search in sources :

Example 1 with PlayerCombatParser

use of com.skelril.nitro.combat.PlayerCombatParser in project Skree by Skelril.

the class BuildWorldWrapper method createFor.

private PlayerCombatParser createFor(Cancellable event) {
    return new PlayerCombatParser() {

        @Override
        public void processPvP(Player attacker, Player defender) {
            Optional<PvPService> optService = Sponge.getServiceManager().provide(PvPService.class);
            if (optService.isPresent()) {
                PvPService service = optService.get();
                if (service.getPvPState(attacker).allowByDefault() && service.getPvPState(defender).allowByDefault()) {
                    return;
                }
            }
            attacker.sendMessage(Text.of(TextColors.RED, "PvP is opt-in only in build worlds!"));
            event.setCancelled(true);
        }
    };
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) PvPService(com.skelril.skree.service.PvPService) PlayerCombatParser(com.skelril.nitro.combat.PlayerCombatParser)

Example 2 with PlayerCombatParser

use of com.skelril.nitro.combat.PlayerCombatParser in project Skree by Skelril.

the class ZonePvPListener method createFor.

private PlayerCombatParser createFor(Cancellable event) {
    return new PlayerCombatParser() {

        @Override
        public void processPvP(Player attacker, Player defender) {
            Optional<PvPService> optService = Sponge.getServiceManager().provide(PvPService.class);
            if (optService.isPresent()) {
                PvPService service = optService.get();
                if (service.getPvPState(attacker).allowByDefault() && service.getPvPState(defender).allowByDefault()) {
                    return;
                }
            }
            attacker.sendMessage(Text.of(TextColors.RED, "PvP is opt-in only in this area!"));
            event.setCancelled(true);
        }
    };
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) PvPService(com.skelril.skree.service.PvPService) PlayerCombatParser(com.skelril.nitro.combat.PlayerCombatParser)

Example 3 with PlayerCombatParser

use of com.skelril.nitro.combat.PlayerCombatParser in project Skree by Skelril.

the class FrimusBossManager method handleDamaged.

private void handleDamaged() {
    List<Instruction<DamagedCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> damagedProcessor = getDamagedProcessor();
    damagedProcessor.add((condition, boss) -> {
        DamageEntityEvent event = condition.getEvent();
        new PlayerCombatParser() {

            @Override
            public void processPlayerAttack(Player attacker, Living defender) {
                if (condition.getDamageSource().get() instanceof IndirectEntityDamageSource) {
                    attacker.sendMessage(Text.of(TextColors.RED, "Projectiles can't harm me... Mwahahaha!"));
                    event.setCancelled(true);
                }
            }
        }.parse(event);
        return Optional.empty();
    });
}
Also used : DamageEntityEvent(org.spongepowered.api.event.entity.DamageEntityEvent) Player(org.spongepowered.api.entity.living.player.Player) Living(org.spongepowered.api.entity.living.Living) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource) 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) PlayerCombatParser(com.skelril.nitro.combat.PlayerCombatParser)

Example 4 with PlayerCombatParser

use of com.skelril.nitro.combat.PlayerCombatParser in project Skree by Skelril.

the class DeathMark method apply.

@Override
public Optional<Instruction<DamagedCondition, Boss<Zombie, CatacombsBossDetail>>> apply(DamagedCondition damagedCondition, Boss<Zombie, CatacombsBossDetail> zombieCatacombsBossDetailBoss) {
    new PlayerCombatParser() {

        @Override
        public void processPlayerAttack(Player attacker, Living defender) {
            CatacombsBossDetail detail = zombieCatacombsBossDetailBoss.getDetail();
            CatacombsInstance inst = detail.getZone();
            if (detail.isWarmingMark()) {
                return;
            }
            if (detail.getMarked().isPresent()) {
                if (attacker.equals(detail.getMarked().get())) {
                    inst.getPlayerMessageChannel(PlayerClassifier.SPECTATOR).send(Text.of(TextColors.YELLOW, attacker.getName() + " has been freed!"));
                } else {
                    detail.getMarked().get().offer(Keys.HEALTH, 0D);
                }
                detail.setMarked(null);
            } else if (activate(detail)) {
                detail.warmMark();
                inst.getPlayerMessageChannel(PlayerClassifier.SPECTATOR).send(Text.of(TextColors.DARK_RED, "The necromancer stares intently at " + attacker.getName() + "!"));
                Task.builder().execute(() -> {
                    if (!inst.contains(attacker)) {
                        detail.setMarked(null);
                        return;
                    }
                    detail.setMarked(attacker);
                    inst.getPlayerMessageChannel(PlayerClassifier.SPECTATOR).send(Text.of(TextColors.DARK_RED, attacker.getName() + " has been marked!"));
                }).delay(3, TimeUnit.SECONDS).submit(SkreePlugin.inst());
            }
        }
    }.parse(damagedCondition.getEvent());
    return Optional.empty();
}
Also used : CatacombsBossDetail(com.skelril.skree.content.zone.group.catacombs.CatacombsBossDetail) Player(org.spongepowered.api.entity.living.player.Player) CatacombsInstance(com.skelril.skree.content.zone.group.catacombs.CatacombsInstance) Living(org.spongepowered.api.entity.living.Living) PlayerCombatParser(com.skelril.nitro.combat.PlayerCombatParser)

Example 5 with PlayerCombatParser

use of com.skelril.nitro.combat.PlayerCombatParser in project Skree by Skelril.

the class TheForgeListener method onPlayerCombat.

@Listener
public void onPlayerCombat(CollideEntityEvent.Impact event, @First Projectile projectile) {
    Optional<TheForgeInstance> optInst = manager.getApplicableZone(projectile);
    if (!optInst.isPresent()) {
        return;
    }
    new PlayerCombatParser() {

        @Override
        public void processMonsterAttack(Living attacker, Player defender) {
            if (!(event instanceof DamageEntityEvent)) {
                return;
            }
            DamageEntityEvent dEvent = (DamageEntityEvent) event;
            if (isFlying(defender)) {
                dEvent.setBaseDamage(dEvent.getBaseDamage() * 3);
            }
        }
    }.parse(event);
}
Also used : DamageEntityEvent(org.spongepowered.api.event.entity.DamageEntityEvent) Player(org.spongepowered.api.entity.living.player.Player) Living(org.spongepowered.api.entity.living.Living) PlayerCombatParser(com.skelril.nitro.combat.PlayerCombatParser) Listener(org.spongepowered.api.event.Listener)

Aggregations

PlayerCombatParser (com.skelril.nitro.combat.PlayerCombatParser)10 Player (org.spongepowered.api.entity.living.player.Player)10 Living (org.spongepowered.api.entity.living.Living)6 DamageEntityEvent (org.spongepowered.api.event.entity.DamageEntityEvent)6 PvPService (com.skelril.skree.service.PvPService)4 Entity (org.spongepowered.api.entity.Entity)3 IndirectEntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource)3 Nullable (javax.annotation.Nullable)2 DamageFunction (org.spongepowered.api.event.cause.entity.damage.DamageFunction)2 DamageSource (org.spongepowered.api.event.cause.entity.damage.source.DamageSource)2 Vector3d (com.flowpowered.math.vector.Vector3d)1 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)1 IntegratedRunnable (com.skelril.nitro.time.IntegratedRunnable)1 TimedRunnable (com.skelril.nitro.time.TimedRunnable)1 Instruction (com.skelril.openboss.Instruction)1 ZoneBossDetail (com.skelril.skree.content.zone.ZoneBossDetail)1 CatacombsBossDetail (com.skelril.skree.content.zone.group.catacombs.CatacombsBossDetail)1 CatacombsInstance (com.skelril.skree.content.zone.group.catacombs.CatacombsInstance)1 NamedBindInstruction (com.skelril.skree.content.zone.group.catacombs.instruction.bossmove.NamedBindInstruction)1 HealthBindInstruction (com.skelril.skree.content.zone.group.freakyfour.boss.bossmove.HealthBindInstruction)1