Gravity Update

This commit is contained in:
Chiss 2014-01-21 11:28:12 +11:00
parent 75669e2333
commit 7bbfdd1a42
11 changed files with 750 additions and 169 deletions

View File

@ -2,7 +2,7 @@ package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_6_R3.Packet;
public class DisguiseBat extends DisguiseAmbient
public class DisguiseBat extends DisguiseAnimal
{
public DisguiseBat(org.bukkit.entity.Entity entity)
{
@ -10,23 +10,13 @@ public class DisguiseBat extends DisguiseAmbient
}
@Override
public Packet GetSpawnPacket()
protected int GetEntityTypeId()
{
return null;
return 65;
}
public String getHurtSound()
{
return "mob.bat.hurt";
}
protected float getVolume()
{
return 0.1F;
}
protected float getPitch()
{
return super.getPitch() * 0.95F;
}
}
}

View File

@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
@ -97,6 +98,12 @@ public abstract class Game implements Listener
//Loaded from Map Config
public WorldData WorldData = null;
//Game Help
private long _helpTimer = 0;
private int _helpIndex = 0;
private ChatColor _helpColor = ChatColor.YELLOW;
protected String[] _help;
//Gameplay Flags
public boolean Damage = true;
@ -970,4 +977,31 @@ public abstract class Game implements Listener
{
return true;
}
@EventHandler
public void HelpUpdate(UpdateEvent event)
{
if (_help == null || _help.length == 0)
return;
if (event.getType() != UpdateType.SEC)
return;
if (this.GetState() != GameState.Recruit)
return;
if (!UtilTime.elapsed(_helpTimer, 8000))
return;
if (_helpColor == ChatColor.YELLOW)
_helpColor = ChatColor.GREEN;
else
_helpColor = ChatColor.YELLOW;
_helpTimer = System.currentTimeMillis();
Announce(C.cWhite + C.Bold + "TIP " + ChatColor.RESET + _helpColor + _help[_helpIndex]);
_helpIndex = (_helpIndex + 1)%_help.length;
}
}

View File

