use of org.spongepowered.api.entity.explosive.PrimedTNT in project Skree by Skelril.
the class WildernessWorldWrapper method onEntitySpawn.
@Listener
public void onEntitySpawn(SpawnEntityEvent event) {
List<Entity> entities = event.getEntities();
Optional<BlockSpawnCause> optBlockCause = event.getCause().first(BlockSpawnCause.class);
for (Entity entity : entities) {
Location<World> loc = entity.getLocation();
Optional<Integer> optLevel = getLevel(loc);
if (!optLevel.isPresent())
continue;
int level = optLevel.get();
if (entity instanceof Egg && optBlockCause.isPresent()) {
PrimedTNT explosive = (PrimedTNT) entity.getLocation().getExtent().createEntity(EntityTypes.PRIMED_TNT, entity.getLocation().getPosition());
explosive.setVelocity(entity.getVelocity());
explosive.offer(Keys.FUSE_DURATION, 20 * 4);
// TODO used to have a 1/4 chance of creating fire
entity.getLocation().getExtent().spawnEntity(explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.DISPENSE).build()).build());
event.setCancelled(true);
return;
}
if (level > 1) {
// TODO move damage modification
if (entity instanceof Monster) {
HealthData healthData = ((Monster) entity).getHealthData();
double curMax = healthData.maxHealth().get();
if (curMax <= 80) {
// TODO do this a better way, but for now it prevents super mobs
double newMax = curMax * getHealthMod(level);
healthData.set(Keys.MAX_HEALTH, newMax);
healthData.set(Keys.HEALTH, newMax);
entity.offer(healthData);
}
// Wandering Bosses
Collection<String> wanderers = wanderingMobManager.getSupportedWanderersOfType(entity.getType());
for (String wanderer : wanderers) {
if (wanderingMobManager.chanceBind(wanderer, level, entity)) {
break;
}
}
}
}
Optional<Value<Integer>> optExplosiveRadius = Optional.empty();
if (optExplosiveRadius.isPresent()) {
Value<Integer> explosiveRadius = optExplosiveRadius.get();
int min = explosiveRadius.get();
entity.offer(Keys.EXPLOSION_RADIUS, Optional.of(MathExt.bound((min + level) / 2, min, entity instanceof Fireball ? 4 : 9)));
}
}
}
use of org.spongepowered.api.entity.explosive.PrimedTNT 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.explosive.PrimedTNT in project Skree by Skelril.
the class JungleRaidEffectProcessor method distributor.
private static void distributor(JungleRaidInstance inst) {
FlagEffectData data = inst.getFlagData();
boolean isSuddenDeath = inst.isSuddenDeath();
if (isSuddenDeath) {
data.amt = 100;
}
if (inst.isFlagEnabled(JungleRaidFlag.END_OF_DAYS) || inst.isFlagEnabled(JungleRaidFlag.GRENADES) || inst.isFlagEnabled(JungleRaidFlag.POTION_PLUMMET) || isSuddenDeath) {
Vector3i bvMax = inst.getRegion().getMaximumPoint();
Vector3i bvMin = inst.getRegion().getMinimumPoint();
for (int i = 0; i < Probability.getRangedRandom(data.amt / 3, data.amt); i++) {
Location<World> testLoc = new Location<>(inst.getRegion().getExtent(), Probability.getRangedRandom(bvMin.getX(), bvMax.getX()), bvMax.getY(), Probability.getRangedRandom(bvMin.getZ(), bvMax.getZ()));
if (testLoc.getBlockType() != BlockTypes.AIR)
continue;
if (inst.isFlagEnabled(JungleRaidFlag.END_OF_DAYS) || isSuddenDeath) {
PrimedTNT explosive = (PrimedTNT) inst.getRegion().getExtent().createEntity(EntityTypes.PRIMED_TNT, testLoc.getPosition());
explosive.setVelocity(new Vector3d(random.nextDouble() * 2.0 - 1, random.nextDouble() * 2 * -1, random.nextDouble() * 2.0 - 1));
explosive.offer(Keys.FUSE_DURATION, 20 * 4);
// TODO used to have a 1/4 chance of creating fire
inst.getRegion().getExtent().spawnEntity(explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
if (inst.isFlagEnabled(JungleRaidFlag.POTION_PLUMMET)) {
PotionEffectType type = Probability.pickOneOf(Sponge.getRegistry().getAllOf(PotionEffectType.class));
for (int ii = Probability.getRandom(5); ii > 0; --ii) {
ThrownPotion potion = (ThrownPotion) inst.getRegion().getExtent().createEntity(EntityTypes.SPLASH_POTION, testLoc.getPosition());
potion.setVelocity(new Vector3d(random.nextDouble() * 2.0 - 1, 0, random.nextDouble() * 2.0 - 1));
potion.offer(Keys.POTION_EFFECTS, Lists.newArrayList(PotionEffect.of(type, 1, type.isInstant() ? 1 : 20 * 10)));
inst.getRegion().getExtent().spawnEntity(potion, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
}
if (inst.isFlagEnabled(JungleRaidFlag.GRENADES)) {
new ItemDropper(testLoc).dropStacks(Lists.newArrayList(newItemStack(ItemTypes.SNOWBALL, Probability.getRandom(3))), SpawnTypes.PLUGIN);
}
}
if (data.amt < 150 && Probability.getChance(inst.isFlagEnabled(JungleRaidFlag.SUPER) ? 9 : 25))
++data.amt;
}
}
Aggregations