Micro Battles

This commit is contained in:
Sam 2018-04-30 12:47:26 +01:00 committed by Alexander Meech
parent 9ebf96cfd5
commit 41fdde2c22
11 changed files with 131 additions and 489 deletions

View File

@ -1752,6 +1752,7 @@ public enum GameKit
C.cGreen + "▪ Wood Sword",
C.cGreen + "▪ Stone Spade",
C.cGreen + "▪ Stone Pickaxe",
C.cGreen + "▪ Stone Axe",
C.cGreen + "▪ 4 Apples"
},
new KitEntityData<>

View File

@ -55,10 +55,6 @@ import nautilus.game.arcade.game.games.hideseek.HideSeek;
import nautilus.game.arcade.game.games.hideseek.modes.Countdown;
import nautilus.game.arcade.game.games.lobbers.BombLobbers;
import nautilus.game.arcade.game.games.micro.Micro;
import nautilus.game.arcade.game.games.micro.modes.CookieFight;
import nautilus.game.arcade.game.games.micro.modes.OverpoweredMicroBattles;
import nautilus.game.arcade.game.games.micro.modes.TinySmash;
import nautilus.game.arcade.game.games.micro.modes.TinyWinners;
import nautilus.game.arcade.game.games.milkcow.MilkCow;
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
import nautilus.game.arcade.game.games.minestrike.Minestrike;
@ -253,10 +249,6 @@ public enum GameType
new GameMode(GodBattles.class, GameType.UHC, "God Battles"),
new GameMode(BloodDiamonds.class, GameType.UHC, "Blood Diamonds"),
new GameMode(Assassins.class, GameType.UHC, "Assassins"),
new GameMode(TinyWinners.class, GameType.Micro, "Tiny Winners"),
new GameMode(OverpoweredMicroBattles.class, GameType.Micro, "OP Micro Battles"),
new GameMode(CookieFight.class, GameType.Micro, "Cookie Fight"),
new GameMode(TinySmash.class, GameType.Micro, "Tiny Smash"),
new GameMode(UltraSpleef.class, GameType.Spleef, "Ultra Spleef"),
new GameMode(RandomKitSSM.class, GameType.Smash, "Random Kit SSM"),
new GameMode(EweHeroes.class, GameType.Sheep, "Heroes Of The Ewe"),

View File

@ -50,7 +50,6 @@ public class BaconBrawl extends SoloGame
}, DESCRIPTION);
DamageTeamSelf = true;
HungerSet = 20;
PrepareFreeze = false;
StrictAntiHack = true;
PlayerGameMode = GameMode.ADVENTURE;

View File