@ -1,20 +1,32 @@
package nautilus.game.arcade.game.games.gravity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftFallingSand;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
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;
@ -24,33 +36,54 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.gravity.kits.*;
import nautilus.game.arcade.game.games.gravity.objects.GravityBomb;
import nautilus.game.arcade.game.games.gravity.objects.GravityDebris;
import nautilus.game.arcade.game.games.gravity.objects.GravityHook;
import nautilus.game.arcade.game.games.gravity.objects.GravityPlayer;
import nautilus.game.arcade.kit.Kit;
public class Gravity extends SoloGame
{
//Contains ALL Objects
private ArrayList<GravityObject> _objects = new ArrayList<GravityObject>();
//Player Hooks
private HashMap<Player, GravityHook> _hooks = new HashMap<Player, GravityHook>();
public Gravity(ArcadeManager manager)
{
super(manager, GameType.Gravity,
new Kit[]
{
new KitPlayer(manager)
new KitJetpack(manager)
},
new String[]
{
"Knock other players into space",
"You auto-grab onto nearby blocks",
C.cGreen + "Push Drop" + C.cGray + " to kick off blocks",
C.cGreen + "Left-Click" + C.cGray + " to use " + F.skill("Block Cannon"),
C.cGreen + "Right-Click" + C.cGray + " to use " + F.skill("Jetpack"),
"Food is Oxygen. Restore it at Emerald Blocks.",
"Last player alive wins!"
});
_help = new String[]
{
"Push DROP to launch yourself off platforms.",
"You automatically grab onto nearby platforms.",
"Hold Block to use your Jetpack",
"Your Experience Bar is your Jetpack Fuel",
"Your Hunger is your Oxygen Level",
"Restore Oxygen at the Emerald Blocks",
};
this.DamagePvP = false;
this.HungerSet = 20;
this.WorldTimeSet = 18000;
this.WorldTimeSet = 22;
this.CompassEnabled = true;
}
@EventHandler
@ -58,29 +91,47 @@ public class Gravity extends SoloGame
{
if (event.GetState() != GameState.Prepare)
return;
for (Player player : GetPlayers(true))
{
_objects.add(new GravityObject(this, player, 60, null));
GravityPlayer obj = new GravityPlayer(this, player, 60, null);
_objects.add(obj);
player.setExp(0.9999f);
}
}
@EventHandler
public void KickOff(PlayerDropItemEvent event)
{
for (GravityObject object : _objects)
object.KickOff(event.getPlayer());
if (object instanceof GravityPlayer)
((GravityPlayer)object).KickOff(event.getPlayer());
event.setCancelled(true);
}
@EventHandler
public void Jetpack(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
for (GravityObject object : _objects)
if (object instanceof GravityPlayer)
((GravityPlayer)object).Jetpack();
}
@EventHandler
public void Shoot(PlayerInteractEvent event)
{
if (event.isCancelled())
return;
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
@ -89,79 +140,279 @@ public class Gravity extends SoloGame
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("SHEARS"))
if (!event.getPlayer().getItemInHand().getType().toString().contains("IRON_SWORD"))
return;
Player player = event.getPlayer();
if (!Recharge.Instance.use(player, "Block Cannon", 2000, true))
if (!Recharge.Instance.use(player, "Block Cannon", 1200, true))
return;
Vector velocity = new Vector(0,0,0);
for (GravityObject object : _objects)
if (object.Ent.equals(player))
velocity = object.Vel.clone();
//velocity.add(player.getLocation().getDirection().multiply(1.2));
velocity = player.getLocation().getDirection().multiply(1.2);
//Projectile
Vector velocity = player.getLocation().getDirection().multiply(1.2);
FallingBlock projectile = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection().multiply(2)), Material.SKULL, (byte)0);
_objects.add(new GravityObject(this, projectile, 20, velocity));
_objects.add(new GravityBomb(this, projectile, 12, velocity));
//Sound
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.25f);
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.25f);
}
@EventHandler
public void Jetpack(UpdateEvent event)
public void HookFire(PlayerInteractEvent event)
{
if (event.isCancelled())
return;
if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (event.getPlayer().getItemInHand() == null)
return;
if (event.getPlayer().getItemInHand().getType() != Material.DIAMOND_SWORD)
return;
Player player = event.getPlayer();
GravityObject old = _hooks.remove(player);
if (old != null)
{
old.Clean();
_objects.remove(old);
//Inform
UtilPlayer.message(player, F.main("Skill", "You detatched from your " + F.skill("Grappling Hook") + "."));
//Sound
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_METAL, 0.75f, 2f);
return;
}
if (!Recharge.Instance.use(player, "Hookshot", 12000, true))
return;
//Projectile
Vector velocity = player.getLocation().getDirection().multiply(0.4);
this.CreatureAllowOverride = true;
Slime slime = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection().multiply(2)), Slime.class);
this.CreatureAllowOverride = false;
slime.setSize(1);
UtilEnt.Vegetate(slime, true);
UtilEnt.ghost(slime, true, false);
GravityHook hook = new GravityHook(this, slime, 4, velocity);
UtilEnt.Leash(hook.Base, player, false, false);
_hooks.put(player, hook);
_objects.add(hook);
//Inform
UtilPlayer.message(player, F.main("Skill", "You launched a " + F.skill("Grappling Hook") + "."));
//Sound
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_METAL, 0.75f, 1.5f);
}
@EventHandler
public void HookUpdate(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
for (GravityObject object : _objects)
object.Jetpack();
Iterator<Player> hookIterator = _hooks.keySet().iterator();
while (hookIterator.hasNext())
{
Player player = hookIterator.next();
GravityObject obj = _hooks.get(player);
if (!player.isValid() || !obj.Ent.isValid())
{
obj.Clean();
hookIterator.remove();
continue;
}
//Dont Disappear
if (obj.Ent instanceof FallingBlock)
((CraftFallingSand)obj.Ent).getHandle().c = 1;
HashMap<Block, Double> blocks = UtilBlock.getInRadius(obj.Ent.getLocation(), 1.2);
double bestDist = 0;
Block bestBlock = null;
for (Block block : blocks.keySet())
{
if (UtilBlock.airFoliage(block))
continue;
double dist = blocks.get(block);
if (bestBlock == null || dist > bestDist)
{
bestBlock = block;
bestDist = dist;
}
}
if (bestBlock == null)
{
//Too Far
if (UtilMath.offset(player, obj.Ent) > 16)
{
obj.Clean();
hookIterator.remove();
//Inform
UtilPlayer.message(player, F.main("Skill", "Your " + F.skill("Grappling Hook") + " missed."));
}
continue;
}
//Reel In
if (player.isBlocking() && player.getItemInHand().getType() == Material.DIAMOND_SWORD)
{
for (GravityObject object : _objects)
if (object instanceof GravityPlayer)
{
GravityPlayer pObj = (GravityPlayer)object;
if (pObj.Ent.equals(player))
{
pObj.AddVelocity(UtilAlg.getTrajectory(player, obj.Ent).multiply(0.03), 0.6);
//Sound
player.getWorld().playSound(player.getLocation(), Sound.NOTE_STICKS, 0.3f, 2f);
}
}
}
else if (UtilMath.offset(player, obj.Ent) > 16)
{
double power = (double)(UtilMath.offset(player, obj.Ent) - 16) / 200d;
for (GravityObject object : _objects)
if (object instanceof GravityPlayer)
{
GravityPlayer pObj = (GravityPlayer)object;
if (pObj.Ent.equals(player))
{
pObj.AddVelocity(UtilAlg.getTrajectory(player, obj.Ent).multiply(power), 0.6);
//Sound
player.getWorld().playSound(player.getLocation(), Sound.NOTE_STICKS, 0.3f, 0.6f - (float)power);
}
}
}
_objects.remove(obj);
obj.Base.setVelocity(new Vector(0,0,0));
}
}
@EventHandler
public void ObjectUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!InProgress() && GetState() != GameState.End)
return;
//Movement + Invalid
Iterator<GravityObject> objectIterator = _objects.iterator();
while (objectIterator.hasNext())
{
GravityObject obj = objectIterator.next();
obj.Update();
if (!obj.Update())
{
obj.Clean();
objectIterator.remove();
}
}
//AutoGrab
for (GravityObject a : _objects)
a.AutoGrab();
//Player AutoGrab
for (GravityObject object : _objects)
if (object instanceof GravityPlayer)
((GravityPlayer)object).AutoGrab();
//Collision
for (GravityObject a : _objects)
for (GravityObject b : _objects)
a.Collide(b);
//Bomb Detonate
HashSet<GravityDebris> newDebris = new HashSet<GravityDebris>();
objectIterator = _objects.iterator();
while (objectIterator.hasNext())
{
GravityObject obj = objectIterator.next();
if (!(obj instanceof GravityBomb))
continue;
HashSet<GravityDebris> debris = ((GravityBomb)obj).DetonateCheck();
if (!debris.isEmpty())
{
newDebris.addAll(debris);
objectIterator.remove();
obj.CustomCollide();
obj.Clean();
}
}
_objects.addAll(newDebris);
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (event.GetCause() != DamageCause.CUSTOM && event.GetCause() != DamageCause.VOID)
event.SetCancelled("No Damage");
}
@EventHandler
public void FallingBlockLand(EntityChangeBlockEvent event)
{
if (event.getEntity() instanceof FallingBlock)
{
event.setCancelled(true);
event.getEntity().remove();
}
}
@EventHandler
public void FallDamage(CustomDamageEvent event)
public void OxygenSuffocate(UpdateEvent event)
{
if (event.GetCause() == DamageCause.FALL || event.GetCause() == DamageCause.SUFFOCATION)
event.SetCancelled("Fall");
if (event.getType() != UpdateType.SEC)
return;
if (!IsLive())
return;
for (GravityObject object : _objects)
if (object instanceof GravityPlayer)
((GravityPlayer)object).Oxygen();
}
}

