minor game fixes

portal method in StackerManager.java
This commit is contained in:
Chiss 2013-09-27 17:08:32 +10:00
parent 2a3d7426d5
commit 34521eef8f
5 changed files with 68 additions and 32 deletions

View File

@ -1,5 +1,6 @@
package mineplex.hub.modules; package mineplex.hub.modules;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -27,6 +28,7 @@ import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown; import mineplex.core.projectile.IThrown;
@ -44,6 +46,8 @@ public class StackerManager extends MiniPlugin implements IThrown
private HashSet<String> _disabled = new HashSet<String>(); private HashSet<String> _disabled = new HashSet<String>();
private HashSet<Entity> _tempStackShift = new HashSet<Entity>(); private HashSet<Entity> _tempStackShift = new HashSet<Entity>();
private HashMap<String, Long> _portalTime = new HashMap<String, Long>();
public StackerManager(HubManager manager) public StackerManager(HubManager manager)
{ {
super("Stacker", manager.GetPlugin()); super("Stacker", manager.GetPlugin());
@ -91,6 +95,7 @@ public class StackerManager extends MiniPlugin implements IThrown
{ {
_disabled.remove(event.getPlayer().getName()); _disabled.remove(event.getPlayer().getName());
_tempStackShift.remove(event.getPlayer()); _tempStackShift.remove(event.getPlayer());
_portalTime.remove(event.getPlayer().getName());
} }
@EventHandler @EventHandler
@ -163,13 +168,17 @@ public class StackerManager extends MiniPlugin implements IThrown
if (!Recharge.Instance.use(stacker, "Stacker", 500, true)) if (!Recharge.Instance.use(stacker, "Stacker", 500, true))
return; return;
top.setPassenger(stackee); top.setPassenger(stackee);
UtilPlayer.message(stacker, F.main("Stacker", "You stacked " + F.name(UtilEnt.getName(stackee) + "."))); UtilPlayer.message(stacker, F.main("Stacker", "You stacked " + F.name(UtilEnt.getName(stackee) + ".")));
UtilPlayer.message(stackee, F.main("Stacker", "You were stacked by " + F.name(stacker.getName() + "."))); UtilPlayer.message(stackee, F.main("Stacker", "You were stacked by " + F.name(stacker.getName() + ".")));
UtilPlayer.message(stackee, F.main("Stacker", "Push " + F.skill("Crouch") + " to escape!")); UtilPlayer.message(stackee, F.main("Stacker", "Push " + F.skill("Crouch") + " to escape!"));
//Portal Delay
SetPortalDelay(stacker);
SetPortalDelay(stackee);
event.setCancelled(true); event.setCancelled(true);
} }
@ -225,6 +234,10 @@ public class StackerManager extends MiniPlugin implements IThrown
UtilAction.velocity(throwee, thrower.getLocation().getDirection(), 1.8, false, 0, 0.3, 2, false); UtilAction.velocity(throwee, thrower.getLocation().getDirection(), 1.8, false, 0, 0.3, 2, false);
_projectileManager.AddThrow(throwee, thrower, this, -1, true, false, true, false, 2.4d); _projectileManager.AddThrow(throwee, thrower, this, -1, true, false, true, false, 2.4d);
//Portal Delay
SetPortalDelay(thrower);
SetPortalDelay(throwee);
} }
@Override @Override
@ -239,6 +252,9 @@ public class StackerManager extends MiniPlugin implements IThrown
Entity rider = target.getPassenger(); Entity rider = target.getPassenger();
while (rider != null) while (rider != null)
{ {
//Portal Delay
SetPortalDelay(rider);
rider.leaveVehicle(); rider.leaveVehicle();
rider.setVelocity(new Vector(0.25 - Math.random()/2, Math.random()/2, 0.25 - Math.random()/2)); rider.setVelocity(new Vector(0.25 - Math.random()/2, Math.random()/2, 0.25 - Math.random()/2));
rider = rider.getPassenger(); rider = rider.getPassenger();
@ -248,6 +264,9 @@ public class StackerManager extends MiniPlugin implements IThrown
//Effect //Effect
data.GetThrown().getWorld().playSound(data.GetThrown().getLocation(), Sound.HURT, 1f, 1f); data.GetThrown().getWorld().playSound(data.GetThrown().getLocation(), Sound.HURT, 1f, 1f);
//Portal Delay
SetPortalDelay(target);
} }
@Override @Override
@ -261,4 +280,23 @@ public class StackerManager extends MiniPlugin implements IThrown
{ {
} }
public void SetPortalDelay(Entity ent)
{
if (ent instanceof Player)
_portalTime.put(((Player)ent).getName(), System.currentTimeMillis());
}
public boolean CanPortal(Player player)
{
//Riding
if (player.getVehicle() != null || player.getPassenger() != null)
return false;
//Portal Delay
if (!_portalTime.containsKey(player.getName()))
return true;
return UtilTime.elapsed(_portalTime.get(player.getName()), 5000);
}
} }

