Wither Assault (I don't like it at all)

This commit is contained in:
Sam 2018-04-30 17:49:23 +01:00 committed by Alexander Meech
parent 77adc83720
commit d568842d7c
8 changed files with 169 additions and 301 deletions

View File

@ -3886,8 +3886,9 @@ public enum GameKit
},
new KitEntityData<>
(
Wither.class,
createColoured(Material.SKULL_ITEM, (byte) 2)
Skeleton.class,
createColoured(Material.SKULL_ITEM, (byte) 1),
SkeletonType.WITHER.ordinal()
)
),

View File

@ -50,7 +50,7 @@ public class Micro extends TeamGame
"Be the " + C.cYellow + "Last Team" + C.Reset + " standing!"
};
private static final long BARRIER_TIME = TimeUnit.SECONDS.toMillis(10);
private static final long CHEAT_TIME = TimeUnit.SECONDS.toMillis(5);
private static final long CHEAT_TIME = TimeUnit.SECONDS.toMillis(4);
private final Set<Block> _glass = new HashSet<>();
private final Map<GameTeam, Location> _teamCenters = new HashMap<>();

View File

@ -11,34 +11,26 @@ import nautilus.game.arcade.game.Game;
public class PlayerCopyWither
{
private Game Host;
private Skeleton _ent;
private Player _owner;
private final Skeleton _ent;
private final Player _owner;
public PlayerCopyWither(Game host, Player owner, ChatColor nameColor)
PlayerCopyWither(Game host, Player owner, ChatColor nameColor)
{
Host = host;
_owner = owner;
Host.CreatureAllowOverride = true;
host.CreatureAllowOverride = true;
_ent = owner.getWorld().spawn(owner.getLocation(), Skeleton.class);
Host.CreatureAllowOverride = false;
host.CreatureAllowOverride = false;
UtilEnt.ghost(_ent, true, false);
UtilEnt.vegetate(_ent);
UtilEnt.vegetate(_ent, true);
//Armor
_ent.getEquipment().setArmorContents(owner.getInventory().getArmorContents());
_ent.setCustomName(C.cWhite + C.Bold + C.Scramble + "XX" + ChatColor.RESET + " " + nameColor + owner.getName() + " " + C.cWhite + C.Bold + C.Scramble + "XX");
_ent.setCustomNameVisible(true);
//Disguise
// DisguisePlayer disguise = new DisguisePlayer(_ent, ((CraftPlayer)owner).getProfile());
// Host.Manager.GetDisguise().disguise(disguise);
}
public LivingEntity GetEntity()

View File

@ -4,7 +4,10 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -53,6 +56,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
@ -75,24 +79,19 @@ import nautilus.game.arcade.stats.TeamKillsStatTracker;
public class WitherGame extends TeamGame implements IBlockRestorer
{
private static final double WITHER_FACTOR = 2.5;
private static final long GAME_TIMEOUT = TimeUnit.MINUTES.toMillis(5);
private GameTeam _runners;
private GameTeam _withers;
private double _witherFactor = 2.5;
private int _yLimit = 0;
private int _maxY;
private long _gameTime = 300000;
private HashMap<Player, PlayerCopyWither> _doubles = new HashMap<Player, PlayerCopyWither>();
// private int _livesPerPlayer = 3;
// private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
private HashSet<BlockData> _blocks = new HashSet<BlockData>();
private ArrayList<Location> _locationsOfBlocks = new ArrayList<Location>();
private final Map<Player, PlayerCopyWither> _doubles = new HashMap<>();
private final Set<BlockData> _blocks = new HashSet<>();
private final List<Location> _locationsOfBlocks = new ArrayList<>();
public WitherGame(ArcadeManager manager)
{
@ -118,29 +117,28 @@ public class WitherGame extends TeamGame implements IBlockRestorer
C.cRed + "Withers" + C.cWhite + " Kill all the Humans within 5 Minutes",
});
this.DeathOut = true;
this.DamageTeamSelf = false;
this.DamageSelf = false;
this.DeathSpectateSecs = 4;
this.HungerSet = 20;
this.WorldBoundaryKill = false;
DeathOut = true;
DamageTeamSelf = false;
DamageSelf = false;
DeathSpectateSecs = 4;
HungerSet = 20;
WorldBoundaryKill = false;
//Customizing for the Editor kit
this.BlockBreak = true;
this.BlockPlace = true;
this.ItemPickup = true;
BlockBreak = true;
BlockPlace = true;
ItemPickup = true;
this.KitRegisterState = GameState.Prepare;
KitRegisterState = GameState.Prepare;
this.InventoryClick = false;
this.InventoryOpenBlock = false;
InventoryClick = false;
InventoryOpenBlock = false;
_help = new String[]
{
"Blocks placed by an Editor can be passed by other humans by " + C.cDGreen + "Right-clicking the block",
"Withers are too powerful to be killed. Hiding is the only option!",
"Medics are a valuable asset. Stick with them and keep them safe!",
};
@ -219,7 +217,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
return;
// Enough Withers
if (_withers.GetPlayers(true).size() * _witherFactor >= _runners
if (_withers.GetPlayers(true).size() * WITHER_FACTOR >= _runners
.GetPlayers(true).size())
return;
@ -227,28 +225,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
setWither(player, true);
}
// @EventHandler
// public void assignCompassOnStart(GameStateChangeEvent event)
// {
// if (event.GetState() != GameState.Live)
// return;
//
// for (Player players : _withers.GetPlayers(true))
// {
// ItemStack compass = new ItemBuilder(Material.COMPASS, 1).build();
//
// ItemMeta im = compass.getItemMeta();
// im.setLore(new ArrayList<String>(Arrays.asList(
// F.item("A compass that trigger"),
// F.item("your ability to track humans!"))));
// im.setDisplayName(F.name("Scent Trigger"));
//
// compass.setItemMeta(im);
//
// players.getInventory().setItem(7, compass);
// }
// }
// Cancel wither shooting in waiting lobby
@EventHandler
public void onWitherSkullFire(ProjectileLaunchEvent event)
@ -381,8 +357,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
public void setWither(Player player, boolean forced)
{
// _lives.remove(player);
SetPlayerTeam(player, _withers, true);
// Kit
@ -408,27 +382,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
}
}
// @EventHandler
// public void playerLoseLife(final PlayerDeathOutEvent event)
// {
// Player player = event.GetPlayer();
//
// if (_lives.containsKey(player))
// {
// int lives = _lives.get(player);
//
// if (lives <= 1)
// return;
//
// _lives.put(player, lives - 1);
//
// UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen +
// C.Bold + lives + " Lives Remaining") + "."));
//
// event.setCancelled(true);
// }
// }
@EventHandler
public void gameStart(GameStateChangeEvent event)
{
@ -466,26 +419,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
}
// @EventHandler
// public void playerLivesDisplay(PlayerKitGiveEvent event)
// {
// if (!_runners.HasPlayer(event.GetPlayer()))
// return;
//
// //Player Lives
// if (!_lives.containsKey(event.GetPlayer()))
// _lives.put(event.GetPlayer(), _livesPerPlayer);
//
// int lives = _lives.get(event.GetPlayer());
//
// if (lives <= 0)
// return;
//
// event.GetPlayer().getInventory().setItem(8,
// ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, lives,
// C.cGreen + C.Bold + lives + " Lives Remaining"));
// }
@Override
public void EndCheck()
{
@ -502,7 +435,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
GameTeam winner = null;
// Wither Win
if (UtilTime.elapsed(this.GetStateTime(), _gameTime))
if (UtilTime.elapsed(this.GetStateTime(), GAME_TIMEOUT))
winner = _runners;
// Runner Win
@ -542,36 +475,20 @@ public class WitherGame extends TeamGame implements IBlockRestorer
if (event.getType() != UpdateType.FAST)
return;
// int lives = 0;
// for (int i : _lives.values())
// lives += i;
// Wipe Last
Scoreboard.reset();
Scoreboard.writeNewLine();
Scoreboard.write(_runners.GetColor() + C.Bold + _runners.GetName());
Scoreboard.write(_runners.GetColor() + ""
+ _runners.GetPlayers(true).size() + " Players");
Scoreboard.write(_runners.GetColor() + "" + _runners.GetPlayers(true).size() + " Players");
Scoreboard.writeNewLine();
Scoreboard.write(_withers.GetColor() + C.Bold + _withers.GetName());
Scoreboard.write(_withers.GetColor() + ""
+ _withers.GetPlayers(true).size() + " Players");
// Scoreboard.WriteBlank();
// Scoreboard.Write(C.cYellow + C.Bold + "Humans Alive");
// Scoreboard.Write(lives + " / " + (_lives.size() * _livesPerPlayer));
Scoreboard.write(_withers.GetColor() + "" + _withers.GetPlayers(true).size() + " Players");
Scoreboard.writeNewLine();
Scoreboard.write(C.cYellow + C.Bold + "Time Left");
Scoreboard.write(UtilTime.MakeStr(
Math.max(
0,
_gameTime
- (System.currentTimeMillis() - this
.GetStateTime())), 1));
Scoreboard.write(UtilTime.MakeStr(Math.max(0, GAME_TIMEOUT - (System.currentTimeMillis() - GetStateTime())), 1));
Scoreboard.draw();
}
@ -598,7 +515,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
public int getRequiredWithers()
{
return (int) (GetPlayers(true).size() / _witherFactor);
return (int) (GetPlayers(true).size() / WITHER_FACTOR);
}
@EventHandler
@ -620,15 +537,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
double distanceToGround = player.getLocation().distance(new Location(_spawn.getWorld(), player.getLocation().getX(), _spawn.getY(), player.getLocation().getZ()));
double speed;
if (distanceToGround < 8)
{
speed = 0.16;
}
else
{
speed = 0.09 - (_yLimit - player.getLocation().getY()) * 0.006;
}
if (distanceToGround < 4)
{
speed = 0.016;
@ -662,10 +570,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
continue;
UtilAction.velocity(player, vec, 0.6, false, 0, 0.4, 10, true);
// if (player.getLocation().getY() < _yLimit + 6)
// UtilAction.velocity(player, new Vector(0, 1, 0), 0.6, false, 0,
// 0, 10, true);
}
}
@ -684,11 +588,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
else if (!isInsideMap(block.getLocation()))
blockIter.remove();
// else if (UtilAlg.inBoundingBox(block.getLocation(), _safeA,
// _safeB) || UtilAlg.inBoundingBox(block.getLocation(), _spawnA,
// _spawnB))
// blockIter.remove();
}
for (Block block : blocks)
@ -717,32 +616,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
}
}
// @EventHandler
// public void cleanLives(PlayerQuitEvent event)
// {
// _lives.remove(event.getPlayer());
// }
// @EventHandler
// public void livesUpdate(UpdateEvent event)
// {
// if (!IsLive())
// return;
//
// if (event.getType() != UpdateType.FASTER)
// return;
//
// Iterator<Player> playerIter = _lives.keySet().iterator();
//
// while (playerIter.hasNext())
// {
// Player player = playerIter.next();
//
// if (!player.isOnline() || !_runners.HasPlayer(player))
// playerIter.remove();
// }
// }
@EventHandler
public void arrowDamage(CustomDamageEvent event)
{
@ -921,20 +794,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
Bukkit.getPluginManager().callEvent(new HumanReviveEvent(thrower, copy.GetPlayer()));
}
// Revive a player
// for (Player player : GetPlayers(true))
// {
// GameTeam otherTeam = GetTeam(player);
// if (otherTeam == null || !otherTeam.equals(throwerTeam))
// continue;
//
// if (UtilMath.offset(player.getLocation().add(0, 1, 0), event
// .getEntity().getLocation()) > 3)
// continue;
//
// playerIn(player, null, thrower);
// }
}
@EventHandler

