Snake update (woo)
This commit is contained in:
parent
d784a0b017
commit
36b825d36d
@ -28,6 +28,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
@ -49,7 +50,7 @@ import net.minecraft.server.v1_6_R3.Navigation;
|
||||
|
||||
public class Snake extends SoloGame
|
||||
{
|
||||
private double _maxSpeed = 120;
|
||||
private double _maxSpeed = 180;
|
||||
|
||||
private HashMap<Player, ArrayList<Creature>> _tail = new HashMap<Player, ArrayList<Creature>>();
|
||||
private HashSet<Entity> _food = new HashSet<Entity>();
|
||||
@ -58,7 +59,10 @@ public class Snake extends SoloGame
|
||||
|
||||
private HashMap<Player, Long> _invul = new HashMap<Player, Long>();
|
||||
private HashMap<Player, Long> _speed = new HashMap<Player, Long>();
|
||||
|
||||
|
||||
private HashMap<Player, Location> _move = new HashMap<Player, Location>();
|
||||
private HashMap<Player, Long> _moveTime = new HashMap<Player, Long>();
|
||||
|
||||
public Snake(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.Snake,
|
||||
@ -164,19 +168,46 @@ public class Snake extends SoloGame
|
||||
if (UtilMath.offset(loc, tail.getLocation()) > 12)
|
||||
loc = tail.getLocation().add(UtilAlg.getTrajectory(tail.getLocation(), loc).multiply(12));
|
||||
|
||||
//Move Mult
|
||||
double moveMult = 1.2;
|
||||
|
||||
//Teleport
|
||||
if (before != null)
|
||||
{
|
||||
Location tp = before.getLocation().add(UtilAlg.getTrajectory2d(before, tail).multiply(1.4));
|
||||
tp.setPitch(tail.getLocation().getPitch());
|
||||
tp.setYaw(tail.getLocation().getYaw());
|
||||
tail.teleport(tp);
|
||||
}
|
||||
|
||||
|
||||
//Move
|
||||
EntityCreature ec = ((CraftCreature)tail).getHandle();
|
||||
Navigation nav = ec.getNavigation();
|
||||
nav.a(loc.getX(), loc.getY(), loc.getZ(), (1 + 2f * mult) * moveMult);
|
||||
nav.a(loc.getX(), loc.getY(), loc.getZ(), (1 + 2f * mult) * 1);
|
||||
|
||||
//Store
|
||||
before = tail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Idle(UpdateEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
if (!_move.containsKey(player) || UtilMath.offset(player.getLocation(), _move.get(player)) > 4)
|
||||
{
|
||||
_move.put(player, player.getLocation());
|
||||
_moveTime.put(player, System.currentTimeMillis());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (UtilTime.elapsed(_moveTime.get(player), 6000))
|
||||
KillPlayer(player, null, "Idle");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Collide(UpdateEvent event)
|
||||
@ -206,7 +237,7 @@ public class Snake extends SoloGame
|
||||
|
||||
if (UtilMath.offset(player, tail) < 1.2)
|
||||
{
|
||||
KillPlayer(player, other);
|
||||
KillPlayer(player, other, null);
|
||||
|
||||
done = true;
|
||||
break;
|
||||
@ -219,7 +250,7 @@ public class Snake extends SoloGame
|
||||
}
|
||||
}
|
||||
|
||||
public void KillPlayer(Player player, Player killer)
|
||||
public void KillPlayer(Player player, Player killer, String type)
|
||||
{
|
||||
if (killer != null)
|
||||
{
|
||||
@ -228,6 +259,13 @@ public class Snake extends SoloGame
|
||||
DamageCause.CUSTOM, 500, false, true, false,
|
||||
killer.getName(), "Snake Tail");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Damage Event
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||
DamageCause.CUSTOM, 500, false, true, false,
|
||||
type, type);
|
||||
}
|
||||
|
||||
if (_tail.containsKey(player))
|
||||
{
|
||||
@ -252,6 +290,15 @@ public class Snake extends SoloGame
|
||||
|
||||
Location loc = GetTeamList().get(0).GetSpawns().get(UtilMath.r(GetTeamList().get(0).GetSpawns().size()));
|
||||
|
||||
loc.setX(-48 + UtilMath.r(97));
|
||||
loc.setZ(-48 + UtilMath.r(97));
|
||||
|
||||
if (!UtilBlock.airFoliage(loc.getBlock()))
|
||||
return;
|
||||
|
||||
if (UtilMath.offset(loc, this.GetSpectatorLocation()) > 48)
|
||||
return;
|
||||
|
||||
//Spawn
|
||||
this.CreatureAllowOverride = true;
|
||||
Slime pig = loc.getWorld().spawn(loc, Slime.class);
|
||||
@ -323,6 +370,9 @@ public class Snake extends SoloGame
|
||||
|
||||
tail.setRemoveWhenFarAway(false);
|
||||
tail.setColor(_color.get(player));
|
||||
|
||||
//Sets yaw/pitch
|
||||
tail.teleport(loc);
|
||||
|
||||
UtilEnt.Vegetate(tail);
|
||||
|
||||
@ -344,12 +394,10 @@ public class Snake extends SoloGame
|
||||
if (event.GetCause() == DamageCause.LAVA)
|
||||
{
|
||||
if (event.GetDamageePlayer() != null)
|
||||
KillPlayer(event.GetDamageePlayer(), null);
|
||||
|
||||
else
|
||||
event.AddMod("Lava", "Lava", 5000, false);
|
||||
|
||||
return;
|
||||
{
|
||||
KillPlayer(event.GetDamageePlayer(), null, "Lava");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.GetCause() != DamageCause.CUSTOM)
|
||||
|
Loading…
Reference in New Issue
Block a user