View File

@ -58,7 +58,7 @@ import nautilus.game.arcade.ore.OreObsfucation;
public class Bridge extends TeamGame implements OreObsfucation public class Bridge extends TeamGame implements OreObsfucation
{ {
//Bridge Timer //Bridge Timer
private int _bridgeTime = 600000; private int _bridgeTime = 15000;
private boolean _bridgesDown = false; private boolean _bridgesDown = false;
//Wood Bridge //Wood Bridge

View File

@ -111,6 +111,9 @@ public class DragonEscape extends SoloGame
last = best; last = best;
} }
if (WorldData.MapName.contains("Hell"))
this.WorldTimeSet = 16000;
} }
@EventHandler @EventHandler
@ -165,13 +168,15 @@ public class DragonEscape extends SoloGame
if (SetScore(player, playerScore)) if (SetScore(player, playerScore))
return; return;
if (player.getLocation().getY() < 50)
player.damage(50);
if (dragonScore > playerScore) if (dragonScore > playerScore)
player.damage(50); player.damage(50);
} }
} }
public ArrayList<DragonScore> GetScores()
{
return _ranks;
}
public boolean SetScore(Player player, double playerScore) public boolean SetScore(Player player, double playerScore)
{ {

View File

@ -1,11 +1,9 @@
package nautilus.game.arcade.game.games.dragonescape; package nautilus.game.arcade.game.games.dragonescape;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EnderDragon; import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class DragonEscapeData public class DragonEscapeData
@ -13,19 +11,19 @@ public class DragonEscapeData
public DragonEscape Host; public DragonEscape Host;
public EnderDragon Dragon; public EnderDragon Dragon;
public Location Target = null; public Location Target = null;
public Location Location = null; public Location Location = null;
public float Pitch = 0; public float Pitch = 0;
public Vector Velocity = new Vector(0,0,0); public Vector Velocity = new Vector(0,0,0);
public DragonEscapeData(DragonEscape host, EnderDragon dragon, Location target) public DragonEscapeData(DragonEscape host, EnderDragon dragon, Location target)
{ {
Host = host; Host = host;
Dragon = dragon; Dragon = dragon;
Location temp = dragon.getLocation(); Location temp = dragon.getLocation();
temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(dragon.getLocation(), target))); temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(dragon.getLocation(), target)));
dragon.teleport(temp); dragon.teleport(temp);
@ -35,32 +33,27 @@ public class DragonEscapeData
Location = dragon.getLocation(); Location = dragon.getLocation();
} }
public void Move() public void Move()
{ {
Turn(); Turn();
//Distance Boost
double dist = 0;
for (Player player : Host.GetPlayers(true))
{
double offset = UtilMath.offset(Location, player.getLocation());
if (offset < dist || dist == -1)
{
dist = offset;
}
}
//Speed //Speed
double speed = 0.16; //+ (System.currentTimeMillis() - Host.GetStateTime())/2000000d; double speed = 0.16;
speed += (System.currentTimeMillis() - Host.GetStateTime())/1000d * 0.001; speed += (System.currentTimeMillis() - Host.GetStateTime())/1000d * 0.001;
if (dist > 10) //Speed Distance Boost
speed += (dist-10) * 0.001; if (!Host.GetScores().isEmpty())
{
double score = Host.GetScore(Dragon);
double best = Host.GetScores().get(0).Score;
double lead = (best-score)/10000d;
speed += lead * 0.0025;
}
Location.add(Velocity.clone().multiply(speed)); Location.add(Velocity.clone().multiply(speed));
Location.add(0, -Pitch, 0); Location.add(0, -Pitch, 0);

View File

@ -608,11 +608,11 @@ public class TurfForts extends TeamGame
if (!IsLive()) if (!IsLive())
return; return;
if (GetRedLines() == 0) if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0)
{ {
AnnounceEnd(GetTeam(ChatColor.AQUA)); AnnounceEnd(GetTeam(ChatColor.AQUA));
} }
else if (GetBlueLines() == 0) else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0)
{ {
AnnounceEnd(GetTeam(ChatColor.RED)); AnnounceEnd(GetTeam(ChatColor.RED));
} }