View File

@ -1,40 +1,44 @@
package nautilus.game.arcade.game.games.gravity;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.disguise.disguises.DisguiseBat;
import mineplex.core.disguise.disguises.DisguiseChicken;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftFallingSand;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Zombie;
import org.bukkit.util.Vector;
public class GravityObject
public abstract class GravityObject
{
public Gravity Host;
public Entity Ent;
public double Mass;
public double Size;
public Vector Vel;
public Chicken Base;
public Zombie Base;
public long GrabDelay = 0;
public long CollideDelay;
public GravityObject(Gravity host, Entity ent, double mass, Vector vel)
public GravityObject(Gravity host, Entity ent, double mass, double size, Vector vel)
{
Host = host;
Ent = ent;
Mass = mass;
Size = size;
CollideDelay = System.currentTimeMillis() + 100;
@ -44,12 +48,17 @@ public class GravityObject
Vel = new Vector(0,0,0);
Host.CreatureAllowOverride = true;
Base = ent.getWorld().spawn(ent.getLocation().subtract(0, 0, 0), Chicken.class);
Base = ent.getWorld().spawn(ent.getLocation().subtract(0, 0, 0), Zombie.class);
Host.CreatureAllowOverride = false;
Base.setMaxHealth(60);
Base.setHealth(60);
Base.setBaby();
DisguiseBat disguise = new DisguiseBat(Base);
//disguise.setBaby();
Host.Manager.GetDisguise().disguise(disguise);
UtilEnt.Vegetate(Base);
UtilEnt.Vegetate(Base, true);
UtilEnt.ghost(Base, true, true);
}
@ -71,13 +80,27 @@ public class GravityObject
return false;
if (Ent.getVehicle() == null)
{
Base.setPassenger(Ent);
UtilPlayer.message(Ent, "Attaching to Space Suit");
}
Base.setVelocity(Vel);
//Effect
if (Vel.length() > 0)
{
if (IsPlayer())
{
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, Ent.getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1);
}
else if (Ent instanceof FallingBlock)
{
UtilParticle.PlayParticle(ParticleType.RED_DUST, Ent.getLocation().add(0, -0.1, 0), 0, 0, 0, 0, 1);
}
else if (Ent instanceof Slime)
{
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, Ent.getLocation().add(0, 0.1, 0), 0, 0, 0, 0, 1);
}
}
return true;
}
@ -91,8 +114,15 @@ public class GravityObject
if (System.currentTimeMillis() < other.CollideDelay)
return;
if (this.Vel.length() == 0 && other.Vel.length() == 0)
return;
double size = this.Size;
if (other.Size > size)
size = other.Size;
if (UtilMath.offset(this.Base, other.Base) > 2)
if (UtilMath.offset(this.Base, other.Base) > size)
return;
Vector v1 = Vel;
@ -107,11 +137,11 @@ public class GravityObject
//Sound
double power = v1.clone().multiply(this.Mass).subtract(v2.clone().multiply(other.Mass)).length();
Host.Announce("Collision Power: " + power);
this.Ent.getWorld().playSound(this.Ent.getLocation(), Sound.ZOMBIE_WOOD, 1f, 1f);
other.Ent.getWorld().playSound(other.Ent.getLocation(), Sound.ZOMBIE_WOOD, 1f, 1f);
//Host.Announce("Collision Power: " + power);
this.PlayCollideSound(power);
other.PlayCollideSound(power);
//Delay
this.CollideDelay = System.currentTimeMillis() + 1000;
other.CollideDelay = System.currentTimeMillis() + 1000;
@ -119,94 +149,21 @@ public class GravityObject
this.GrabDelay = System.currentTimeMillis();
other.GrabDelay = System.currentTimeMillis();
//Inform
Host.Announce(UtilEnt.getName(this.Ent) + " collided with " + UtilEnt.getName(other.Ent) + " with Power: " + power);
}
public boolean NearBlock()
{
for (Block block : UtilBlock.getSurrounding(Base.getLocation().getBlock(), true))
{
if (UtilBlock.airFoliage(block))
continue;
if (UtilMath.offset(block.getLocation().add(0.5, 0.5, 0.5), Base.getLocation()) < 1.6)
return true;
}
for (Block block : UtilBlock.getSurrounding(Base.getLocation().getBlock().getRelative(BlockFace.UP), true))
{
if (UtilBlock.airFoliage(block))
continue;
if (UtilMath.offset(block.getLocation().add(0.5, 0.5, 0.5), Base.getLocation().add(0, 1, 0)) < 1.6)
return true;
}
for (Block block : UtilBlock.getSurrounding(Base.getLocation().getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP), true))
{
if (UtilBlock.airFoliage(block))
continue;
if (UtilMath.offset(block.getLocation().add(0.5, 0.5, 0.5), Base.getLocation().add(0, 2, 0)) < 1.6)
return true;
}
return false;
//Collide
this.CustomCollide();
other.CustomCollide();
}
public void AutoGrab()
public void CustomCollide()
{
if (!IsPlayer())
return;
if (Vel.length() == 0)
return;
if (!UtilTime.elapsed(GrabDelay, 1000))
return;
if (!NearBlock())
return;
Vel.multiply(0);
GrabDelay = System.currentTimeMillis();
UtilPlayer.message(Ent, "You grabbed onto a Block");
}
public void KickOff(Player player)
{
if (!Ent.equals(player))
return;
if (!NearBlock())
return;
GrabDelay = System.currentTimeMillis();
AddVelocity(player.getLocation().getDirection().multiply(0.5), 0.5);
UtilPlayer.message(Ent, "You kicked off a Block");
}
public void Jetpack()
{
if (!Ent.isValid())
return;
if (!(Ent instanceof Player))
return;
Player player = ((Player)Ent);
if (!player.isBlocking())
return;
AddVelocity(player.getLocation().getDirection().multiply(0.015), 0.5);
public void PlayCollideSound(double power)
{
Ent.getWorld().playSound(Ent.getLocation(), Sound.ZOMBIE_WOOD, 1f, 1f);
}
public void AddVelocity(Vector vel)
{
AddVelocity(vel, 50);
@ -230,4 +187,11 @@ public class GravityObject
Vel.normalize().multiply(3);
}
}
public void Clean()
{
Ent.remove();
Ent.leaveVehicle();
Base.remove();
}
}