@ -1,86 +1,87 @@
package nautilus.game.arcade.game.games.micro;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilTime;
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.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.micro.kits.*;
import nautilus.game.arcade.game.games.micro.kits.KitArcher;
import nautilus.game.arcade.game.games.micro.kits.KitFighter;
import nautilus.game.arcade.game.games.micro.kits.KitWorker;
import nautilus.game.arcade.game.modules.MapCrumbleModule;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.stats.KillsWithinGameStatTracker;
public class Micro extends TeamGame
{
private ArrayList<Block> _blocks = new ArrayList<Block>();
private ArrayList<Block> _glass = new ArrayList<Block>();
public Micro(ArcadeManager manager, GameType type)
private static final String[] DESCRIPTION =
{
"Gather some " + C.cGreen + "Blocks" + C.Reset + ".",
"The " + C.cAqua + "Glass Barrier" + C.Reset + " will disappear in " + C.cRed + "10 seconds" + C.Reset + ".",
"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 final Set<Block> _glass = new HashSet<>();
private final Map<GameTeam, Location> _teamCenters = new HashMap<>();
public Micro(ArcadeManager manager)
{
this(manager,
super(manager, GameType.Micro, new Kit[]
{
new KitArcher(manager),
new KitWorker(manager),
new KitFighter(manager)
}, DESCRIPTION);
new Kit[]
{
new KitArcher(manager),
new KitWorker(manager),
new KitFighter(manager)
},
GameType.Micro);
}
public Micro(ArcadeManager manager, Kit[] kits, GameType type)
{
super(manager, type, kits,
new String[]
{
"Small game, big strategy!",
});
this.StrictAntiHack = true;
this.InventoryClick = true;
this.ItemDrop = true;
this.ItemPickup = true;
this.BlockBreak = true;
this.BlockPlace = true;
StrictAntiHack = true;
InventoryClick = true;
ItemDrop = true;
ItemPickup = true;
BlockBreak = true;
BlockPlace = true;
new CompassModule()
.setGiveCompass(true)
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
new TeamArmorModule()
.giveTeamArmor()
.giveHotbarItem()
.register(this);
}
public Micro(ArcadeManager manager)
{
this(manager, GameType.Micro);
new MapCrumbleModule()
.register(this);
registerStatTrackers(
new KillsWithinGameStatTracker(this, 8, "Annihilation")
);
@ -93,27 +94,22 @@ public class Micro extends TeamGame
DamageDealt
);
}
@Override
public void ParseData()
public void ParseData()
{
for (Location loc : WorldData.GetCustomLocs("20"))
for (Location location : WorldData.GetCustomLocs("20"))
{
_glass.add(loc.getBlock());
loc.getBlock().setType(Material.STAINED_GLASS);
Block block = location.getBlock();
_glass.add(block);
block.setType(Material.STAINED_GLASS);
}
for (GameTeam team : GetTeamList())
{
_teamCenters.put(team, UtilAlg.getAverageLocation(team.GetSpawns()));
}
for (int y= WorldData.MinY ; y < WorldData.MaxY ; y++)
for (int x= WorldData.MinX ; x < WorldData.MaxX ; x++)
for (int z= WorldData.MinZ ; z < WorldData.MaxZ ; z++)
{
Block block = WorldData.World.getBlockAt(x, y, z);
if (block.getType() == Material.AIR)
continue;
_blocks.add(block);
}
}
@EventHandler
@ -127,132 +123,95 @@ public class Micro extends TeamGame
{
event.setCancelled(true);
}
@EventHandler
public void BlockPlace(BlockPlaceEvent event)
public void playerDropItem(PlayerDropItemEvent event)
{
if (event.isCancelled())
if (!IsLive())
{
return;
_blocks.add(event.getBlock());
}
ItemStack itemStack = event.getItemDrop().getItemStack();
if (UtilItem.isSword(itemStack))
{
event.setCancelled(true);
}
}
@EventHandler
public void BlockUpdate(UpdateEvent event)
public void updateHunger(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!IsLive())
return;
if (_blocks.isEmpty())
return;
if (!UtilTime.elapsed(GetStateTime(), 12000))
return;
int d = 1;
if (UtilTime.elapsed(GetStateTime(), 16000))
d = 2;
if (UtilTime.elapsed(GetStateTime(), 20000))
d = 3;
//TimingManager.start("Block Fall");
for (int i = 0 ; i < d ; i++)
{
Block bestBlock = null;
double bestDist = 0;
for (Block block : _blocks)
return;
}
for (Player player : GetPlayers(true))
{
if (player.getFoodLevel() < 2)
{
double dist = UtilMath.offset2d(GetSpectatorLocation(), block.getLocation().add(0.5, 0.5, 0.5));
if (bestBlock == null || dist > bestDist)
{
bestBlock = block;
bestDist = dist;
}
player.setFoodLevel(2);
}
//Shuffle Down
while (bestBlock.getRelative(BlockFace.DOWN).getType() != Material.AIR)
bestBlock = bestBlock.getRelative(BlockFace.DOWN);
_blocks.remove(bestBlock);
if (bestBlock.getType() != Material.AIR)
}
}
@EventHandler
public void updateGlassBarrier(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER || !IsLive() || _glass.isEmpty())
{
return;
}
if (!UtilTime.elapsed(GetStateTime(), CHEAT_TIME))
{
for (GameTeam team : GetTeamList())
{
if (Math.random() > 0.75)
bestBlock.getWorld().spawnFallingBlock(bestBlock.getLocation().add(0.5, 0.5, 0.5), bestBlock.getType(), bestBlock.getData());
MapUtil.QuickChangeBlockAt(bestBlock.getLocation(), Material.AIR);
Location expected = _teamCenters.get(team);
for (Player player : team.GetPlayers(true))
{
Location location = UtilAlg.findClosest(player.getLocation(), _teamCenters.values());
if (!location.equals(expected))
{
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 500, false, true, true, GetName(), "Cheating");
}
}
}
}
//TimingManager.stop("Block Fall");
if (UtilTime.elapsed(GetStateTime(), BARRIER_TIME))
{
for (Block block : _glass)
{
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR);
}
_glass.clear();
_teamCenters.clear();
}
}
@EventHandler
public void TimeUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!IsLive())
return;
WorldData.World.setTime(WorldData.World.getTime() + 1);
}
@EventHandler
public void FoodUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetPlayers(true))
if (player.getFoodLevel() < 2)
player.setFoodLevel(2);
}
@EventHandler
public void BarrierUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!IsLive())
return;
if (_glass.isEmpty())
return;
if (!UtilTime.elapsed(GetStateTime(), 10000))
return;
for (Block block : _glass)
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR);
_glass.clear();
}
@EventHandler
public void BarrierBreak(BlockBreakEvent event)
public void blockBreak(BlockBreakEvent event)
{
if (_glass.contains(event.getBlock()))
{
event.setCancelled(true);
}
}
@EventHandler
public void ArrowDecrease(CustomDamageEvent event)
public void arrowDamage(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
{
return;
event.AddMod(GetName(), "Projectile Reduce", -2, false);
}
event.AddKnockback("Increase", 1.6d);
}
}

