From 62072077c19ed6f7dc5e18a0dd297f5a56236e65 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Sat, 1 Aug 2015 00:47:44 -0600 Subject: [PATCH] Fixed evolution rotation --- .../arcade/game/games/evolution/EvoKit.java | 4 +- .../game/games/evolution/Evolution.java | 33 +++---- .../games/evolution/evolve/EvolveData.java | 93 ++++++++++++++----- .../games/evolution/evolve/EvolveManager.java | 5 + 4 files changed, 88 insertions(+), 47 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoKit.java index b918a37fa..45f70f190 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/EvoKit.java @@ -33,6 +33,8 @@ public abstract class EvoKit extends Kit { player.playSound(player.getLocation(), Sound.LEVEL_UP, 1.0F, 0.1F); + UtilPlayer.message(player, C.Line); + UtilPlayer.message(player, C.Line); UtilPlayer.message(player, ArcadeFormat.Line); UtilPlayer.message(player, C.Bold + "You evolved into " + ("aeiou".indexOf(GetName().toLowerCase().substring(0, 1)) == -1 ? "a " : "an ") + F.elem(C.cGreen + C.Bold + GetName()) + "!"); @@ -43,7 +45,7 @@ public abstract class EvoKit extends Kit UtilPlayer.message(player, C.Line); UtilPlayer.message(player, ArcadeFormat.Line); - } + } @Override public abstract void GiveItems(Player player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index f82f29d89..ca0a92956 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -172,6 +172,18 @@ public class Evolution extends SoloGame _evolve.tick(); } + @EventHandler + public void moveEvolve(PlayerMoveEvent event) + { + if (!IsLive()) + return; + + if (!_evolve.isEvolving(event.getPlayer())) + return; + + _evolve.getEvolve(event.getPlayer()).teleport(); + } + @Override public boolean HasKit(Player player, Kit kit) { @@ -210,16 +222,6 @@ public class Evolution extends SoloGame event.SetCancelled("Player is evolving!"); } - @EventHandler - public void onEvolveMove(PlayerMoveEvent event) - { - if (!IsLive()) - return; - - if (_evolve.isEvolving(event.getPlayer())) - event.getPlayer().teleport(event.getFrom()); - } - @EventHandler public void onEvolveAbility(EvolutionAbilityUseEvent event) { @@ -268,17 +270,6 @@ public class Evolution extends SoloGame public void endEvolve(final EvolutionPostEvolveEvent event) { event.getPlayer().teleport(GetTeam(event.getPlayer()).GetSpawn()); - - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - @Override - public void run() - { - SetKit(event.getPlayer(), GetKit(event.getPlayer()), false); - } - }, 4); - - Manager.GetCondition().GetActiveCondition(event.getPlayer(), ConditionType.CLOAK).Expire(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java index a4a7928f0..93946bf66 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java @@ -4,7 +4,9 @@ import java.util.ArrayList; import java.util.Iterator; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -12,6 +14,7 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.condition.Condition; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import nautilus.game.arcade.game.games.evolution.EvoKit; import nautilus.game.arcade.game.games.evolution.events.EvolutionBeginEvent; @@ -38,8 +41,8 @@ import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Bat; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -62,15 +65,21 @@ public class EvolveData private String _evolveTop; + private Bat _bat; + private ArrayList _rotateLocs = new ArrayList(); private Iterator _rotateIterator; - private double _radius = 3.4; + + private double _radius = 4.0; + private double _speed = 6.0; + private double _height = 2.5; public EvolveData(EvolveManager manager, Player player, EvoKit from, EvoKit to) { _manager = manager; _player = player; + _manager.Host.Manager.GetCondition().Factory().Cloak(null, _player, null, Double.MAX_VALUE, false, false); _to = to; _evolveTop = C.cWhite + "You evolved into " + ("aeiou".indexOf(_to.GetName().toLowerCase().substring(0, 1)) == -1 ? "a " : "an ") + C.cGreen + C.Bold + _to.GetName(); @@ -78,13 +87,16 @@ public class EvolveData _eFrom = spawn(from.getEntity()); setupLocs(); + setupBat(); Bukkit.getServer().getPluginManager().callEvent(new EvolutionBeginEvent(_player)); + + teleport(); } private void setupLocs() { - for (double i = 0 ; i < 50.0 ; i+= .02) + for (double i = 0 ; i < 50.0 ; i+= .03) { Location loc = _manager.getLocation().clone().add(Math.cos(i) * _radius, 3.0, Math.sin(i) * _radius); @@ -98,6 +110,23 @@ public class EvolveData _rotateIterator = _rotateLocs.iterator(); } + + private void setupBat() + { + _manager.Host.CreatureAllowOverride = true; + Bat bat = _manager.getLocation().getWorld().spawn(_rotateIterator.next(), Bat.class); + _manager.Host.CreatureAllowOverride = false; + + bat.setAwake(true); + bat.setRemoveWhenFarAway(false); + + UtilEnt.Vegetate(bat, true); + UtilEnt.ghost(bat, false, true); + + bat.setPassenger(_player); + + _bat = bat; + } //Boolean completed public boolean tick() @@ -120,6 +149,19 @@ public class EvolveData UtilTextMiddle.display(null, _evolveTop, _player); + for (ConditionType type : ConditionType.values()) + { + if (type == ConditionType.CLOAK) + continue; + + if (!_manager.Host.Manager.GetCondition().HasCondition(_player, type, null)) + continue; + + _manager.Host.Manager.GetCondition().GetActiveCondition(_player, type).Expire(); + } + + _manager.Host.SetKit(_player, _manager.Host.GetKit(_player), false); + Bukkit.getServer().getPluginManager().callEvent(new EvolutionEndEvent(_player)); } else @@ -137,43 +179,44 @@ public class EvolveData if (!UtilTime.elapsed(_endTime, 2400)) return false; - despawn(_eTo); + despawn(_eTo); + + _player.leaveVehicle(); + _bat.remove(); - for (ConditionType type : ConditionType.values()) - { - if (type == ConditionType.CLOAK) - continue; - - _manager.Host.Manager.GetCondition().EndCondition(_player, type, "Removing kit effects"); - } - - _player.setFlying(false); - _player.setAllowFlight(false); Bukkit.getServer().getPluginManager().callEvent(new EvolutionPostEvolveEvent(_player)); + + Condition cloak = _manager.Host.Manager.GetCondition().GetActiveCondition(_player, ConditionType.CLOAK); + + if (cloak != null) + cloak.Expire(); + return true; } } - private void teleport() + public void teleport() { + _player.teleport(_player.getLocation().setDirection(UtilAlg.getTrajectory(_player.getEyeLocation(), _manager.getLocation()))); + + if (_bat.isEmpty() || _bat.getPassenger() != _player) + _bat.setPassenger(_player); + if (_player.getFireTicks() > 0) _player.setFireTicks(0); - - ((CraftEntity) _player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0)); - + _player.setFallDistance(0); _player.setHealth(20.0); - _player.setAllowFlight(true); - _player.setFlying(true); ((CraftPlayer) _player).getHandle().p(0); - if (!_rotateIterator.hasNext()) - _rotateIterator = _rotateLocs.iterator(); - - _player.teleport(_rotateIterator.next()); + //Orbit + double oX = -Math.sin(_bat.getTicksLived() / _speed) * 2 * _radius; + double oZ = Math.cos(_bat.getTicksLived() / _speed) * 2 * _radius; + + UtilAction.velocity(_bat, UtilAlg.getTrajectory(_bat.getLocation(), _manager.getLocation().clone().add(oX, _height, oZ)), 0.4, false, 0, 0.1, 1, true); } - + private EntityInsentient spawn(EntityType type) { try diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveManager.java index a9fe89f2e..c015b574a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveManager.java @@ -43,6 +43,11 @@ public class EvolveManager _data.put(player.getName(), new EvolveData(this, player, from, to)); } + public EvolveData getEvolve(Player player) + { + return _data.get(player.getName()); + } + public void tick() { Iterator> iterator = _data.entrySet().iterator();