View File

@ -0,0 +1,5 @@
package nautilus.game.arcade.game.games.gravity.kits;
public class KitHook {
}

View File

@ -6,17 +6,18 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public class KitPlayer extends Kit
public class KitJetpack extends Kit
{
public KitPlayer(ArcadeManager manager)
public KitJetpack(ArcadeManager manager)
{
super(manager, "Player", KitAvailability.Free,
super(manager, "Astronaut", KitAvailability.Free,
new String[]
{
@ -35,9 +36,10 @@ public class KitPlayer extends Kit
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SHEARS, (byte)0, 1, "Block Cannon"));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1, "Jetpack"));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Grappling Hook"));
//player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SHEARS, (byte)0, 1, "Block Cannon"));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1,
C.cYellow + "Left-Click: " + C.cWhite + "Block Cannon " + C.cYellow + "Right-Click: " + C.cWhite + "Jetpack"));
//player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Grappling Hook"));
}
@Override

View File

@ -0,0 +1,74 @@
package nautilus.game.arcade.game.games.gravity.objects;
import java.util.HashSet;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.game.games.gravity.Gravity;
import nautilus.game.arcade.game.games.gravity.GravityObject;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.util.Vector;
public class GravityBomb extends GravityObject
{
public GravityBomb(Gravity host, Entity ent, double mass, Vector vel)
{
super(host, ent, mass, 1.5, vel);
}
@Override
public void PlayCollideSound(double power)
{
Ent.getWorld().playSound(Ent.getLocation(), Sound.EXPLODE, 1f, 1f);
}
public HashSet<GravityDebris> DetonateCheck()
{
HashSet<GravityDebris> debris = new HashSet<GravityDebris>();
if (!Ent.isValid())
return debris;
for (Block block : UtilBlock.getInRadius(Ent.getLocation(), 1.5d).keySet())
{
if (UtilBlock.airFoliage(block))
continue;
if (block.getType() == Material.EMERALD_BLOCK)
continue;
//Projectile
Vector velocity = UtilAlg.getTrajectory(Ent.getLocation(), block.getLocation().add(0.5, 0.5, 0.5));
velocity.add(Vel.clone().normalize());
velocity.multiply(0.3);
//Block
Material type = block.getType();
byte data = block.getData();
block.setType(Material.AIR);
//Projectile
FallingBlock projectile = block.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 0.6, 0.5), type,data);
GravityDebris newDebris = new GravityDebris(Host, projectile, 12, velocity);
//Add
debris.add(newDebris);
}
return debris;
}
@Override
public void CustomCollide()
{
Ent.remove();
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, Ent.getLocation(), 0, 0, 0, 0, 1);
}
}