View File

@ -18,6 +18,7 @@ public class KitWorker extends Kit
ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD),
ItemStackFactory.Instance.CreateStack(Material.STONE_SPADE),
ItemStackFactory.Instance.CreateStack(Material.STONE_PICKAXE),
ItemStackFactory.Instance.CreateStack(Material.STONE_AXE),
ItemStackFactory.Instance.CreateStack(Material.APPLE, 4)
};

View File

@ -1,55 +0,0 @@
package nautilus.game.arcade.game.games.micro.modes;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.games.micro.Micro;
/**
* CookieFight
*
* @author xXVevzZXx
*/
public class CookieFight extends Micro
{
private int _enchantmentLevel;
public CookieFight(ArcadeManager manager)
{
super(manager, GameType.Brawl);
_enchantmentLevel = 250;
}
@EventHandler
public void cookie(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
return;
for (Player player : GetPlayers(true))
{
ItemStack item = new ItemStack(Material.COOKIE);
item.addUnsafeEnchantment(Enchantment.KNOCKBACK, _enchantmentLevel);
player.getInventory().addItem(item);
UtilPlayer.message(player, F.main("Game", "Oh look, you got a Cookie!"));
}
}
@Override
public String GetMode()
{
return "Cookie Fight";
}
}

View File

@ -1,40 +0,0 @@
package nautilus.game.arcade.game.games.micro.modes;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.games.micro.Micro;
import nautilus.game.arcade.game.games.micro.modes.kits.KitOverlord;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.kit.Kit;
/**
* OPMicroBattles
*
* @author xXVevzZXx
*/
public class OverpoweredMicroBattles extends Micro
{
public OverpoweredMicroBattles(ArcadeManager manager)
{
super(manager,
new Kit[]
{
new KitOverlord(manager)
},
GameType.Brawl);
getModule(TeamArmorModule.class)
.dontGiveTeamArmor();
new AbsorptionFix(this);
}
@Override
public String GetMode()
{
return "OP Micro Battles";
}
}

View File

@ -1,96 +0,0 @@
package nautilus.game.arcade.game.games.micro.modes;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.games.micro.Micro;
import nautilus.game.arcade.game.games.smash.kits.KitBlaze;
import nautilus.game.arcade.game.games.smash.kits.KitChicken;
import nautilus.game.arcade.game.games.smash.kits.KitCow;
import nautilus.game.arcade.game.games.smash.kits.KitCreeper;
import nautilus.game.arcade.game.games.smash.kits.KitEnderman;
import nautilus.game.arcade.game.games.smash.kits.KitGolem;
import nautilus.game.arcade.game.games.smash.kits.KitMagmaCube;
import nautilus.game.arcade.game.games.smash.kits.KitPig;
import nautilus.game.arcade.game.games.smash.kits.KitSheep;
import nautilus.game.arcade.game.games.smash.kits.KitSkeletalHorse;
import nautilus.game.arcade.game.games.smash.kits.KitSkeleton;
import nautilus.game.arcade.game.games.smash.kits.KitSkySquid;
import nautilus.game.arcade.game.games.smash.kits.KitSlime;
import nautilus.game.arcade.game.games.smash.kits.KitSnowman;
import nautilus.game.arcade.game.games.smash.kits.KitSpider;
import nautilus.game.arcade.game.games.smash.kits.KitWitch;
import nautilus.game.arcade.game.games.smash.kits.KitWitherSkeleton;
import nautilus.game.arcade.game.games.smash.kits.KitWolf;
import nautilus.game.arcade.game.games.smash.kits.KitZombie;
import nautilus.game.arcade.kit.Kit;
/**
* TinySmash
*
* @author xXVevzZXx
*/
public class TinySmash extends Micro
{
public TinySmash(ArcadeManager manager)
{
super(manager, new Kit[]
{
new KitSkeleton(manager),
new KitGolem(manager),
new KitSpider(manager),
new KitSlime(manager),
new KitCreeper(manager),
new KitEnderman(manager),
new KitSnowman(manager),
new KitWolf(manager),
new KitBlaze(manager),
new KitWitch(manager),
new KitChicken(manager),
new KitSkeletalHorse(manager),
new KitPig(manager),
new KitSkySquid(manager),
new KitWitherSkeleton(manager),
new KitMagmaCube(manager),
new KitZombie(manager),
new KitCow(manager),
new KitSheep(manager)
}, GameType.Brawl);
}
@EventHandler(priority = EventPriority.LOWEST)
public void noFallDamage(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetCause() == DamageCause.FALL)
event.SetCancelled("No Fall Damage");
}
@EventHandler(priority = EventPriority.HIGH)
public void customKnockback(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetDamageePlayer() != null)
event.AddKnockback("Smash Knockback", 1 + 0.1 * (20 - event.GetDamageePlayer().getHealth()));
}
@Override
public String GetMode()
{
return "Tiny Smash";
}
}

