use of org.spongepowered.api.entity.living.monster.Zombie in project Skree by Skelril.
the class PatientXInstance method freezeEntities.
private void freezeEntities() {
Zombie boss = getBoss().get();
double total = 0;
for (Living entity : getContained(Living.class)) {
if (entity.equals(boss)) {
continue;
}
BlockType curType = entity.getLocation().getBlockType();
if (curType != BlockTypes.WATER && curType != BlockTypes.FLOWING_WATER) {
continue;
}
if (entity instanceof Zombie) {
entity.offer(Keys.HEALTH, 0D);
EntityHealthUtil.heal(boss, 1);
total += .02;
} else if (!Probability.getChance(5)) {
entity.damage(Probability.getRandom(25), EntityDamageSource.builder().entity(boss).type(DamageTypes.MAGIC).build());
}
}
modifyDifficulty(-total);
}
use of org.spongepowered.api.entity.living.monster.Zombie in project Skree by Skelril.
the class PatientXInstance method runAttack.
public void runAttack(PatientXAttack attackCase) {
Optional<Zombie> optBoss = getBoss();
if (!optBoss.isPresent()) {
return;
}
Zombie boss = optBoss.get();
Collection<Player> contained = getPlayers(PARTICIPANT);
if (contained.isEmpty()) {
return;
}
switch(attackCase) {
case MUSICAL_CHAIRS:
sendAttackBroadcast("Let's play musical chairs!", AttackSeverity.NORMAL);
for (Player player : contained) {
do {
player.setLocation(getRandomDest());
} while (player.getLocation().getPosition().distanceSquared(boss.getLocation().getPosition()) <= 5 * 5);
// TODO convert to Sponge
if (((EntityZombie) boss).canEntityBeSeen(tf(player))) {
player.offer(Keys.HEALTH, Probability.getRandom(player.get(Keys.MAX_HEALTH).get()));
sendAttackBroadcast("Don't worry, I have a medical degree...", AttackSeverity.NORMAL);
sendAttackBroadcast("...or was that a certificate of insanity?", AttackSeverity.NORMAL);
}
}
attackDur = System.currentTimeMillis() + 2000;
break;
case SMASHING_HIT:
for (Player player : contained) {
final double old = player.get(Keys.HEALTH).get();
player.offer(Keys.HEALTH, 3D);
Task.builder().execute(() -> {
if (!player.isRemoved() || !contains(player)) {
return;
}
player.offer(Keys.HEALTH, old * .75);
}).delay(2, TimeUnit.SECONDS).submit(SkreePlugin.inst());
}
attackDur = System.currentTimeMillis() + 3000;
sendAttackBroadcast("This special attack will be a \"smashing hit\"!", AttackSeverity.NORMAL);
break;
case BOMB_PERFORMANCE:
double tntQuantity = Math.max(2, difficulty / 2.4);
for (Player player : contained) {
for (double i = Probability.getRangedRandom(tntQuantity, Math.pow(2, Math.min(9, tntQuantity))); i > 0; i--) {
PrimedTNT explosive = (PrimedTNT) getRegion().getExtent().createEntity(EntityTypes.PRIMED_TNT, player.getLocation().getPosition());
explosive.setVelocity(new Vector3d(random.nextDouble() * 1 - .5, random.nextDouble() * .8 + .2, random.nextDouble() * 1 - .5));
explosive.offer(Keys.FUSE_DURATION, 20 * 4);
getRegion().getExtent().spawnEntity(explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
}
attackDur = System.currentTimeMillis() + 5000;
sendAttackBroadcast("Your performance is really going to \"bomb\"!", AttackSeverity.NORMAL);
break;
case WITHER_AWAY:
PotionEffect witherEffect = PotionEffect.of(PotionEffectTypes.WITHER, 1, 20 * 15);
for (Player player : contained) {
List<PotionEffect> potionEffects = player.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(witherEffect);
player.offer(Keys.POTION_EFFECTS, potionEffects);
}
attackDur = System.currentTimeMillis() + 15750;
sendAttackBroadcast("Like a candle I hope you don't \"whither\" and die!", AttackSeverity.NORMAL);
break;
case SPLASH_TO_IT:
for (Player player : contained) {
for (int i = Probability.getRandom(6) + 2; i > 0; --i) {
throwSlashPotion(player.getLocation());
}
}
attackDur = System.currentTimeMillis() + 2000;
sendAttackBroadcast("Splash to it!", AttackSeverity.NORMAL);
break;
case COLD_FEET:
PotionEffect slowEffect = PotionEffect.of(PotionEffectTypes.SLOWNESS, 2, 20 * 60);
for (Player player : contained) {
List<PotionEffect> potionEffects = player.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(slowEffect);
player.offer(Keys.POTION_EFFECTS, potionEffects);
}
attackDur = System.currentTimeMillis() + 20000;
sendAttackBroadcast("What's the matter, got cold feet?", AttackSeverity.NORMAL);
break;
case IM_JUST_BATTY:
for (Player player : contained) {
Cause cause = Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build();
player.simulateChat(Text.of("I love Patient X!"), cause);
Entity bat = getRegion().getExtent().createEntity(EntityTypes.BAT, player.getLocation().getPosition());
getRegion().getExtent().spawnEntity(bat, cause);
bat.getPassengers().add(player);
}
attackDur = System.currentTimeMillis() + 20000;
sendAttackBroadcast("Awe, I love you too!", AttackSeverity.NORMAL);
sendAttackBroadcast("But only cause I'm a little batty...", AttackSeverity.NORMAL);
break;
case RADIATION:
ParticleEffect radiationEffect = ParticleEffect.builder().type(ParticleTypes.FLAME).quantity(1).build();
Task.builder().execute(() -> {
for (int i = config.radiationTimes; i > 0; i--) {
Task.builder().execute(() -> {
if (isBossSpawned()) {
for (Player player : getPlayers(PlayerClassifier.PARTICIPANT)) {
for (int e = 0; e < 30; ++e) {
getRegion().getExtent().spawnParticles(radiationEffect, player.getLocation().getPosition().add(5 - Probability.getRandom(10) + Probability.getRangedRandom(0, 1.0), 5 - Probability.getRandom(10) + Probability.getRangedRandom(0, 1.0), 5 - Probability.getRandom(10) + Probability.getRangedRandom(0, 1.0)));
}
if (LightLevelUtil.getMaxLightLevel(player.getLocation()).get() >= config.radiationLightLevel) {
player.damage(difficulty * config.radiationMultiplier, EntityDamageSource.builder().entity(boss).type(DamageTypes.MAGIC).build());
}
}
}
}).delay(i * 500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
}
}).delay(3, TimeUnit.SECONDS).submit(SkreePlugin.inst());
attackDur = System.currentTimeMillis() + (config.radiationTimes * 500);
sendAttackBroadcast("Ahhh not the radiation treatment!", AttackSeverity.NORMAL);
break;
case SNOWBALL_FIGHT:
final int burst = Probability.getRangedRandom(10, 20);
Task.builder().execute(() -> {
for (int i = burst; i > 0; i--) {
Task.builder().execute(() -> {
if (boss != null) {
freezeBlocks(true);
}
}).delay(i * 500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
}
}).delay(7, TimeUnit.SECONDS).submit(SkreePlugin.inst());
attackDur = System.currentTimeMillis() + 7000 + (500 * burst);
sendAttackBroadcast("Let's have a snow ball fight!", AttackSeverity.NORMAL);
break;
}
lastAttack = attackCase;
}
use of org.spongepowered.api.entity.living.monster.Zombie 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 (DamageFunction modifier : event.getModifiers()) {
event.setDamage(modifier.getModifier(), (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.entity.living.monster.Zombie in project Skree by Skelril.
the class ShnugglesPrimeInstance method runAttack.
public void runAttack(ShnugglesPrimeAttack attackCase) {
Optional<Giant> optBoss = getBoss();
if (!optBoss.isPresent()) {
return;
}
Giant boss = optBoss.get();
double bossHealth = getHealth(boss);
double maxBossHealth = getMaxHealth(boss);
double delay = 15000;
if (lastAttackTime != 0 && System.currentTimeMillis() - lastAttackTime <= delay) {
return;
}
Collection<Player> contained = getPlayers(PARTICIPANT);
if (contained.isEmpty()) {
return;
}
// AI-ish system
if ((attackCase == ShnugglesPrimeAttack.EVERLASTING || attackCase == ShnugglesPrimeAttack.MINION_LEECH) && bossHealth > maxBossHealth * .9) {
attackCase = Probability.getChance(2) ? ShnugglesPrimeAttack.DARK_POTIONS : ShnugglesPrimeAttack.CORRUPTION;
}
for (Player player : contained) {
if (player.get(Keys.HEALTH).get() < 4) {
attackCase = ShnugglesPrimeAttack.CORRUPTION;
break;
}
}
Collection<Zombie> zombies = getContained(Zombie.class);
if (zombies.size() > 200) {
attackCase = ShnugglesPrimeAttack.BASK_IN_MY_GLORY;
}
if (bossHealth < maxBossHealth * .4 && Probability.getChance(5)) {
if (zombies.size() < 100 && bossHealth > 200) {
attackCase = ShnugglesPrimeAttack.EVERLASTING;
} else {
attackCase = ShnugglesPrimeAttack.MINION_LEECH;
}
}
if ((attackCase == ShnugglesPrimeAttack.BLINDNESS || attackCase == ShnugglesPrimeAttack.FIRE) && bossHealth < maxBossHealth * .15) {
runRandomAttack();
return;
}
switch(attackCase) {
case WRATH:
sendAttackBroadcast("Taste my wrath!", AttackSeverity.NORMAL);
for (Player player : contained) {
player.offer(Keys.VELOCITY, new Vector3d(random.nextDouble() * 3 - 1.5, random.nextDouble() * 1 + .5, random.nextDouble() * 3 - 1.5));
player.offer(Keys.FIRE_TICKS, 20 * 3);
}
break;
case CORRUPTION:
sendAttackBroadcast("Embrace my corruption!", AttackSeverity.NORMAL);
PotionEffect witherEffect = PotionEffect.of(PotionEffectTypes.WITHER, 1, 20 * 3);
for (Player player : contained) {
List<PotionEffect> potionEffects = player.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(witherEffect);
player.offer(Keys.POTION_EFFECTS, potionEffects);
}
break;
case BLINDNESS:
sendAttackBroadcast("Are you BLIND? Mwhahahaha!", AttackSeverity.NORMAL);
PotionEffect blindnessEffect = PotionEffect.of(PotionEffectTypes.BLINDNESS, 0, 20 * 4);
for (Player player : contained) {
List<PotionEffect> potionEffects = player.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(blindnessEffect);
player.offer(Keys.POTION_EFFECTS, potionEffects);
}
break;
case TANGO_TIME:
sendAttackBroadcast("Tango time!", AttackSeverity.ULTIMATE);
activeAttacks.add(ShnugglesPrimeAttack.TANGO_TIME);
Task.builder().delay(7, TimeUnit.SECONDS).execute(() -> {
if (!isBossSpawned()) {
return;
}
for (Player player : getPlayers(PARTICIPANT)) {
// TODO Convert to Sponge
if (((EntityGiantZombie) boss).canEntityBeSeen(tf(player))) {
player.sendMessage(Text.of(TextColors.YELLOW, "Come closer..."));
player.setLocation(boss.getLocation());
EntityDamageSource source = EntityDamageSource.builder().entity(boss).type(DamageTypes.ATTACK).build();
player.damage(100, source, Cause.source(boss).build());
player.offer(Keys.VELOCITY, new Vector3d(random.nextDouble() * 1.7 - 1.5, random.nextDouble() * 2, random.nextDouble() * 1.7 - 1.5));
} else {
player.sendMessage(Text.of(TextColors.YELLOW, "Fine... No tango this time..."));
}
}
sendAttackBroadcast("Now wasn't that fun?", AttackSeverity.INFO);
activeAttacks.remove(ShnugglesPrimeAttack.TANGO_TIME);
}).submit(SkreePlugin.inst());
break;
case EVERLASTING:
if (!damageHeals) {
activeAttacks.add(ShnugglesPrimeAttack.EVERLASTING);
sendAttackBroadcast("I am everlasting!", AttackSeverity.NORMAL);
damageHeals = true;
Task.builder().delay(12, TimeUnit.SECONDS).execute(() -> {
if (damageHeals) {
damageHeals = false;
if (!isBossSpawned()) {
return;
}
sendAttackBroadcast("Thank you for your assistance.", AttackSeverity.INFO);
}
activeAttacks.remove(ShnugglesPrimeAttack.EVERLASTING);
}).submit(SkreePlugin.inst());
break;
}
runRandomAttack();
return;
case FIRE:
sendAttackBroadcast("Fire is your friend...", AttackSeverity.NORMAL);
for (Player player : contained) {
player.offer(Keys.FIRE_TICKS, 20 * 5);
}
break;
case BASK_IN_MY_GLORY:
if (!damageHeals) {
sendAttackBroadcast("Bask in my glory!", AttackSeverity.ULTIMATE);
activeAttacks.add(ShnugglesPrimeAttack.BASK_IN_MY_GLORY);
Task.builder().delay(7, TimeUnit.SECONDS).execute(() -> {
if (!isBossSpawned()) {
return;
}
boolean baskInGlory = false;
for (Player player : getContained(Player.class)) {
// TODO Convert to Sponge
if (((EntityGiantZombie) boss).canEntityBeSeen(tf(player))) {
player.sendMessage(Text.of(TextColors.DARK_RED, "You!"));
baskInGlory = true;
}
}
// Attack
if (baskInGlory) {
damageHeals = true;
spawnPts.stream().filter(pt -> Probability.getChance(12)).forEach(pt -> {
Explosion explosion = Explosion.builder().shouldDamageEntities(true).location(pt).radius(10).build();
getRegion().getExtent().triggerExplosion(explosion, Cause.source(SkreePlugin.container()).owner(boss).build());
});
// Schedule Reset
Task.builder().delay(500, TimeUnit.MILLISECONDS).execute(() -> {
damageHeals = false;
}).submit(SkreePlugin.inst());
return;
}
// Notify if avoided
sendAttackBroadcast("Gah... Afraid are you friends?", AttackSeverity.INFO);
activeAttacks.remove(ShnugglesPrimeAttack.BASK_IN_MY_GLORY);
}).submit(SkreePlugin.inst());
break;
}
runRandomAttack();
break;
case DARK_POTIONS:
sendAttackBroadcast("Unleash the inner darkness!", AttackSeverity.NORMAL);
PotionEffect instantDamageEffect = PotionEffect.of(PotionEffectTypes.INSTANT_DAMAGE, 0, 1);
for (Living entity : getContained(Zombie.class)) {
if (!Probability.getChance(5)) {
continue;
}
entity.offer(Keys.HEALTH, 0D);
Location targetLoc = entity.getLocation();
Entity potion = getRegion().getExtent().createEntity(EntityTypes.SPLASH_POTION, targetLoc.getPosition());
potion.offer(Keys.POTION_EFFECTS, Lists.newArrayList(instantDamageEffect));
getRegion().getExtent().spawnEntity(potion, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
return;
case MINION_LEECH:
sendAttackBroadcast("My minions our time is now!", AttackSeverity.ULTIMATE);
activeAttacks.add(ShnugglesPrimeAttack.MINION_LEECH);
IntegratedRunnable minionEater = new IntegratedRunnable() {
@Override
public boolean run(int times) {
if (!isBossSpawned()) {
return true;
}
for (Living entity : getContained(Living.class)) {
// TODO convert to Sponge
if (entity instanceof Giant || !Probability.getChance(5) || !((EntityGiantZombie) boss).canEntityBeSeen((EntityLivingBase) entity)) {
continue;
}
double realDamage = entity.get(Keys.HEALTH).get();
// TODO convert to Sponge
if (entity instanceof Zombie && ((EntityZombie) entity).isChild()) {
entity.offer(Keys.HEALTH, 0D);
} else {
DamageSource source = DamageSource.builder().type(DamageTypes.ATTACK).build();
entity.damage(realDamage, source, Cause.source(boss).build());
}
toHeal += Math.min(1, realDamage / 3);
}
if (new TimeFilter(-1, 2).matchesFilter(times + 1)) {
getPlayerMessageChannel(SPECTATOR).send(Text.of(TextColors.DARK_AQUA, "The boss has drawn in: " + (int) toHeal + " health."));
}
return true;
}
@Override
public void end() {
if (!isBossSpawned()) {
return;
}
heal(boss, toHeal);
toHeal = 0;
sendAttackBroadcast("Thank you my minions!", AttackSeverity.INFO);
printBossHealth();
activeAttacks.remove(ShnugglesPrimeAttack.MINION_LEECH);
}
};
TimedRunnable<IntegratedRunnable> minonEatingTask = new TimedRunnable<>(minionEater, 20);
Task minionEatingTaskExecutor = Task.builder().interval(500, TimeUnit.MILLISECONDS).execute(minonEatingTask).submit(SkreePlugin.inst());
minonEatingTask.setTask(minionEatingTaskExecutor);
break;
}
lastAttackTime = System.currentTimeMillis();
lastAttack = attackCase;
}
use of org.spongepowered.api.entity.living.monster.Zombie in project Skree by Skelril.
the class CatacombsInstance method spawnBossWave.
private void spawnBossWave() {
Zombie zombie = spawnZombie(entryPoint);
Boss<Zombie, CatacombsBossDetail> boss = new Boss<>(zombie, new CatacombsBossDetail(this, wave));
List<Instruction<DamageCondition, Boss<Zombie, CatacombsBossDetail>>> damageProcessor = boss.getDamageProcessor();
if (Probability.getChance(2)) {
damageProcessor.add(new ThorAttack());
}
if (Probability.getChance(2)) {
damageProcessor.add(new SoulReaper());
}
List<Instruction<DamagedCondition, Boss<Zombie, CatacombsBossDetail>>> damagedProcessor = boss.getDamagedProcessor();
if (Probability.getChance(4)) {
damagedProcessor.add(new BlipDefense());
}
if (Probability.getChance(3)) {
damagedProcessor.add(new ExplosiveArrowBarrage() {
@Override
public boolean activate(EntityDetail detail) {
return Probability.getChance(12);
}
});
}
if (Probability.getChance(2)) {
damagedProcessor.add(new DeathMark());
}
if (Probability.getChance(2)) {
damagedProcessor.add(new CatacombsDamageNearby());
}
if (Probability.getChance(2)) {
damagedProcessor.add(new UndeadMinionRetaliation(Probability.getRangedRandom(23, 36)));
}
bossManager.bind(boss);
}
Aggregations