use of org.spongepowered.api.event.entity.DamageEntityEvent in project Skree by Skelril.
the class HealableInstruction method apply.
@Override
public Optional<Instruction<DamagedCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>>>> apply(DamagedCondition damagedCondition, Boss<Living, ZoneBossDetail<FreakyFourInstance>> boss) {
Optional<DamageSource> optDmgSource = damagedCondition.getDamageSource();
if (optDmgSource.isPresent()) {
if (optDmgSource.get().getType() == DamageTypes.EXPLOSIVE) {
DamageEntityEvent event = damagedCondition.getEvent();
EntityHealthUtil.heal(boss.getTargetEntity().get(), event.getFinalDamage());
event.setCancelled(true);
}
}
return Optional.empty();
}
use of org.spongepowered.api.event.entity.DamageEntityEvent in project Skree by Skelril.
the class PatientXManager method setupBossManager.
private void setupBossManager() {
Sponge.getEventManager().registerListeners(SkreePlugin.inst(), new BossListener<>(bossManager, Zombie.class));
List<Instruction<BindCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> bindProcessor = bossManager.getBindProcessor();
bindProcessor.add((condition, boss) -> {
Optional<Zombie> optBossEnt = boss.getTargetEntity();
if (optBossEnt.isPresent()) {
Zombie bossEnt = optBossEnt.get();
bossEnt.offer(Keys.DISPLAY_NAME, Text.of("Patient X"));
setMaxHealth(bossEnt, config.bossHealth, true);
}
return Optional.empty();
});
bindProcessor.add((condition, boss) -> {
Optional<Zombie> optBoss = boss.getTargetEntity();
if (optBoss.isPresent()) {
optBoss.get().offer(Keys.PERSISTS, true);
}
return Optional.empty();
});
bindProcessor.add((condition, boss) -> {
boss.getDetail().getZone().getPlayerMessageChannel(PlayerClassifier.SPECTATOR).send(Text.of(TextColors.GOLD, "Ice to meet you again!"));
return Optional.empty();
});
List<Instruction<UnbindCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> unbindProcessor = bossManager.getUnbindProcessor();
unbindProcessor.add((condition, boss) -> {
PatientXInstance inst = boss.getDetail().getZone();
Location<World> target = inst.getCenter();
for (Player player : inst.getPlayers(PlayerClassifier.PARTICIPANT)) {
player.setLocation(target);
boolean useX = Probability.getChance(2);
int accel = Probability.getChance(2) ? 1 : -1;
Vector3d v = new Vector3d(useX ? accel : 0, 0, !useX ? accel : 0);
player.setVelocity(v);
}
inst.freezeBlocks(100, false);
// Reset respawn mechanics
inst.bossDied();
return Optional.empty();
});
List<Instruction<DamageCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> damageProcessor = bossManager.getDamageProcessor();
damageProcessor.add((condition, boss) -> {
PatientXInstance inst = boss.getDetail().getZone();
DamageEntityEvent event = condition.getEvent();
// Nullify all modifiers
for (Tuple<DamageModifier, Function<? super Double, Double>> modifier : event.getModifiers()) {
event.setDamage(modifier.getFirst(), (a) -> a);
}
event.setBaseDamage(inst.getDifficulty() * config.baseBossHit);
return Optional.empty();
});
List<Instruction<DamagedCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> damagedProcessor = bossManager.getDamagedProcessor();
damagedProcessor.add((condition, boss) -> {
DamageEntityEvent event = condition.getEvent();
Optional<DamageSource> optDamageSource = condition.getDamageSource();
if (optDamageSource.isPresent() && blockedDamage.contains(optDamageSource.get().getType())) {
event.setCancelled(true);
return Optional.empty();
}
return Optional.of((damagedCondition, zombieZoneBossDetailBoss) -> {
PatientXInstance inst = boss.getDetail().getZone();
if (optDamageSource.isPresent() && optDamageSource.get() instanceof EntityDamageSource) {
if (optDamageSource.get() instanceof IndirectEntityDamageSource) {
Task.builder().execute(() -> {
VelocityEntitySpawner.sendRadial(EntityTypes.SNOWBALL, inst.getBoss().get(), Cause.source(SpawnCause.builder().type(SpawnTypes.PROJECTILE).build()).build());
}).delayTicks(1).submit(SkreePlugin.inst());
} else {
Entity srcEntity = ((EntityDamageSource) optDamageSource.get()).getSource();
if (srcEntity instanceof Player) {
Optional<ItemStack> optHeld = ((Player) srcEntity).getItemInHand(HandTypes.MAIN_HAND);
if (optHeld.isPresent() && optHeld.get().getItem() == ItemTypes.BLAZE_ROD) {
inst.modifyDifficulty(2);
}
}
}
}
inst.modifyDifficulty(.5);
inst.teleportRandom(true);
return Optional.empty();
});
});
}
use of org.spongepowered.api.event.entity.DamageEntityEvent in project Skree by Skelril.
the class ShnugglesPrimeManager method setupBossManager.
private void setupBossManager() {
Sponge.getEventManager().registerListeners(SkreePlugin.inst(), new BossListener<>(bossManager, Giant.class));
List<Instruction<BindCondition, Boss<Giant, ZoneBossDetail<ShnugglesPrimeInstance>>>> bindProcessor = bossManager.getBindProcessor();
bindProcessor.add((condition, boss) -> {
Optional<Giant> optBossEnt = boss.getTargetEntity();
if (optBossEnt.isPresent()) {
Giant bossEnt = optBossEnt.get();
bossEnt.offer(Keys.DISPLAY_NAME, Text.of("Shnuggles Prime"));
setMaxHealth(bossEnt, 750, true);
}
return Optional.empty();
});
bindProcessor.add((condition, boss) -> {
Optional<Giant> optBoss = boss.getTargetEntity();
if (optBoss.isPresent()) {
optBoss.get().offer(Keys.PERSISTS, true);
}
return Optional.empty();
});
bindProcessor.add((condition, boss) -> {
boss.getDetail().getZone().getPlayerMessageChannel(PlayerClassifier.SPECTATOR).send(Text.of(TextColors.GOLD, "I live again!"));
return Optional.empty();
});
List<Instruction<UnbindCondition, Boss<Giant, ZoneBossDetail<ShnugglesPrimeInstance>>>> unbindProcessor = bossManager.getUnbindProcessor();
unbindProcessor.add((condition, boss) -> {
ShnugglesPrimeInstance inst = boss.getDetail().getZone();
// Reset respawn mechanics
inst.bossDied();
// Buff babies
inst.buffBabies();
return Optional.empty();
});
unbindProcessor.add((condition, boss) -> {
ShnugglesPrimeInstance inst = boss.getDetail().getZone();
int playerCount = inst.getPlayers(PlayerClassifier.PARTICIPANT).size();
Collection<ItemStack> drops = dropTable.getDrops(Math.min(7000, playerCount * 1500), 1);
Optional<Giant> optEnt = boss.getTargetEntity();
if (optEnt.isPresent()) {
Task.builder().execute(() -> {
new ItemDropper(optEnt.get().getLocation()).dropStacks(drops, SpawnTypes.DROPPED_ITEM);
}).delayTicks(1).submit(SkreePlugin.inst());
}
return Optional.empty();
});
List<Instruction<DamagedCondition, Boss<Giant, ZoneBossDetail<ShnugglesPrimeInstance>>>> damagedProcessor = bossManager.getDamagedProcessor();
damagedProcessor.add((condition, boss) -> {
ShnugglesPrimeInstance inst = boss.getDetail().getZone();
DamageEntityEvent event = condition.getEvent();
// Schedule a task to change the display name to show HP
Task.builder().execute(inst::printBossHealth).delayTicks(1).submit(SkreePlugin.inst());
if (inst.damageHeals()) {
if (inst.isActiveAttack(ShnugglesPrimeAttack.BASK_IN_MY_GLORY)) {
if (boss.getTargetEntity().isPresent()) {
toFullHealth(boss.getTargetEntity().get());
}
} else {
double healedDamage = event.getFinalDamage() * 2;
if (boss.getTargetEntity().isPresent()) {
heal(boss.getTargetEntity().get(), healedDamage);
}
}
event.setBaseDamage(0);
if (Probability.getChance(3) && event.getCause().first(Player.class).isPresent()) {
int affected = 0;
if (boss.getTargetEntity().isPresent()) {
for (Entity e : boss.getTargetEntity().get().getNearbyEntities(8)) {
if (e.isLoaded() && !e.isRemoved() && e instanceof Player && inst.contains(e)) {
e.setVelocity(new Vector3d(Math.random() * 3 - 1.5, Math.random() * 4, Math.random() * 3 - 1.5));
e.offer(Keys.FIRE_TICKS, Probability.getRandom(20 * 60));
++affected;
}
}
}
if (affected > 0) {
inst.sendAttackBroadcast("Feel my power!", AttackSeverity.INFO);
}
}
}
Optional<DamageSource> optDmgSource = condition.getDamageSource();
if (optDmgSource.isPresent()) {
DamageSource dmgSource = optDmgSource.get();
Entity attacker = null;
if (dmgSource instanceof IndirectEntityDamageSource) {
attacker = ((IndirectEntityDamageSource) dmgSource).getIndirectSource();
} else if (dmgSource instanceof EntityDamageSource) {
attacker = ((EntityDamageSource) dmgSource).getSource();
if (attacker instanceof Player) {
/* TODO Convert to Sponge
if (ItemUtil.hasForgeBook((Player) attacker)) {
boss.setHealth(0);
final Player finalAttacker = (Player) attacker;
if (!finalAttacker.getGameMode().equals(GameMode.CREATIVE)) {
server().getScheduler().runTaskLater(inst(), () -> (finalAttacker).setItemInHand(null), 1);
}
}*/
}
}
if (Probability.getChance(3) && attacker instanceof Player) {
inst.spawnMinions((Player) attacker);
}
}
return Optional.empty();
});
}
use of org.spongepowered.api.event.entity.DamageEntityEvent 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"));
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();
});
}
use of org.spongepowered.api.event.entity.DamageEntityEvent 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();
});
}
Aggregations