View File

@ -1,76 +0,0 @@
package nautilus.game.arcade.game.games.micro.modes;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.games.champions.kits.KitAssassin;
import nautilus.game.arcade.game.games.champions.kits.KitBrute;
import nautilus.game.arcade.game.games.champions.kits.KitKnight;
import nautilus.game.arcade.game.games.champions.kits.KitMage;
import nautilus.game.arcade.game.games.champions.kits.KitRanger;
import nautilus.game.arcade.game.games.micro.Micro;
import nautilus.game.arcade.game.modules.TeamArmorModule;
import nautilus.game.arcade.kit.Kit;
/**
* TinnyWinners gamemode for Micro battles
*
* @author xXVevzZXx
*/
public class TinyWinners extends Micro
{
public TinyWinners(ArcadeManager manager)
{
super(manager,
new Kit[]
{
new KitBrute(manager), new KitRanger(manager), new KitKnight(manager),
new KitMage(manager), new KitAssassin(manager)
},
GameType.Brawl);
Manager.GetDamage().UseSimpleWeaponDamage = false;
Manager.getCosmeticManager().setHideParticles(true);
Manager.getClassManager().GetItemFactory().getProximityManager().setProxyLimit(6);
getModule(TeamArmorModule.class)
.dontGiveTeamArmor();
manager.enableChampionsModules();
}
@EventHandler
public void end(GameStateChangeEvent event)
{
if (event.GetState() != GameState.End)
return;
Manager.disableChampionsModules();
}
@Override
@EventHandler
public void FoodUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetPlayers(true))
player.setFoodLevel(20);
}
@Override
public String GetMode()
{
return "Tiny Winners";
}
}

View File

@ -1,47 +0,0 @@
package nautilus.game.arcade.game.games.micro.modes.kits;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilItem;
import mineplex.core.game.kit.GameKit;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkFletcher;
public class KitOverlord extends Kit
{
private static final Perk[] PERKS = {
new PerkFletcher(7, 4, true)
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, 4, Enchantment.DAMAGE_ALL),
ItemStackFactory.Instance.CreateStack(Material.DIAMOND_PICKAXE),
ItemStackFactory.Instance.CreateStack(Material.BOW, 25, Enchantment.ARROW_DAMAGE),
ItemStackFactory.Instance.CreateStack(Material.COOKED_BEEF, 64),
ItemStackFactory.Instance.CreateStack(Material.GOLDEN_APPLE, 5)
};
public KitOverlord(ArcadeManager manager)
{
super(manager, GameKit.MICRO_FIGHTER, PERKS);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setHelmet(UtilItem.makeUnbreakable(new ItemStack(Material.DIAMOND_HELMET)));
player.getInventory().setChestplate(UtilItem.makeUnbreakable(new ItemStack(Material.DIAMOND_CHESTPLATE)));
player.getInventory().setLeggings(UtilItem.makeUnbreakable(new ItemStack(Material.DIAMOND_LEGGINGS)));
player.getInventory().setBoots(UtilItem.makeUnbreakable(new ItemStack(Material.DIAMOND_BOOTS)));
}
}

View File

@ -131,7 +131,11 @@ public class MapCrumbleModule extends Module
}
_enabled = true;
_onCrumble.run();
if (_onCrumble != null)
{
_onCrumble.run();
}
}
@EventHandler