Fixed jump system

This commit is contained in:
Mysticate 2015-09-30 20:28:35 -04:00
parent c39806a4e3
commit 05b735ba40
3 changed files with 67 additions and 7 deletions

View File

@ -307,7 +307,6 @@ public class Maze implements Listener
continue;
Recharge.Instance.useForce(player, "Monster Hit", 1000);
Recharge.Instance.useForce(player, "Monster Launch", 2100);
//Velocity
//UtilAction.velocity(player, new Vector(1,0,0), 4, false, 0, 1.2, 1.2, true);

View File

@ -1,11 +1,15 @@
package nautilus.game.arcade.game.games.monstermaze;
import java.util.HashMap;
import java.util.Iterator;
import java.util.regex.Pattern;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
@ -18,6 +22,7 @@ import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.monstermaze.MMMazes.MazePreset;
import nautilus.game.arcade.game.games.monstermaze.MazeBlockData.MazeBlock;
import nautilus.game.arcade.game.games.monstermaze.events.AbilityUseEvent;
import nautilus.game.arcade.game.games.monstermaze.events.MonsterBumpPlayerEvent;
import nautilus.game.arcade.game.games.monstermaze.kits.KitJumper;
import nautilus.game.arcade.game.games.monstermaze.kits.KitRepulsor;
import nautilus.game.arcade.game.games.monstermaze.trackers.AbilityUseTracker;
@ -49,6 +54,8 @@ public class MonsterMaze extends SoloGame
private Location _center;
private HashMap<Player, Long> _launched = new HashMap<Player, Long>();
@SuppressWarnings("unchecked")
public MonsterMaze(ArcadeManager manager)
{
@ -205,7 +212,7 @@ public class MonsterMaze extends SoloGame
for (Player p : GetPlayers(true))
{
if (!UtilInv.contains(p, "Jumps Remaining", Material.FEATHER, (byte) 0, 1) || p.getLocation().getY()-_center.getY() <= 0 || !Recharge.Instance.usable(p, "MM Player Jump") || !Recharge.Instance.usable(p, "Monster Launch"))
if (!UtilInv.contains(p, "Jumps Remaining", Material.FEATHER, (byte) 0, 1) || p.getLocation().getY()-_center.getY() <= 0 || !Recharge.Instance.usable(p, "MM Player Jump") || isLaunched(p))
continue;
setJumpsLeft(p, p.getInventory().getItem(8).getAmount() - 1);
@ -268,6 +275,64 @@ public class MonsterMaze extends SoloGame
return _monsterType;
}
@EventHandler
public void onPlayerBump(MonsterBumpPlayerEvent event)
{
if (!IsLive())
return;
_launched.put(event.getPlayer(), System.currentTimeMillis());
}
@EventHandler
public void tickBumps(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!IsLive())
return;
HashMap<Player, Long> copy = new HashMap<Player, Long>();
copy.putAll(_launched);
for (Iterator<Player> iterator = copy.keySet().iterator() ; iterator.hasNext() ;)
{
Player player = iterator.next();
if (player == null || !player.isOnline())
{
_launched.remove(player);
continue;
}
if (UtilEnt.isGrounded(player) && UtilTime.elapsed(copy.get(player), 250))
{
_launched.remove(player);
continue;
}
//If there are blocks surrounding the block it's on top of (if it's on the side of a block)
if (player.getLocation().getY() == player.getLocation().getBlockY() && !UtilBlock.getInBoundingBox(player.getLocation().clone().add(1, -1, 1), player.getLocation().clone().subtract(1, 1, 1), true).isEmpty() && UtilTime.elapsed(copy.get(player), 250))
{
_launched.remove(player);
continue;
}
//Time out
if (UtilTime.elapsed(copy.get(player), 3000))
{
_launched.remove(player);
continue;
}
}
}
public boolean isLaunched(Player player)
{
return _launched.containsKey(player);
}
@EventHandler
public void onRegain(EntityRegainHealthEvent event)
{

View File

@ -69,14 +69,10 @@ public class PilotTracker extends StatTracker<MonsterMaze>
if (UtilEnt.isGrounded(player))
{
System.out.println("LAUNCHED PLAYER IS ON THE GROUND");
_launched.remove(player);
if (getGame().getMaze().isOnPad(player))
{
System.out.println("LAUNCHED PLAYER IS ON THE SAFE PAD");
addStat(player);
}