View File

@ -0,0 +1,17 @@
package nautilus.game.arcade.game.games.gravity.objects;
import nautilus.game.arcade.game.games.gravity.Gravity;
import nautilus.game.arcade.game.games.gravity.GravityObject;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
public class GravityDebris extends GravityObject
{
public GravityDebris(Gravity host, Entity ent, double mass, Vector vel)
{
super(host, ent, mass, 2, vel);
CollideDelay = System.currentTimeMillis() + 250;
}
}

View File

@ -0,0 +1,22 @@
package nautilus.game.arcade.game.games.gravity.objects;
import nautilus.game.arcade.game.games.gravity.Gravity;
import nautilus.game.arcade.game.games.gravity.GravityObject;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
public class GravityHook extends GravityObject
{
public GravityHook(Gravity host, Entity ent, double mass, Vector vel)
{
super(host, ent, mass, 1, vel);
}
@Override
public void PlayCollideSound(double power)
{
Ent.getWorld().playSound(Ent.getLocation(), Sound.IRONGOLEM_HIT, 1f, 2f);
}
}

View File

@ -0,0 +1,218 @@
package nautilus.game.arcade.game.games.gravity.objects;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.gravity.Gravity;
import nautilus.game.arcade.game.games.gravity.GravityObject;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.util.Vector;
public class GravityPlayer extends GravityObject
{
public GravityPlayer(Gravity host, Entity ent, double mass, Vector vel)
{
super(host, ent, mass, 2, vel);
}
@Override
public void PlayCollideSound(double power)
{
Ent.getWorld().playSound(Ent.getLocation(), Sound.HURT, 0.8f, 0.75f);
}
public boolean NearBlock()
{
return !NearBlockList().isEmpty();
}
public Collection<Block> NearBlockList()
{
HashSet<Block> blocks = new HashSet<Block>();
for (Block block : UtilBlock.getSurrounding(Base.getLocation().getBlock(), true))
{
if (UtilBlock.airFoliage(block))
continue;
blocks.add(block);
}
for (Block block : UtilBlock.getSurrounding(Base.getLocation().getBlock().getRelative(BlockFace.UP), true))
{
if (UtilBlock.airFoliage(block))
continue;
blocks.add(block);
}
for (Block block : UtilBlock.getSurrounding(Base.getLocation().getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP), true))
{
if (UtilBlock.airFoliage(block))
continue;
blocks.add(block);
}
return blocks;
}
public void AutoGrab()
{
//AntiClip();
if (Vel.length() == 0)
return;
if (!UtilTime.elapsed(GrabDelay, 1000))
return;
if (!NearBlock())
return;
Vel.multiply(0);
Base.setVelocity(new Vector(0,0,0));
GrabDelay = System.currentTimeMillis();
//Sound
Ent.getWorld().playSound(Ent.getLocation(), Sound.STEP_STONE, 2f, 0.5f);
//Effect
Ent.getWorld().playEffect(Ent.getLocation(), Effect.STEP_SOUND, 1);
//UtilPlayer.message(Ent, "You grabbed onto a Block");
}
public void AntiClip()
{
if (!NearBlock() || Vel.length() > 0.05)
return;
Location target = Base.getLocation().getBlock().getLocation().add(0.5, 0.5, 0.5);
target.setY(Base.getLocation().getY());
if (UtilMath.offset(Base.getLocation(), target) > 0.25)
{
this.AddVelocity(UtilAlg.getTrajectory(Base.getLocation(), target).multiply(0.05), 0.05);
}
else
{
Vel.multiply(0);
Base.setVelocity(new Vector(0,0,0));
}
}
public void KickOff(Player player)
{
if (!Ent.equals(player))
return;
if (!NearBlock())
return;
GrabDelay = System.currentTimeMillis();
AddVelocity(player.getLocation().getDirection().multiply(0.5), 0.5);
//Sound
Ent.getWorld().playSound(Ent.getLocation(), Sound.STEP_WOOD, 2f, 0.5f);
//Effect
Ent.getWorld().playEffect(Ent.getLocation(), Effect.STEP_SOUND, 1);
//UtilPlayer.message(Ent, "You kicked off a Block");
}
public void Jetpack()
{
if (!Ent.isValid())
return;
if (!(Ent instanceof Player))
return;
Player player = ((Player)Ent);
if (!player.isBlocking())
return;
if (player.getItemInHand().getType() != Material.IRON_SWORD)
return;
if (player.getExp() <= 0)
{
if (Recharge.Instance.use(player, "Fuel", 1000, false))
UtilPlayer.message(Ent, F.main("Skill", "You have no more " + F.skill("Jetpack Fuel") + "."));
return;
}
player.setExp((float) Math.max(0, player.getExp()-0.004));
AddVelocity(player.getLocation().getDirection().multiply(0.025), 0.5);
//Sound
Ent.getWorld().playSound(Ent.getLocation(), Sound.GHAST_FIREBALL, 0.3f, 2f);
//Effect
UtilParticle.PlayParticle(ParticleType.FLAME, Ent.getLocation().add(0, 0.5, 0), 0.1f, 0.1f, 0.1f, 0, 2);
}
public void Oxygen()
{
boolean near = false;
for (Block block : UtilBlock.getInRadius(Ent.getLocation(), 4d).keySet())
{
if (block.getType() == Material.EMERALD_BLOCK)
{
near = true;
break;
}
}
//Restore
if (near)
{
UtilPlayer.message(Ent, F.main("Game", "Restoring Oxygen..."));
Ent.getWorld().playSound(Ent.getLocation(), Sound.CAT_HISS, 0.2f, 0.5f);
Base.setHealth(Math.min(60, Base.getHealth() + 6));
}
//Lose
else
{
Base.setHealth(Math.max(1, Base.getHealth() - 1));
}
//Die
if (Base.getHealth() <= 1)
{
Host.Manager.GetDamage().NewDamageEvent((Player)Ent, null, null,
DamageCause.CUSTOM, 2, false, true, false,
"Oxygen Depleted", "Oxygen Depleted");
UtilPlayer.message(Ent, F.main("Game", "You are suffocating!"));
UtilPlayer.message(Ent, F.main("Game", "Get more Oxygen from the Emerald Blocks!"));
}
}
}

View File

@ -15,6 +15,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.PlayerDeathOutEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
@ -701,10 +702,13 @@ public class GameFlagManager implements Listener
{
UtilPlayer.message(player, C.cRed + C.Bold + "WARNING: " + C.cWhite + C.Bold + "RETURN TO PLAYABLE AREA!");
if (player.getLocation().getY() > game.WorldData.MaxY)
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0, 0, 10, true);
else
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0.4, 0, 10, true);
if (game.GetType() != GameType.Gravity)
{
if (player.getLocation().getY() > game.WorldData.MaxY)
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0, 0, 10, true);
else
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0.4, 0, 10, true);
}
Manager.GetDamage().NewDamageEvent(player, null, null,
DamageCause.VOID, 4, false, false, false,