From 0b08e6052db71875630b1cd9824687828d5b1126 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 4 Dec 2017 00:47:18 +0000 Subject: [PATCH] Attempt to fix the fireballs fired by ghasts --- .../game/games/christmasnew/ChristmasNew.java | 2 +- .../christmasnew/section/four/MobDefense.java | 43 +++++++++++++++++-- .../christmasnew/section/four/Section4.java | 2 +- .../christmasnew/section/six/BossFight.java | 2 +- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java index 890b6c4ee..62da08cf1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java @@ -136,7 +136,7 @@ public class ChristmasNew extends ChristmasCommon int blockId = Material.STAINED_CLAY.getId(); TextAlign align = TextAlign.CENTER; - UtilBlockText.MakeText("Happy Holidays", location, face, blockId, (byte) 14, align); + UtilBlockText.MakeText("Merry Christmas", location, face, blockId, (byte) 14, align); UtilBlockText.MakeText("from", location.subtract(0, 6, 0), BlockFace.WEST, blockId, (byte) 5, align); UtilBlockText.MakeText("Mineplex", location.subtract(0, 6, 0), BlockFace.WEST, blockId, (byte) 4, align); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/MobDefense.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/MobDefense.java index 242e4c383..2c2d77d2c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/MobDefense.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/MobDefense.java @@ -10,12 +10,16 @@ import org.bukkit.entity.Blaze; import org.bukkit.entity.Creature; import org.bukkit.entity.Creeper; import org.bukkit.entity.Entity; +import org.bukkit.entity.Fireball; import org.bukkit.entity.Ghast; +import org.bukkit.entity.LargeFireball; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Projectile; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileHitEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; @@ -50,6 +54,7 @@ class MobDefense extends SectionChallenge private int _generatorHealth; private int _wave; + private Ghast _ghast; MobDefense(ChristmasNew host, Location present, Section section, List mobSpawns, Location ghastSpawn, Location generator, List healthIndicators, List particles) { @@ -63,7 +68,7 @@ class MobDefense extends SectionChallenge _particles = particles; _generatorHealth = GENERATOR_HEALTH; - _ghastSpawn.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory2d(ghastSpawn, generator))); + _ghastSpawn.setYaw(180); } @Override @@ -181,6 +186,36 @@ class MobDefense extends SectionChallenge } } + @EventHandler + public void updateGhastFire(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW || _ghast == null || !_ghast.isValid()) + { + return; + } + + Location location = _ghast.getLocation().add(0, 0.5, 0); + Fireball fireball = _ghast.launchProjectile(LargeFireball.class); + fireball.setBounce(false); + fireball.setDirection(UtilAlg.getTrajectory(location, _generator).multiply(0.5)); + } + + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + if (_ghast == null) + { + return; + } + + Projectile projectile = event.getEntity(); + + if (projectile instanceof LargeFireball && UtilMath.offsetSquared(projectile.getLocation(), _generator) < 25) + { + _generatorHealth -= 5; + } + } + @EventHandler public void updateHolograms(UpdateEvent event) { @@ -193,7 +228,7 @@ class MobDefense extends SectionChallenge _healthHolograms.forEach(hologram -> hologram.setText(text)); - _particles.forEach(location -> UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location,null, 0.1F, _wave, ViewDist.NORMAL)); + _particles.forEach(location -> UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location, null, 0.1F, _wave, ViewDist.NORMAL)); } private void spawnMob(Class clazz, int amount, int players) @@ -209,9 +244,9 @@ class MobDefense extends SectionChallenge public void spawnGhast() { - Ghast ghast = spawn(_ghastSpawn, Ghast.class); + _ghast = spawn(_ghastSpawn, Ghast.class); - UtilEnt.vegetate(ghast); + UtilEnt.vegetate(_ghast); } public void setWave(int wave) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/Section4.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/Section4.java index be7ad7eda..c56955ace 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/Section4.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/four/Section4.java @@ -80,7 +80,7 @@ public class Section4 extends Section @EventHandler public void updateWaves(UpdateEvent event) { - if (event.getType() != UpdateType.SEC || _start == 0) + if (event.getType() != UpdateType.SEC || _start == 0 || !_host.IsLive()) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/six/BossFight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/six/BossFight.java index e1cc29dce..7f6b01c93 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/six/BossFight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/section/six/BossFight.java @@ -37,7 +37,7 @@ class BossFight extends SectionChallenge { private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); - private static final int TIME_OF_DAY = 11000; + private static final int TIME_OF_DAY = 12000; private final Location _bossSpawn; private final List _lightning;