SG borders now have audio and attack nearby players.

This commit is contained in:
Cheese 2015-03-21 12:22:47 +11:00
parent 6a68dc6b24
commit 2bbf035d4c
4 changed files with 195 additions and 73 deletions

View File

@ -14,11 +14,13 @@ import org.bukkit.block.DoubleChest;
import org.bukkit.block.Furnace;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLargeFireball;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Firework;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
@ -36,6 +38,7 @@ import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
@ -55,6 +58,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import org.bukkit.scoreboard.TeamNameTagVisibility;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -98,6 +102,7 @@ import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker;
import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
import net.minecraft.server.v1_7_R4.EntityArrow;
import net.minecraft.server.v1_7_R4.EntityLargeFireball;
import net.minecraft.server.v1_7_R4.PacketPlayInUseEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutScoreboardTeam;
import net.minecraft.server.v1_7_R4.ScoreboardTeam;
@ -139,7 +144,6 @@ public class SurvivalGames extends SoloGame
private double _currentBorder;
private double _previousBorder;
private long _borderStartedMoving;
private ArrayList<String> _borderIgnore = new ArrayList<String>();
// Deathmatch
private boolean _deathMatchTeleported = false;
@ -165,50 +169,50 @@ public class SurvivalGames extends SoloGame
{
super(manager, GameType.SurvivalGames,
new Kit[]
{
new KitAxeman(manager),
new Kit[]
{
new KitAxeman(manager),
// new KitLooter(manager),
// new KitLooter(manager),
new KitKnight(manager),
new KitKnight(manager),
new KitArcher(manager),
new KitArcher(manager),
new KitBrawler(manager),
new KitBrawler(manager),
new KitAssassin(manager),
new KitAssassin(manager),
new KitBeastmaster(manager),
new KitBeastmaster(manager),
new KitBomber(manager),
new KitBomber(manager),
new KitNecromancer(manager),
new KitNecromancer(manager),
new KitBarbarian(manager),
new KitBarbarian(manager),
new KitHorseman(manager),
},
new KitHorseman(manager),
},
new String[]
{
"Search for chests to find loot",
new String[]
{
"Search for chests to find loot",
"Slaughter your opponents",
"Slaughter your opponents",
"Stay away from the borders!",
"Stay away from the borders!",
"Last tribute alive wins!"
});
"Last tribute alive wins!"
});
_help = new String[]
{
C.cGreen + "Use a Compass to find and kill enemies!",
{
C.cGreen + "Use a Compass to find and kill enemies!",
C.cGreen + "You lose Speed 2 at start of game if you attack.",
C.cGreen + "You lose Speed 2 at start of game if you attack.",
C.cAqua + "Avoid enemies who have better gear than you!"
};
C.cAqua + "Avoid enemies who have better gear than you!"
};
// Manager.GetAntiStack().SetEnabled(false);
@ -817,9 +821,9 @@ public class SurvivalGames extends SoloGame
// A complicated way to get the face the dead body should be towards.
for (HashSet<Byte> validBlocks : new HashSet[]
{
UtilBlock.blockAirFoliageSet, UtilBlock.blockPassSet
})
{
UtilBlock.blockAirFoliageSet, UtilBlock.blockPassSet
})
{
if (validBlocks.contains((byte) block.getRelative(proper).getTypeId()))
@ -828,9 +832,9 @@ public class SurvivalGames extends SoloGame
}
for (BlockFace face : new BlockFace[]
{
BlockFace.EAST, BlockFace.SOUTH, BlockFace.NORTH, BlockFace.WEST
})
{
BlockFace.EAST, BlockFace.SOUTH, BlockFace.NORTH, BlockFace.WEST
})
{
if (validBlocks.contains((byte) block.getRelative(face).getTypeId()))
{
@ -1375,40 +1379,144 @@ public class SurvivalGames extends SoloGame
distanceMovedSince *= percentageBorderMoved;
double border = (_previousBorder - 0.3D) + distanceMovedSince;
ArrayList<String> borderIgnore = new ArrayList<String>();
//24 @ 100+ reduced to 0 at 32-
double borderAttackDist = Math.max(8, (Math.min(100, border) - 28d) / 3d);
double borderCheckDist = borderAttackDist + 6;
for (Player player : UtilServer.getPlayers())
{
if (_borderIgnore.contains(player.getName()))
Location loc = player.getLocation();
//Bump Players Back In
if (loc.getX() > _spawn.getX() + border ||
loc.getX() < _spawn.getX() - border ||
loc.getZ() > _spawn.getZ() + border ||
loc.getZ() < _spawn.getZ() - border)
{
if (Recharge.Instance.use(player, "Hit by Border", 1000, false, false))
{
UtilAction.velocity(player, UtilAlg.getTrajectory2d(loc, GetSpectatorLocation()), 1.2, true, 0.4, 0, 10, true);
if (Manager.IsAlive(player))
{
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 10, false, false, false, "Nether Field",
"Vaporize");
player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f);
player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f);
}
}
}
if (border < 32)
continue;
//Attack Players who are nearby
Location attackSource = null;
if (loc.getX() > _spawn.getX() + (border-borderCheckDist))
{
attackSource = player.getLocation();
attackSource.setX(_spawn.getX() + border);
}
else if (loc.getX() < _spawn.getX() - (border-borderCheckDist))
{
attackSource = player.getLocation();
attackSource.setX(_spawn.getX() - border);
}
else if (loc.getZ() > _spawn.getZ() + (border-borderCheckDist))
{
attackSource = player.getLocation();
attackSource.setZ(_spawn.getZ() + border);
}
else if (loc.getZ() < _spawn.getZ() - (border-borderCheckDist))
{
attackSource = player.getLocation();
attackSource.setZ(_spawn.getZ() - border);
}
if (attackSource != null)
{
double dist = UtilMath.offset(player.getLocation(), attackSource);
player.playSound(player.getLocation().add(UtilAlg.getTrajectory(player.getLocation(), attackSource).multiply(8)),
Sound.PORTAL, (float)(1 - (dist / borderCheckDist)) * 2, 2f);
if (!Manager.IsAlive(player))
continue;
//Shoot more frequently when they get closer
if (dist < borderAttackDist && Math.random() > dist / borderAttackDist)
{
//Spawn Fireball
Location spawn = attackSource.clone().add((Math.random()-0.5)*8, 4 + Math.random() * 4, (Math.random()-0.5)*8);
spawn.add(new Vector((Math.random()-0.5),(Math.random()-0.5),(Math.random()-0.5)));
spawn.subtract(UtilAlg.getTrajectory(spawn, player.getLocation()).multiply(8 + UtilMath.r(8)));
Fireball ball = player.getWorld().spawn(spawn, Fireball.class);
//Trajectory
Vector traj = UtilAlg.getTrajectory(spawn, player.getLocation());
traj.add(new Vector((Math.random()-0.5)*0.2,(Math.random()-0.5)*0.2,(Math.random()-0.5)*0.2));
EntityLargeFireball eFireball = ((CraftLargeFireball) ball).getHandle();
eFireball.dirX = traj.getX() * 0.1;
eFireball.dirY = traj.getY() * 0.1;
eFireball.dirZ = traj.getZ() * 0.1;
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, spawn, 0, 0, 0, 0, 1);
player.getWorld().playSound(attackSource, Sound.GHAST_FIREBALL, 2f, 2f);
}
}
}
}
@EventHandler
public void borderBlockDamage(ProjectileHitEvent event)
{
if (!(event.getEntity() instanceof Fireball))
return;
Collection<Block> blocks = UtilBlock.getInRadius(event.getEntity().getLocation(), 3.5).keySet();
//Dont destroy above hollow ground
Iterator<Block> blockIter = blocks.iterator();
while (blockIter.hasNext())
{
Block block = blockIter.next();
if (!UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
{
blockIter.remove();
continue;
}
Location loc = player.getLocation();
if (loc.getX() > _spawn.getX() + border || loc.getX() < _spawn.getX() - border || loc.getZ() > _spawn.getZ() + border
|| loc.getZ() < _spawn.getZ() - border)
{
if (!Manager.IsAlive(player))
{
player.teleport(GetSpectatorLocation());
}
else
{
UtilAction.velocity(player, UtilAlg.getTrajectory2d(loc, GetSpectatorLocation()), 1, true, 0.4, 0, 10, true);
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 1, false, false, false, "Border",
"Border Damage");
player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f);
player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f);
borderIgnore.add(player.getName());
}
}
int sides = 0;
if (UtilBlock.solid(block.getRelative(BlockFace.NORTH))) sides++;
if (UtilBlock.solid(block.getRelative(BlockFace.EAST))) sides++;
if (UtilBlock.solid(block.getRelative(BlockFace.SOUTH))) sides++;
if (UtilBlock.solid(block.getRelative(BlockFace.WEST))) sides++;
if (UtilBlock.solid(block.getRelative(BlockFace.UP))) sides++;
if (sides >= 4)
blockIter.remove();
}
_borderIgnore = borderIgnore;
Manager.GetExplosion().BlockExplosion(blocks, event.getEntity().getLocation(), false);
}
@EventHandler
public void borderDamage(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
return;
if (!(event.GetProjectile() instanceof Fireball))
return;
event.AddMult("Fireball", "Nether Field", 1, true);
event.AddKnockback("Fireball", 2);
}
private ArrayList<Double> buildBorders(int seconds, double border, double leaveRemaining)
@ -1755,11 +1863,17 @@ public class SurvivalGames extends SoloGame
_baseLoot.registerLoot(new RandomItem(Material.LEATHER_HELMET, 30));
_baseLoot.registerLoot(new RandomItem(Material.LEATHER_LEGGINGS, 30));
// Gold armor
_baseLoot.registerLoot(new RandomItem(Material.GOLD_BOOTS, 25));
_baseLoot.registerLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25));
_baseLoot.registerLoot(new RandomItem(Material.GOLD_HELMET, 25));
_baseLoot.registerLoot(new RandomItem(Material.GOLD_LEGGINGS, 25));
// Chain armor
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 30));
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 30));
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_HELMET, 30));
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 30));
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20));
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20));
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20));
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20));
// Throwable
_baseLoot.registerLoot(new RandomItem(Material.FISHING_ROD, 30));
@ -2009,7 +2123,7 @@ public class SurvivalGames extends SoloGame
/*CustomExplosion explosion = new CustomExplosion(getArcadeManager().GetDamage(), event.getEntity().getLocation(),
((TNTPrimed) event.getEntity()).getYield(), "Throwing TNT");
explosion.setPlayer(player, true);*/
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 14))
@ -2051,7 +2165,7 @@ public class SurvivalGames extends SoloGame
TNTPrimed tnt = player.getWorld()
.spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class);
tnt.setFuseTicks(40);
tnt.setFuseTicks(50);
UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.5, false, 0, 0.1, 10, false);
@ -2132,9 +2246,9 @@ public class SurvivalGames extends SoloGame
}
Player[] players = new Player[]
{
target, player
};
{
target, player
};
if (!(GetKit(player) instanceof KitAssassin || GetKit(target) instanceof KitAssassin))
{

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
@ -15,11 +16,12 @@ public class KitBarbarian extends Kit
{
public KitBarbarian(ArcadeManager manager)
{
super(manager, "Barbarian", KitAvailability.Gem, 10000,
super(manager, "Barbarian", KitAvailability.Gem, 6000,
new String[]
{
"Skilled at taking out teams!"
"Skilled at taking out teams!",
"Abilities disabled for first 30 seconds."
},
new Perk[]
@ -36,6 +38,6 @@ public class KitBarbarian extends Kit
@Override
public void GiveItems(Player player)
{
Recharge.Instance.useForce(player, GetName(), 45000);
}
}

View File

@ -21,6 +21,7 @@ import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilGear;
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.kit.Perk;
@ -58,7 +59,7 @@ public class PerkBladeVortex extends Perk
if (!Recharge.Instance.use(player, GetName(), 24000, true, true))
return;
Recharge.Instance.setDisplayForce(player, GetName(), true);
event.setCancelled(true);
@ -74,7 +75,7 @@ public class PerkBladeVortex extends Perk
Manager.GetDamage().NewDamageEvent(cur, player, null,
DamageCause.CUSTOM, 2 * targets.get(cur), false, true, false,
player.getName(), GetName());
//Velocity
UtilAction.velocity(cur,
UtilAlg.getTrajectory2d(cur.getLocation().toVector(), player.getLocation().toVector()),
@ -113,7 +114,7 @@ public class PerkBladeVortex extends Perk
}
}, (long) ((Math.PI/2d - (j%(Math.PI/2d))) * 8));
}
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
}

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.kit.perks;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
@ -37,6 +38,10 @@ public class PerkCleave extends Perk
if (event.GetReason() != null)
return;
//Dont allow usage in early game
if (UtilTime.elapsed(Manager.GetGame().GetStateTime(), 30000))
return;
//Damager
Player damager = event.GetDamagerPlayer(false);