Removed the revolving thing.

This commit is contained in:
Mysticate 2015-08-08 16:13:54 -04:00
parent 858e57bb0d
commit 5298fa341e
7 changed files with 172 additions and 124 deletions

View File

@ -14,6 +14,11 @@ public class PacketPlayOutCamera extends Packet
{
}
public PacketPlayOutCamera(int id)
{
a = id;
}
public PacketPlayOutCamera(Entity paramEntity)
{
this.a = paramEntity.getEntityId();

View File

@ -2,16 +2,19 @@ package nautilus.game.arcade.game.games.evolution;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.ConditionActive;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.condition.ConditionActive;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
@ -42,7 +45,7 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
public class Evolution extends SoloGame
{
@ -52,7 +55,8 @@ public class Evolution extends SoloGame
private NautHashMap<String, EvoToken> _tokens = new NautHashMap<String, EvoToken>();
private ArrayList<Location> _evoPlatforms = new ArrayList<Location>();
//Platform location, viewing location.
private NautHashMap<Location, Location> _evoPlatforms = new NautHashMap<Location, Location>();
public Evolution(ArcadeManager manager)
{
@ -121,12 +125,36 @@ public class Evolution extends SoloGame
@Override
public void ParseData()
{
for (Location loc : WorldData.GetDataLocs("RED"))
for (Location platform : WorldData.GetDataLocs("RED"))
{
loc.getBlock().setType(Material.AIR);
_evoPlatforms.add(loc);
platform.getBlock().setType(Material.AIR);
Iterator<Location> green = WorldData.GetDataLocs("GREEN").iterator();
while (green.hasNext())
{
Location viewing = green.next();
viewing.getBlock().setType(Material.AIR);
if (UtilMath.offset2d(platform, viewing) > 8.0)
continue;
green.remove();
_evoPlatforms.put(platform, loadAngle(platform, viewing));
break;
}
}
}
private Location loadAngle(Location platform, Location viewing)
{
Vector b = UtilAlg.getTrajectory(viewing, platform).normalize();
viewing.setPitch(UtilAlg.GetPitch(b));
viewing.setYaw(UtilAlg.GetYaw(b));
return viewing;
}
//Double Kit
@EventHandler(priority = EventPriority.MONITOR)
@ -139,14 +167,14 @@ public class Evolution extends SoloGame
{
_tokens.put(player.getName(), new EvoToken(player));
upgradeKit(player, false);
upgradeKit(player, true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void endNoEvolve(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
if (event.GetState() != GameState.Prepare)
return;
if (_evoPlatforms.size() <= 0)
@ -156,7 +184,7 @@ public class Evolution extends SoloGame
return;
}
_evolve = new EvolveManager(this, _evoPlatforms.get(0));
_evolve = new EvolveManager(this, _evoPlatforms);
}
@EventHandler
@ -171,25 +199,13 @@ 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(false);
}
@Override
public boolean HasKit(Player player, Kit kit)
{
if (GetKit(player) == null)
return false;
if (GetKit(player) == (kit))
if (GetKit(player) == kit)
return true;
return false;
@ -255,6 +271,9 @@ public class Evolution extends SoloGame
public void startEvolve(EvolutionBeginEvent event)
{
Recharge.Instance.Get(event.getPlayer()).clear();
event.getPlayer().teleport(GetTeam(event.getPlayer()).GetSpawn());
Manager.GetCondition().Factory().Cloak("Evolving", event.getPlayer(), null, 10, true, true);
}
@EventHandler
@ -330,9 +349,6 @@ public class Evolution extends SoloGame
End();
return;
}
killer.teleport(GetTeam(killer).GetSpawn());
Manager.GetCondition().Factory().Cloak("Evolving", killer, null, 10, true, true);
}
//Boolean ending
@ -397,6 +413,7 @@ public class Evolution extends SoloGame
if (player.isOnline())
AddGems(player, 10, "Participation", false, false);
_evolve.end();
SetState(GameState.End);
AnnounceEnd(players);
}

View File

@ -1,10 +1,6 @@
package nautilus.game.arcade.game.games.evolution.evolve;
import java.lang.reflect.Method;
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;
@ -18,7 +14,6 @@ import nautilus.game.arcade.game.games.evolution.EvoKit;
import nautilus.game.arcade.game.games.evolution.events.EvolutionBeginEvent;
import nautilus.game.arcade.game.games.evolution.events.EvolutionEndEvent;
import nautilus.game.arcade.game.games.evolution.events.EvolutionPostEvolveEvent;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.EntityBlaze;
import net.minecraft.server.v1_7_R4.EntityChicken;
import net.minecraft.server.v1_7_R4.EntityCreeper;
@ -40,62 +35,70 @@ 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.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftZombie;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie;
import org.bukkit.util.Vector;
public class EvolveData
{
private boolean _ended = false;
private final long _timestamp = System.currentTimeMillis();
private long _endTime = System.currentTimeMillis();
private final EvolveManager _manager;
private final PlatformToken _token;
private boolean _active = true;
private final Player _player;
private final EvoKit _to;
private String _evolveTop;
private final EntityInsentient _eFrom;
private EntityInsentient _eTo;
private String _evolveTop;
private Zombie _zombie;
private int _ticks = 0;
public EvolveData(EvolveManager manager, Player player, EvoKit from, EvoKit to)
public EvolveData(EvolveManager manager, PlatformToken token, Player player, EvoKit from, EvoKit to)
{
_manager = manager;
_token = token;
_player = player;
_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();
_eFrom = spawn(from.getEntity());
_eFrom = spawn(from.getEntity(), token.Platform, false);
setupZombie();
_zombie = setupZombie();
Bukkit.getServer().getPluginManager().callEvent(new EvolutionBeginEvent(_player));
Bukkit.getScheduler().scheduleSyncDelayedTask(_manager.Host.Manager.getPlugin(), new Runnable()
{
@Override
public void run()
{
setupPlayer();
}
}, 2);
}
private void setupZombie()
private Zombie setupZombie()
{
_manager.Host.CreatureAllowOverride = true;
Zombie zombie = _manager.getLocation().getWorld().spawn(_manager.getLocation(), Zombie.class);
Zombie zombie = _token.Viewing.getWorld().spawn(_token.Viewing, Zombie.class);
_manager.Host.CreatureAllowOverride = false;
UtilEnt.Vegetate(zombie, true);
UtilEnt.ghost(zombie, false, true);
UtilEnt.ghost(zombie, true, true);
_zombie = zombie;
zombie.teleport(_token.Viewing);
return zombie;
}
private void setupPlayer()
@ -105,30 +108,40 @@ public class EvolveData
UtilPlayer.sendPacket(_player, packet);
}
private void endPlayer()
{
//Stop spectating
PacketPlayOutCamera packet = new PacketPlayOutCamera(_player);
UtilPlayer.sendPacket(_player, packet);
}
//Boolean completed
public boolean tick()
{
_ticks++;
teleport(false);
//Failsafe
if (_ended)
{
return true;
}
//Hasn't ended yet
if (_active)
{
handleAnimation(_eFrom);
//If 2 seconds past
if (UtilTime.elapsed(_timestamp, 2400))
{
_active = false;
_endTime = System.currentTimeMillis();
_eTo = spawn(_to.getEntity());
_eTo = spawn(_to.getEntity(), _token.Platform, false);
despawn(_eFrom);
UtilFirework.playFirework(_manager.getLocation().clone().add(0.0, 1.5, 0.0), Type.BALL, Color.GREEN, false, false);
UtilFirework.playFirework(_token.Platform.clone().add(0.0, 1.5, 0.0), Type.BALL, Color.GREEN, false, false);
UtilTextMiddle.display(null, _evolveTop, _player);
_manager.Host.SetKit(_player, _manager.Host.GetKit(_player), false);
Bukkit.getServer().getPluginManager().callEvent(new EvolutionEndEvent(_player));
}
else
@ -136,21 +149,21 @@ public class EvolveData
//Play particles
if (UtilTime.elapsed(_timestamp, 500))
{
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, new Location(_eFrom.world.getWorld(), _eFrom.locX, _eFrom.locY + 1.0, _eFrom.locZ), 0.5F, 1.0F, 0.5F, 0, 5, ViewDist.SHORT, _player);
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, _token.Platform.clone().add(0.0, 1.0, 0.0), 0.5F, 1.0F, 0.5F, 0, 5, ViewDist.SHORT, _player);
}
}
return false;
}
else
{
handleAnimation(_eTo);
if (!UtilTime.elapsed(_endTime, 2400))
return false;
despawn(_eTo);
//Stop spectating
PacketPlayOutCamera packet = new PacketPlayOutCamera(_player);
UtilPlayer.sendPacket(_player, packet);
endPlayer();
_zombie.remove();
@ -159,66 +172,40 @@ public class EvolveData
}
}
public void teleport(boolean teleport)
//Force end. (Game ended)
public void end()
{
if (_player.getFireTicks() > 0)
_player.setFireTicks(0);
_active = false;
_player.setFallDistance(0);
_player.setHealth(20.0);
if (_eFrom != null)
despawn(_eFrom);
((CraftPlayer) _player).getHandle().p(0);
if (_eTo != null)
despawn(_eTo);
double sizeMod = 3.5;
double speed = 15d;
double oX = -Math.sin(_ticks/speed) * 2 * sizeMod;
double oY = 3;
double oZ = Math.cos(_ticks/speed) * 2 * sizeMod;
endPlayer();
if (teleport)
_zombie.remove();
_ended = true;
}
private void handleAnimation(EntityInsentient entity)
{
_zombie.teleport(_manager.getLocation().clone().add(oX, oY, oZ));
setupPlayer();
}
else
{
UtilAction.velocity(_zombie,
UtilAlg.getTrajectory(_zombie.getLocation(), _manager.getLocation().clone().add(oX, oY, oZ)),
0.4, false, 0, 0.0, 0.0, false);
// float yaw = entity.yaw;
// yaw += 2;
//
// _token.Platform.setYaw(yaw);
// entity.setLocation(_token.Platform.getX(), _token.Platform.getY(), _token.Platform.getZ(), yaw, entity.pitch);
}
EntityZombie eB = ((CraftZombie) _zombie).getHandle();
Vector to = UtilAlg.getTrajectory(_zombie.getEyeLocation(), _manager.getLocation()).normalize();
try
{
float pitch = UtilAlg.GetPitch(to);
float yaw = UtilAlg.GetYaw(to);
eB.lastYaw = yaw;
eB.yaw = yaw;
eB.lastPitch = pitch;
eB.pitch = pitch;
Method method = Entity.class.getDeclaredMethod("b", float.class, float.class);
method.setAccessible(true);
method.invoke(eB, yaw, pitch);
method.setAccessible(false);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
private EntityInsentient spawn(EntityType type)
private EntityInsentient spawn(EntityType type, Location loc, boolean invisible)
{
try
{
EntityInsentient entity = getEntity(type).getConstructor(World.class).newInstance(((CraftWorld) _manager.getLocation().getWorld()).getHandle());
entity.setLocation(_manager.getLocation().getX(), _manager.getLocation().getY(), _manager.getLocation().getZ(), 0.0F, 0.0F);
EntityInsentient entity = getEntity(type).getConstructor(World.class).newInstance(((CraftWorld) loc.getWorld()).getHandle());
entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(entity);
entity.setCustomNameVisible(false);
@ -227,6 +214,13 @@ public class EvolveData
((EntitySlime) entity).setSize(3);
}
if (invisible)
{
entity.Invisible = true;
}
entity.ghost = true;
UtilPlayer.sendPacket(_player, packet);
return entity;
}

View File

@ -1,9 +1,11 @@
package nautilus.game.arcade.game.games.evolution.evolve;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map.Entry;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.evolution.EvoKit;
import nautilus.game.arcade.game.games.evolution.Evolution;
@ -15,19 +17,22 @@ public class EvolveManager
{
public final Evolution Host;
private final Location _evolveLoc;
private final NautHashMap<Location, Location> _evolveLocs;
private NautHashMap<String, EvolveData> _data = new NautHashMap<String, EvolveData>();
public EvolveManager(Evolution evolution, Location evolveLoc)
public EvolveManager(Evolution evolution, NautHashMap<Location, Location> evolveLocs)
{
Host = evolution;
_evolveLoc = evolveLoc;
_evolveLocs = evolveLocs;
}
public Location getLocation()
private PlatformToken getLocation()
{
return _evolveLoc;
ArrayList<Entry<Location, Location>> locs = new ArrayList<Entry<Location, Location>>(_evolveLocs.entrySet());
Entry<Location, Location> entry = locs.get(UtilMath.r(locs.size()));
return new PlatformToken(entry.getKey(), entry.getValue());
}
public boolean isEvolving(Player player)
@ -40,7 +45,7 @@ public class EvolveManager
if (_data.containsKey(player.getName()))
return;
_data.put(player.getName(), new EvolveData(this, player, from, to));
_data.put(player.getName(), new EvolveData(this, getLocation(), player, from, to));
}
public EvolveData getEvolve(Player player)
@ -76,4 +81,12 @@ public class EvolveManager
}
}
}
public void end()
{
for (EvolveData data : _data.values())
{
data.end();
}
}
}

View File

@ -0,0 +1,20 @@
package nautilus.game.arcade.game.games.evolution.evolve;
import org.bukkit.Location;
public class PlatformToken
{
/**
* @author Mysticate
* August 8, 2015
*/
public final Location Platform;
public final Location Viewing;
public PlatformToken(Location platform, Location viewing)
{
Platform = platform.clone();
Viewing = viewing.clone();
}
}

View File

@ -27,7 +27,6 @@ public class KitCreeper extends EvoKit
{
new PerkSulphurBombEVO()
}, EntityType.CREEPER);
}
@Override

View File

@ -50,7 +50,7 @@ public class PerkSulphurBombEVO extends Perk implements IThrown
if (!UtilEvent.isAction(event, ActionType.R))
return;
if (!UtilInv.IsItem(event.getItem(), Material.DIAMOND_AXE, (byte) 0))
if (!UtilInv.IsItem(event.getItem(), Material.IRON_AXE, (byte) 0))
return;
Player player = event.getPlayer();