View File

@ -29,8 +29,6 @@ public class KitHumanMedic extends Kit
private static final ItemStack[] PLAYER_ITEMS =
{
ItemStackFactory.Instance.CreateStack(Material.STONE_AXE),
ItemStackFactory.Instance.CreateStack(Material.STONE_PICKAXE),
ItemStackFactory.Instance.CreateStack(Material.STONE_SPADE),
new ItemBuilder(Material.POTION).setAmount(2).setData((short) 16429).setTitle(C.Reset + "Revival Potion").build(),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.kit.perks;
import java.util.Iterator;
import java.util.Map;
import java.util.WeakHashMap;
import org.bukkit.Sound;
@ -10,16 +11,18 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkWitherArrows extends Perk
{
private WeakHashMap<Arrow, Player> _proj = new WeakHashMap<Arrow, Player>();
private final Map<Arrow, Player> _proj = new WeakHashMap<>();
public PerkWitherArrows()
{
@ -32,8 +35,10 @@ public class PerkWitherArrows extends Perk
@EventHandler
public void shoot(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
if (event.getType() != UpdateType.TICK || !Manager.GetGame().IsLive())
{
return;
}
for (Player player : Manager.GetGame().GetPlayers(true))
{

View File

@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
@ -21,15 +22,19 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.data.IBlockRestorer;
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.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.WitherSkull;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -88,7 +93,7 @@ public class PerkWitherAttack extends Perk
event.setCancelled(true);
WitherSkull skull = (WitherSkull)event.getEntity();
WitherSkull skull = (WitherSkull) event.getEntity();
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, skull.getLocation(), 0, 0, 0, 0, 1,
ViewDist.MAX, UtilServer.getPlayers());
@ -129,7 +134,7 @@ public class PerkWitherAttack extends Perk
private void explode(WitherSkull skull)
{
double scale = 0.4 + 0.6 * Math.min(1, skull.getTicksLived()/20d);
double scale = 0.4 + 0.6 * Math.min(1, skull.getTicksLived() / 20d);
//Players
HashMap<Player, Double> players = UtilPlayer.getInRadius(skull.getLocation(), 7);
@ -139,32 +144,39 @@ public class PerkWitherAttack extends Perk
continue;
//Damage Event
Manager.GetDamage().NewDamageEvent(player, (LivingEntity)skull.getShooter(), null,
Manager.GetDamage().NewDamageEvent(player, (LivingEntity) skull.getShooter(), null,
DamageCause.CUSTOM, 2 + 10 * players.get(player) * scale, true, true, false,
UtilEnt.getName((LivingEntity)skull.getShooter()), GetName());
UtilEnt.getName((LivingEntity) skull.getShooter()), GetName());
}
//Blocks
Set<Block> blocks = UtilBlock.getInRadius(skull.getLocation(), 4d).keySet();
Iterator<Block> blockIterator = blocks.iterator();
while (blockIterator.hasNext())
blocks.removeIf(block ->
{
Block block = blockIterator.next();
if (block.isLiquid())
blockIterator.remove();
else if (block.getRelative(BlockFace.UP).isLiquid())
blockIterator.remove();
if (block.isLiquid() || block.getRelative(BlockFace.UP).isLiquid())
{
return true;
}
Location location = block.getLocation();
for (Entity entity : block.getWorld().getEntitiesByClass(Skeleton.class))
{
if (UtilMath.offsetSquared(location, entity.getLocation()) < 9)
{
return true;
}
}
return false;
});
if (Manager.GetGame() != null && Manager.GetGame() instanceof IBlockRestorer)
{
((IBlockRestorer)Manager.GetGame()).addBlocks(blocks);
((IBlockRestorer) Manager.GetGame()).addBlocks(blocks);
}
Manager.GetExplosion().BlockExplosion(blocks, skull.getLocation(), false);
}
}

View File

@ -1,21 +1,19 @@
package nautilus.game.arcade.kit.perks;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.WeakHashMap;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
@ -26,20 +24,22 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Perk;
public class PerkWitherMinion extends Perk
{
private ArrayList<Skeleton> _ents = new ArrayList<Skeleton>();
private final Map<Skeleton, Player> _minions = new HashMap<>();
public PerkWitherMinion()
{
@ -76,15 +76,15 @@ public class PerkWitherMinion extends Perk
Manager.GetGame().CreatureAllowOverride = true;
for (int i=0 ; i<2 ; i++)
for (int i = 0; i < 2; i++)
{
Skeleton skel = player.getWorld().spawn(player.getEyeLocation(), Skeleton.class);
_ents.add(skel);
_minions.put(skel, player);
skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)1, 1));
skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 1, 1));
ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta();
LeatherArmorMeta meta = (LeatherArmorMeta) armor.getItemMeta();
meta.setColor(Color.BLACK);
armor.setItemMeta(meta);
skel.getEquipment().setChestplate(armor);
@ -108,20 +108,25 @@ public class PerkWitherMinion extends Perk
player.getWorld().playSound(player.getLocation(), Sound.WITHER_HURT, 2f, 0.6f);
}
@EventHandler(priority = EventPriority.LOWEST)
public void witherFallCancel(CustomDamageEvent event)
@EventHandler(priority = EventPriority.HIGH)
public void minionDamage(CustomDamageEvent event)
{
if (event.IsCancelled())
{
return;
}
if (event.GetCause() != DamageCause.FALL)
return;
if (!_ents.contains(event.GetDamageeEntity()))
return;
LivingEntity damagee = event.GetDamageeEntity(), damager = event.GetDamagerEntity(true);
if (event.GetCause() == DamageCause.FALL && _minions.containsKey(damagee))
{
event.SetCancelled("Minion Fall Damage");
}
else if (_minions.containsKey(damager))
{
event.SetDamager(_minions.get(damager));
}
}
@EventHandler
public void entityTarget(EntityTargetEvent event)
@ -139,28 +144,24 @@ public class PerkWitherMinion extends Perk
if (event.getType() != UpdateType.TICK)
return;
Iterator<Skeleton> skelIter = _ents.iterator();
while (skelIter.hasNext())
_minions.keySet().removeIf(skel ->
{
Skeleton skel = skelIter.next();
if (!skel.isValid() || skel.getTicksLived() > 300 || skel.getLocation().getY() < 0)
{
skel.remove();
skelIter.remove();
return true;
}
else
{
if (skel.getTarget() == null)
{
skel.setTarget(UtilPlayer.getClosest(skel.getLocation(), getWitherTeam().GetPlayers(true)));
}
}
}
return false;
});
}
public GameTeam getWitherTeam()
private GameTeam getWitherTeam()
{
if (Manager.GetGame() == null)
return null;