Added Halloween Minigame

Updated gadgets and other minor things.
This commit is contained in:
Chiss 2013-10-22 15:46:31 +11:00
parent 7cec55713c
commit 1977572ced
36 changed files with 2065 additions and 600 deletions

View File

@ -0,0 +1,191 @@
package mineplex.core.common.util;
import java.lang.reflect.Field;
import java.util.HashMap;
import net.minecraft.server.v1_6_R3.DataWatcher;
import net.minecraft.server.v1_6_R3.EntityPlayer;
import net.minecraft.server.v1_6_R3.Packet;
import net.minecraft.server.v1_6_R3.Packet205ClientCommand;
import net.minecraft.server.v1_6_R3.Packet24MobSpawn;
import net.minecraft.server.v1_6_R3.Packet29DestroyEntity;
import net.minecraft.server.v1_6_R3.Packet40EntityMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
public class UtilDisplay
{
public static final int ENTITY_ID = 1234;
private static HashMap<String, Boolean> hasHealthBar = new HashMap<String, Boolean>();
public static void sendPacket(Player player, Packet packet){
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
entityPlayer.playerConnection.sendPacket(packet);
}
//Accessing packets
public static Packet24MobSpawn getMobPacket(String text, double healthPercent, Location loc){
Packet24MobSpawn mobPacket = new Packet24MobSpawn();
mobPacket.a = (int) ENTITY_ID; //Entity ID
mobPacket.b = (byte) EntityType.ENDER_DRAGON.getTypeId(); //Mob type (ID: 64)
mobPacket.c = (int) Math.floor(loc.getBlockX() * 32.0D); //X position
mobPacket.d = (int) -200; //Y position
mobPacket.e = (int) Math.floor(loc.getBlockZ() * 32.0D); //Z position
mobPacket.f = (byte) 0; //Pitch
mobPacket.g = (byte) 0; //Head Pitch
mobPacket.h = (byte) 0; //Yaw
mobPacket.i = (short) 0; //X velocity
mobPacket.j = (short) 0; //Y velocity
mobPacket.k = (short) 0; //Z velocity
DataWatcher watcher = getWatcher(text, healthPercent * 200);
try{
Field t = Packet24MobSpawn.class.getDeclaredField("t");
t.setAccessible(true);
t.set(mobPacket, watcher);
} catch(Exception e){
e.printStackTrace();
}
return mobPacket;
}
public static Packet29DestroyEntity getDestroyEntityPacket(){
Packet29DestroyEntity packet = new Packet29DestroyEntity();
packet.a = new int[]{ENTITY_ID};
return packet;
}
public static Packet40EntityMetadata getMetadataPacket(DataWatcher watcher){
Packet40EntityMetadata metaPacket = new Packet40EntityMetadata();
metaPacket.a = (int) ENTITY_ID;
try{
Field b = Packet40EntityMetadata.class.getDeclaredField("b");
b.setAccessible(true);
b.set(metaPacket, watcher.c());
} catch(Exception e){
e.printStackTrace();
}
return metaPacket;
}
public static Packet205ClientCommand getRespawnPacket(){
Packet205ClientCommand packet = new Packet205ClientCommand();
packet.a = (int) 1;
return packet;
}
public static DataWatcher getWatcher(String text, double health){
DataWatcher watcher = new DataWatcher();
watcher.a(0, (Byte) (byte) 0x20); //Flags, 0x20 = invisible
watcher.a(6, (Float) (float) health);
watcher.a(10, (String) text); //Entity name
watcher.a(11, (Byte) (byte) 1); //Show name, 1 = show, 0 = don't show
watcher.a(16, (Integer) (int) health); //Wither health, 200 = full health
return watcher;
}
//Other methods
public static void displayTextBar(JavaPlugin plugin, final Player player, double healthPercent, String text)
{
Packet24MobSpawn mobPacket = getMobPacket(text, healthPercent, player.getLocation());
sendPacket(player, mobPacket);
hasHealthBar.put(player.getName(), true);
new BukkitRunnable(){
@Override
public void run(){
Packet29DestroyEntity destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, destroyEntityPacket);
hasHealthBar.put(player.getName(), false);
}
}.runTaskLater(plugin, 120L);
}
public static void displayLoadingBar(final String text, final String completeText, final Player player, final int healthAdd, final long delay, final boolean loadUp, final JavaPlugin plugin){
Packet24MobSpawn mobPacket = getMobPacket(text, 0, player.getLocation());
sendPacket(player, mobPacket);
hasHealthBar.put(player.getName(), true);
new BukkitRunnable(){
int health = (loadUp ? 0 : 200);
@Override
public void run(){
if((loadUp ? health < 200 : health > 0)){
DataWatcher watcher = getWatcher(text, health);
Packet40EntityMetadata metaPacket = getMetadataPacket(watcher);
sendPacket(player, metaPacket);
if(loadUp){
health += healthAdd;
} else {
health -= healthAdd;
}
} else {
DataWatcher watcher = getWatcher(text, (loadUp ? 200 : 0));
Packet40EntityMetadata metaPacket = getMetadataPacket(watcher);
Packet29DestroyEntity destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, metaPacket);
sendPacket(player, destroyEntityPacket);
hasHealthBar.put(player.getName(), false);
//Complete text
Packet24MobSpawn mobPacket = getMobPacket(completeText, 100, player.getLocation());
sendPacket(player, mobPacket);
hasHealthBar.put(player.getName(), true);
DataWatcher watcher2 = getWatcher(completeText, 200);
Packet40EntityMetadata metaPacket2 = getMetadataPacket(watcher2);
sendPacket(player, metaPacket2);
new BukkitRunnable(){
@Override
public void run(){
Packet29DestroyEntity destroyEntityPacket = getDestroyEntityPacket();
sendPacket(player, destroyEntityPacket);
hasHealthBar.put(player.getName(), false);
}
}.runTaskLater(plugin, 40L);
this.cancel();
}
}
}.runTaskTimer(plugin, delay, delay);
}
public static void displayLoadingBar(final String text, final String completeText, final Player player, final int secondsDelay, final boolean loadUp, JavaPlugin plugin){
final int healthChangePerSecond = 200 / secondsDelay;
displayLoadingBar(text, completeText, player, healthChangePerSecond, 20L, loadUp, plugin);
}
}

View File

@ -401,8 +401,21 @@ public class UtilEnt
{
for (int z=zMin ; z<=zMax ; z++)
{
//half block, carpet, snow, etc
//if (player.getLocation().getBlock().getType() != Material.AIR)
// return true;
//standing on...
if (player.getLocation().add(x, -0.5, z).getBlock().getType() != Material.AIR)
return true;
//fences/walls
Material beneath = player.getLocation().add(x, -1.5, z).getBlock().getType();
if (player.getLocation().getY() % 0.5 == 0 &&
(beneath == Material.FENCE ||
beneath == Material.NETHER_FENCE ||
beneath == Material.COBBLE_WALL))
return true;
}
}

View File

@ -172,7 +172,7 @@ public class AntiHack extends MiniPlugin
(_ignore.containsKey(player) && System.currentTimeMillis() < _ignore.get(player))) //Ignore
{
_speedTicks.remove(player);
return;
return;
}
UpdateSpeed(player, event);

View File

@ -70,6 +70,16 @@ public class Chat extends MiniPlugin
}
}
@EventHandler
public void lagTest(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().equals("lag") || event.getMessage().equals("ping"))
{
event.getPlayer().sendMessage(F.main(GetName(), "PONG!"));
event.setCancelled(true);
}
}
@EventHandler
public void SilenceUpdate(UpdateEvent event)
{

View File

@ -16,6 +16,6 @@ public class FilterChatCommand extends CommandBase<Chat>
@Override
public void Execute(Player caller, String[] args)
{
Plugin.Get(caller).ToggleFilterChat();
//Plugin.Get(caller).ToggleFilterChat();
}
}

View File

@ -273,7 +273,7 @@ public class Explosion extends MiniPlugin
return _explosionBlocks;
}
public void BlockExplosion(Collection<Block> blockSet, Location mid)
public void BlockExplosion(Collection<Block> blockSet, Location mid, boolean onlyAbove)
{
if (blockSet.isEmpty())
return;
@ -286,10 +286,13 @@ public class Explosion extends MiniPlugin
if (cur.getTypeId() == 0)
continue;
if (onlyAbove && cur.getY() < mid.getY())
continue;
blocks.put(cur, new AbstractMap.SimpleEntry<Integer, Byte>(cur.getTypeId(), cur.getData()));
if (cur.getTypeId() != 98 || cur.getData() != 0)
cur.setTypeId(0);
cur.setType(Material.AIR);
}
//DELAY

View File

@ -4,12 +4,12 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/bukkit.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.ClassCombat"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-codec-1.6.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Core"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,202 +0,0 @@
package mineplex.hub;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEnderDragon;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
public class Dragon extends MiniPlugin
{
HubManager Manager;
public EnderDragon Dragon = null;
public Entity TargetEntity = null;
public Location Target = null;
public Location Location = null;
public float Pitch = 0;
public Vector Velocity = new Vector(0,0,0);
public double RangeBest = 1000;
public long RangeTime = 0;
public int textA = 0;
public int textB = 0;
public Dragon(HubManager manager)
{
super("Dragon Manager", manager.GetPlugin());
Manager = manager;
}
public void Spawn()
{
if (Dragon != null)
Dragon.remove();
if (UtilServer.getPlayers().length == 0)
return;
if (!Manager.GetSpawn().getWorld().isChunkLoaded(Manager.GetSpawn().getChunk()))
return;
for (Entity ent : Manager.GetSpawn().getWorld().getEntities())
{
if (ent instanceof EnderDragon)
ent.remove();
}
Dragon = Manager.GetSpawn().getWorld().spawn(Manager.GetSpawn().add(0, 50, 0), EnderDragon.class);
UtilEnt.Vegetate(Dragon);
Dragon.setCustomName(C.cGreen + C.Bold + "The Mineplex Dragon");
Velocity = Dragon.getLocation().getDirection().setY(0).normalize();
Pitch = UtilAlg.GetPitch(Dragon.getLocation().getDirection());
Location = Dragon.getLocation();
TargetSky();
}
@EventHandler
public void MoveUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (Dragon == null || !Dragon.isValid())
{
//Spawn();
return;
}
Turn();
Location.add(Velocity);
Location.add(0, -Pitch, 0);
Location.setPitch(-1 * Pitch);
Location.setYaw(180 + UtilAlg.GetYaw(Velocity));
((CraftEnderDragon)Dragon).getHandle().setTargetBlock(Location.getBlockX(), Location.getBlockY(), Location.getBlockZ());
}
@EventHandler
public void ColorEvent(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
return;
if (Dragon == null || !Dragon.isValid())
return;
ChatColor aCol = ChatColor.RED;
if (textA == 1) aCol = ChatColor.GOLD;
else if (textA == 2) aCol = ChatColor.YELLOW;
else if (textA == 3) aCol = ChatColor.GREEN;
else if (textA == 4) aCol = ChatColor.AQUA;
else if (textA == 5) aCol = ChatColor.LIGHT_PURPLE;
textA = (textA+1)%6;
ChatColor bCol = ChatColor.GREEN;
if (textB > 6) bCol = ChatColor.WHITE;
textB = (textB+1)%14;
Dragon.setCustomName(aCol + C.Bold + C.Line + Manager.DragonTextA +ChatColor.RESET + " - " + bCol + C.Bold + C.Line + Manager.DragonTextB);
}
private void Turn()
{
//Pitch
float desiredPitch = UtilAlg.GetPitch(UtilAlg.getTrajectory(Location, Target));
if (desiredPitch < Pitch) Pitch = (float)(Pitch - 0.05);
if (desiredPitch > Pitch) Pitch = (float)(Pitch + 0.05);
if (Pitch > 0.5) Pitch = 0.5f;
if (Pitch < -0.5) Pitch = -0.5f;
//Flat
Vector desired = UtilAlg.getTrajectory2d(Location, Target);
desired.subtract(UtilAlg.Normalize(new Vector(Velocity.getX(), 0, Velocity.getZ())));
desired.multiply(0.075);
Velocity.add(desired);
//Speed
UtilAlg.Normalize(Velocity);
}
public void Target()
{
if (TargetEntity != null)
{
if (!TargetEntity.isValid())
{
TargetEntity = null;
}
else
{
Target = TargetEntity.getLocation().subtract(0, 8, 0);
}
return;
}
if (Target == null)
{
TargetSky();
}
if (UtilMath.offset(Location, Target) < 10)
{
TargetSky();
}
TargetTimeout();
}
public void TargetTimeout()
{
if (UtilMath.offset(Location, Target)+1 < RangeBest)
{
RangeTime = System.currentTimeMillis();
RangeBest = UtilMath.offset(Location, Target);
}
else
{
if (UtilTime.elapsed(RangeTime, 10000))
{
TargetSky();
}
}
}
public void TargetSky()
{
RangeBest = 9000;
RangeTime = System.currentTimeMillis();
Target = Manager.GetSpawn().add(40 - UtilMath.r(80), 50 + UtilMath.r(30), 40 - UtilMath.r(80));
System.out.println("Dragon flying to: " + UtilWorld.locToStrClean(Target));
}
}

View File

@ -80,10 +80,10 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
new PetManager(this, clientManager, donationManager, creature, GetWebServerAddress());
//Main Modules
PacketHandler packetHandler = new PacketHandler(this);
PacketHandler packetHandler = new PacketHandler(this);
Portal portal = new Portal(this);
PartyManager partyManager = new PartyManager(this, clientManager);
HubManager hubManager = new HubManager(this, clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager);
new ServerManager(this, clientManager, donationManager, portal, partyManager, new ServerStatusManager(this, new LagMeter(this, clientManager)), hubManager, new StackerManager(hubManager));
new Chat(this, clientManager);
new MemoryFix(this);

View File

@ -38,6 +38,7 @@ import org.bukkit.scoreboard.Scoreboard;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -62,6 +63,9 @@ import mineplex.minecraft.game.core.condition.ConditionManager;
public class HubManager extends MiniClientPlugin<HubClient>
{
public String Mode = "Halloween";
private BlockRestore _blockRestore;
private CoreClientManager _clientManager;
private ConditionManager _conditionManager;
private DonationManager _donationManager;
@ -86,10 +90,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
private boolean _shuttingDown;
public HubManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager)
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager)
{
super("Hub Manager", plugin);
_blockRestore = blockRestore;
_clientManager = clientManager;
_conditionManager = conditionManager;
_donationManager = donationManager;
@ -105,6 +110,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
new MapManager(this);
new WorldManager(this);
new JumpManager(this);
new NewsManager(this);
new GadgetManager(this);
@ -540,6 +546,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
{
return new HubClient(player);
}
public BlockRestore GetBlockRestore()
{
return _blockRestore;
}
public CoreClientManager GetClients()
{

View File

@ -6,6 +6,8 @@ import org.bukkit.entity.Player;
import mineplex.core.MiniPlugin;
import mineplex.hub.HubManager;
import mineplex.hub.gadget.gadgets.Halloween2013_BatGun;
import mineplex.hub.gadget.gadgets.Halloween2013_Helmet;
import mineplex.hub.gadget.types.ArmorGadget;
import mineplex.hub.gadget.types.ArmorGadget.ArmorSlot;
import mineplex.hub.gadget.types.Gadget;
@ -29,6 +31,9 @@ public class GadgetManager extends MiniPlugin
private void CreateGadgets()
{
_gadgets = new HashSet<Gadget>();
_gadgets.add(new Halloween2013_BatGun(this));
_gadgets.add(new Halloween2013_Helmet(this));
}
//Disallows two armor gadgets in same slot.

View File

@ -25,6 +25,8 @@ public abstract class Gadget implements Listener
_code = code;
_name = name;
Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin());
}
public String GetName()
@ -53,8 +55,6 @@ public abstract class Gadget implements Listener
if (event.getPlayer().isOp())
{
_owners.add(event.getPlayer());
this.Enable(event.getPlayer());
}
}

View File

@ -0,0 +1,71 @@
package mineplex.hub.modules;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilDisplay;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
public class NewsManager extends MiniPlugin
{
public HubManager Manager;
private String[] _news;
private int _newsIndex = 0;
private long _newsTime = System.currentTimeMillis();
private int _mineplexIndex = 0;
public NewsManager(HubManager manager)
{
super("News Manager", manager.GetPlugin());
Manager = manager;
_news = new String[]
{
"New Game: " + C.cRed + C.Bold + "Halloween Horror" + ChatColor.RESET + "! Limited time!",
"Halloween Hub Gadgets! Unlockable for limited time!",
"New Super Smash Mobs Kit: " + C.cYellow + C.Bold + "Witch" + ChatColor.RESET + "!"
};
}
@EventHandler
public void FlightUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
return;
//Mineplex Color
ChatColor col = ChatColor.RED;
if (_mineplexIndex == 1) col = ChatColor.GOLD;
else if (_mineplexIndex == 2) col = ChatColor.YELLOW;
else if (_mineplexIndex == 3) col = ChatColor.GREEN;
else if (_mineplexIndex == 4) col = ChatColor.AQUA;
else if (_mineplexIndex == 5) col = ChatColor.LIGHT_PURPLE;
_mineplexIndex = (_mineplexIndex + 1)%6;
//News Change
if (UtilTime.elapsed(_newsTime, 3000))
{
_newsIndex = (_newsIndex + 1)%_news.length;
_newsTime = System.currentTimeMillis();
}
//Text
String text = col + C.Bold + "MINEPLEX" + ChatColor.RESET + " - " + _news[_newsIndex];
if (text.length() > 64)
text = text.substring(0, 64);
for (Player player : UtilServer.getPlayers())
UtilDisplay.displayTextBar(Manager.GetPlugin(), player, (double)_newsIndex/(double)(_news.length-1), text);
}
}

View File

@ -4,21 +4,31 @@ import java.util.HashSet;
import java.util.Iterator;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import net.minecraft.server.v1_6_R3.EntitySkeleton;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftSkeleton;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
@ -34,14 +44,14 @@ public class WorldManager extends MiniPlugin
public HubManager Manager;
private HashSet<LivingEntity> _mobs = new HashSet<LivingEntity>();
public WorldManager(HubManager manager)
{
super("World Manager", manager.GetPlugin());
Manager = manager;
}
@EventHandler
public void SpawnAnimals(UpdateEvent event)
{
@ -75,13 +85,30 @@ public class WorldManager extends MiniPlugin
else loc.add(0, 0.5, -32);
//Spawn
r = Math.random();
if (Manager.Mode.equals("Halloween"))
{
Skeleton ent = loc.getWorld().spawn(loc, Skeleton.class);
if (r > 0.66) _mobs.add(loc.getWorld().spawn(loc, Cow.class));
else if (r > 0.33) _mobs.add(loc.getWorld().spawn(loc, Pig.class));
else _mobs.add(loc.getWorld().spawn(loc, Chicken.class));
if (Math.random() > 0.5)
ent.setSkeletonType(SkeletonType.WITHER);
ent.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN));
_mobs.add(ent);
Manager.GetCondition().Factory().Invisible("Perm", ent, ent, 999999999, 0, false, false, true);
Manager.GetCondition().Factory().Slow("Perm", ent, ent, 999999999, 1, false, false, false, true);
}
else
{
r = Math.random();
if (r > 0.66) _mobs.add(loc.getWorld().spawn(loc, Cow.class));
else if (r > 0.33) _mobs.add(loc.getWorld().spawn(loc, Pig.class));
else _mobs.add(loc.getWorld().spawn(loc, Chicken.class));
}
}
@EventHandler
public void BlockBreak(BlockBreakEvent event)
{
@ -102,7 +129,7 @@ public class WorldManager extends MiniPlugin
{
event.setCancelled(true);
}
@EventHandler
public void LeaveDecay(LeavesDecayEvent event)
{
@ -134,7 +161,7 @@ public class WorldManager extends MiniPlugin
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void ItemPickup(PlayerPickupItemEvent event)
{
@ -152,15 +179,56 @@ public class WorldManager extends MiniPlugin
event.setCancelled(true);
}
@EventHandler
public void UpdateWeather(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
if (event.getType() != UpdateType.TICK)
return;
World world = UtilWorld.getWorld("world");
world.setTime(6000);
if (Manager.Mode.equals("Halloween")) world.setTime(16000);
else world.setTime(6000);
world.setStorm(false);
}
@EventHandler
public void HalloweenUpdates(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!Manager.Mode.equals("Halloween"))
return;
//Block Lightup
for (Player player : UtilServer.getPlayers())
{
for (Block block : UtilBlock.getInRadius(player.getLocation(), 3d).keySet())
{
if (block.getType() == Material.PUMPKIN)
Manager.GetBlockRestore().Add(block, 91, block.getData(), 2000);
}
}
//Mob Helmets
for (LivingEntity ent : _mobs)
{
if (!(ent instanceof Creature))
continue;
Creature skel = (Creature)ent;
if (skel.getTarget() != null && skel.getTarget() instanceof Player && UtilMath.offset(skel, skel.getTarget()) < 6)
{
skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.JACK_O_LANTERN));
}
else
{
skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN));
}
}
}
}

View File

@ -5,7 +5,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core.CraftBukkit"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/bin/craftbukkit.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -3,8 +3,8 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core.CraftBukkit"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -2,12 +2,12 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core.CraftBukkit"/>
<classpathentry combineaccessrules="false" kind="src" path="/Core"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -14,6 +14,7 @@ import nautilus.game.arcade.game.games.dragonescape.DragonEscape;
import nautilus.game.arcade.game.games.dragonriders.DragonRiders;
import nautilus.game.arcade.game.games.dragons.Dragons;
import nautilus.game.arcade.game.games.evolution.Evolution;
import nautilus.game.arcade.game.games.halloween.Halloween;
import nautilus.game.arcade.game.games.hungergames.HungerGames;
import nautilus.game.arcade.game.games.milkcow.MilkCow;
import nautilus.game.arcade.game.games.mineware.MineWare;
@ -50,6 +51,7 @@ public class GameFactory
else if (gameType == GameType.DragonEscape) return new DragonEscape(_manager);
else if (gameType == GameType.DragonRiders) return new DragonRiders(_manager);
else if (gameType == GameType.Evolution) return new Evolution(_manager);
else if (gameType == GameType.Halloween) return new Halloween(_manager);
else if (gameType == GameType.HungerGames) return new HungerGames(_manager);
else if (gameType == GameType.MineWare) return new MineWare(_manager);
else if (gameType == GameType.MilkCow) return new MilkCow(_manager);

View File

@ -12,6 +12,7 @@ public enum GameType
DragonRiders("Dragon Riders"),
Dragons("Dragons"),
Evolution("Evolution"),
Halloween("Halloween Horror"),
Horse("Horseback"),
HungerGames("Hunger Games"),
MineWare("MineWare"),

View File

@ -149,7 +149,7 @@ public class DragonEscape extends SoloGame
_dragonData.Move();
Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(_dragonData.Location, 10d).keySet(), _dragonData.Location);
Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(_dragonData.Location, 10d).keySet(), _dragonData.Location, false);
}
@EventHandler

View File

@ -66,8 +66,6 @@ public class DragonEscapeData
Location.setYaw(180 + UtilAlg.GetYaw(Velocity));
Dragon.teleport(Location);
System.out.println("Flying towards: " + UtilWorld.locToStrClean(Target));
}
private void Turn()

View File

@ -53,7 +53,7 @@ public class DragonData
{
((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ());
Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(Dragon.getLocation(), 10d).keySet(), Dragon.getLocation());
Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(Dragon.getLocation(), 10d).keySet(), Dragon.getLocation(), false);
}
public Location GetTarget()

View File

@ -0,0 +1,279 @@
package nautilus.game.arcade.game.games.halloween;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
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.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.halloween.creatures.*;
import nautilus.game.arcade.game.games.halloween.kits.KitDefault;
import nautilus.game.arcade.game.games.spleef.kits.*;
import nautilus.game.arcade.kit.Kit;
public class Halloween extends SoloGame
{
private ArrayList<ArrayList<Location>> _spawns;
private int _spawnWave = 0;
private int _spawnTick = 0;
private String _waveName = "";
private int _wave = 0;
private long _waveStart = 0;
private long _waveDuration = 0;
private PumpkinKing _king;
private HashSet<CreatureBase> _mobs = new HashSet<CreatureBase>();
public Halloween(ArcadeManager manager)
{
super(manager, GameType.Halloween,
new Kit[]
{
new KitDefault(manager)
},
new String[]
{
"Work as a team!",
"Revive fallen allies!",
"Defeat the hordes of monsters"
});
this.DamagePvP = false;
this.WorldTimeSet = 16000;
this.ItemDrop = true;
this.ItemPickup = true;
this.PrepareFreeze = false;
}
@Override
public void ParseData()
{
_spawns = new ArrayList<ArrayList<Location>>();
_spawns.add(WorldData.GetDataLocs("RED"));
_spawns.add(WorldData.GetDataLocs("YELLOW"));
_spawns.add(WorldData.GetDataLocs("GREEN"));
_spawns.add(WorldData.GetDataLocs("BLUE"));
}
@EventHandler
public void TeamGen(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
return;
GetTeamList().add(new GameTeam("Halloween Monsters", ChatColor.RED, WorldData.GetDataLocs("RED")));
}
@EventHandler
public void SoundUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
return;
if (!IsLive())
return;
if (Math.random() > 0.85)
return;
for (Player player : UtilServer.getPlayers())
player.playSound(player.getLocation(), Sound.AMBIENCE_CAVE, 3f, 1f);
}
@EventHandler
public void UpdateWave(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!IsLive())
return;
//Display Remaining Time
if (_wave > 0)
for (Player player : UtilServer.getPlayers())
{
player.setExp(Math.min(0.999f, (float)(_waveDuration - (System.currentTimeMillis() - _waveStart)) / (float)_waveDuration));
player.setLevel(_wave);
}
if (!UtilTime.elapsed(_waveStart, _waveDuration) || (_wave == 4 && !_king.GetEntity().isValid()))
return;
_wave = _wave + 1;
_waveStart = System.currentTimeMillis();
_waveDuration = 60000;
_spawnTick = 0;
_spawnWave = UtilMath.r(_spawns.size());
if (_wave == 1) _waveName = "Zombies, Skeletons and Creepers, OH MY!";
if (_wave == 2) _waveName = "A Giant? Better kill that guy!";
if (_wave == 3) _waveName = "SPIDERS SPIDERS SPIDERS!!!!!";
if (_wave == 4) _waveName = "THE SKELETON KING EMERGES";
if (_wave <= 4)
Announce(C.cRed + C.Bold + "Wave " + _wave + ": " + C.cYellow + _waveName);
}
public Location GetSpawn()
{
return _spawns.get(_spawnWave).get(UtilMath.r(_spawns.get(_spawnWave).size()));
}
@EventHandler
public void SpawnCreatures(UpdateEvent event)
{
//Boss Swarm
if (event.getType() == UpdateType.SEC && _wave == 4 && _mobs.size() < 20)
{
Location loc = _spawns.get(UtilMath.r(_spawns.size())).get(UtilMath.r(_spawns.get(_spawnWave).size()));
_mobs.add(new MobZombie(this, loc));
}
if (event.getType() != UpdateType.FAST)
return;
if (!IsLive())
return;
this.CreatureAllowOverride = true;
//Plain
if (_wave == 1)
{
if (UtilTime.elapsed(_waveStart, 12000 + (_wave * 2000)))
return;
_mobs.add(new MobZombie(this, GetSpawn()));
if (_spawnTick % 3 == 0)
_mobs.add(new MobSkeletonArcher(this, GetSpawn()));
if (_spawnTick % 5 == 0)
_mobs.add(new MobCreeper(this, GetSpawn()));
}
//Single Giant
if (_wave == 2)
{
_mobs.add(new MobZombie(this, GetSpawn()));
if (_spawnTick % 3 == 0)
_mobs.add(new MobSkeletonArcher(this, GetSpawn()));
if (_spawnTick % 5 == 0)
_mobs.add(new MobCreeper(this, GetSpawn()));
if (_spawnTick == 0)
_mobs.add(new MobGiant(this, GetSpawn()));
}
//Spiders
if (_wave == 3)
{
_mobs.add(new MobSpider(this, GetSpawn()));
_mobs.add(new MobSpider(this, GetSpawn()));
}
//Quad Giant
if (_wave == 4)
{
if (_spawnTick == 0)
{
_waveDuration = 900000;
_king = new PumpkinKing(this, WorldData.GetDataLocs("BLACK").get(0));
_mobs.add(_king);
}
}
this.CreatureAllowOverride = false;
_spawnTick++;
}
@EventHandler
public void CreatureUpdate(UpdateEvent event)
{
if (!IsLive())
return;
//Clean
Iterator<CreatureBase> mobIterator = _mobs.iterator();
while (mobIterator.hasNext())
{
CreatureBase base = mobIterator.next();
if (base.Updater(event))
mobIterator.remove();
}
}
@EventHandler
public void CreatureDamage(CustomDamageEvent event)
{
for (CreatureBase base : _mobs)
base.Damage(event);
}
@EventHandler
public void CreatureTarget(EntityTargetEvent event)
{
for (CreatureBase base : _mobs)
base.Target(event);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void EntityDeath(EntityDeathEvent event)
{
event.getDrops().clear();
}
@Override
public void EndCheck()
{
if (!IsLive())
return;
if (_wave == 5)
{
SetState(GameState.End);
SetCustomWinLine("You defeated the Pumpkin King!!!");
AnnounceEnd(this.GetTeamList().get(0));
return;
}
if (GetPlayers(true).size() == 0)
{
SetState(GameState.End);
SetCustomWinLine("The Pumpkin King is victorious again!");
AnnounceEnd(this.GetTeamList().get(1));
return;
}
}
}

View File

@ -0,0 +1,20 @@
package nautilus.game.arcade.game.games.halloween;
import org.bukkit.Location;
public class TargetData
{
public Location Target;
public long Time;
public TargetData(Location target)
{
SetTarget(target);
}
public void SetTarget(Location target)
{
Target = target;
Time = System.currentTimeMillis();
}
}

View File

@ -0,0 +1,110 @@
package nautilus.game.arcade.game.games.halloween.creatures;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.util.Vector;
public abstract class CreatureBase<T extends LivingEntity>
{
public Game Host;
private String _name;
private T _ent;
private Location _target;
private long _targetTime;
public CreatureBase(Game game, String name, Class<T> mobClass, Location loc)
{
Host = game;
_name = name;
game.CreatureAllowOverride = true;
_ent = loc.getWorld().spawn(loc, mobClass);
if (_name != null)
{
_ent.setCustomName(name);
_ent.setCustomNameVisible(true);
}
SpawnCustom(_ent);
game.CreatureAllowOverride = false;
}
public abstract void SpawnCustom(T ent);
public String GetName()
{
return _name;
}
public T GetEntity()
{
return _ent;
}
public Location GetTarget()
{
return _target;
}
public void SetTarget(Location loc)
{
_target = loc;
_targetTime = System.currentTimeMillis();
}
public long GetTargetTime()
{
return _targetTime;
}
public Location GetPlayerTarget()
{
if (Host.GetPlayers(true).size() == 0)
{
return Host.GetTeamList().get(0).GetSpawn();
}
else
{
Player target = Host.GetPlayers(true).get(UtilMath.r(Host.GetPlayers(true).size()));
return target.getLocation();
}
}
public Location GetRoamTarget()
{
Vector vec = new Vector(UtilMath.r(80) - 40, 0, UtilMath.r(80) - 40);
return vec.toLocation(Host.GetSpectatorLocation().getWorld());
}
public boolean Updater(UpdateEvent event)
{
if (_ent == null || !_ent.isValid())
{
System.out.println(_ent.getType() + " INVALID");
return true;
}
Update(event);
return false;
}
public abstract void Update(UpdateEvent event);
public abstract void Damage(CustomDamageEvent event);
public abstract void Target(EntityTargetEvent event);
}

View File

@ -0,0 +1,87 @@
package nautilus.game.arcade.game.games.halloween.creatures;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
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.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Creeper;
import org.bukkit.event.entity.EntityTargetEvent;
public class MobCreeper extends CreatureBase<Creeper>
{
public MobCreeper(Game game, Location loc)
{
super(game, null, Creeper.class, loc);
}
@Override
public void SpawnCustom(Creeper ent)
{
}
@Override
public void Damage(CustomDamageEvent event)
{
}
@Override
public void Target(EntityTargetEvent event)
{
}
@Override
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
//New Target via Distance
if (GetTarget() == null ||
UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 ||
UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 ||
UtilTime.elapsed(GetTargetTime(), 10000))
{
SetTarget(GetRoamTarget());
return;
}
//Untarget
if (GetEntity().getTarget() != null)
{
if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10)
{
GetEntity().setTarget(null);
}
}
//Move
else
{
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f);
}
}
}
}

View File

@ -0,0 +1,57 @@
package nautilus.game.arcade.game.games.halloween.creatures;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game;
import org.bukkit.Location;
import org.bukkit.entity.Ghast;
import org.bukkit.event.entity.EntityTargetEvent;
public class MobGhast extends CreatureBase<Ghast>
{
public MobGhast(Game game, Location loc)
{
super(game, null, Ghast.class, loc);
}
@Override
public void SpawnCustom(Ghast ent)
{
ent.teleport(new Location(ent.getWorld(), 0, 50, 0));
}
@Override
public void Damage(CustomDamageEvent event)
{
}
@Override
public void Target(EntityTargetEvent event)
{
}
@Override
public void Update(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
Move();
if (event.getType() == UpdateType.FASTER)
Destroy();
}
private void Destroy()
{
Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 8, 0), 6d).keySet(), GetEntity().getLocation().add(0, 8, 0), false);
}
private void Move()
{
}
}

View File

@ -0,0 +1,85 @@
package nautilus.game.arcade.game.games.halloween.creatures;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
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.game.Game;
import org.bukkit.Location;
import org.bukkit.entity.Giant;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.util.Vector;
public class MobGiant extends CreatureBase<Giant>
{
private Location _tpLoc;
public MobGiant(Game game, Location loc)
{
super(game, null, Giant.class, loc);
}
@Override
public void SpawnCustom(Giant ent)
{
_tpLoc = ent.getLocation();
}
@Override
public void Damage(CustomDamageEvent event)
{
}
@Override
public void Target(EntityTargetEvent event)
{
}
@Override
public void Update(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
Move();
if (event.getType() == UpdateType.FASTER)
Destroy();
}
private void Destroy()
{
Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 8, 0), 6d).keySet(), GetEntity().getLocation().add(0, 8, 0), false);
Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 2, 0), 3.5d).keySet(), GetEntity().getLocation(), true);
Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 0, 0), 3.5d).keySet(), GetEntity().getLocation(), true);
}
private void Move()
{
//New Target via Distance
if (GetTarget() == null ||
UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 0.5 ||
UtilTime.elapsed(GetTargetTime(), 20000))
{
SetTarget(GetPlayerTarget());
return;
}
if (_tpLoc == null)
_tpLoc = GetEntity().getLocation();
Vector dir = UtilAlg.getTrajectory2d(GetEntity().getLocation(), GetTarget());
_tpLoc.setPitch(UtilAlg.GetPitch(dir));
_tpLoc.setYaw(UtilAlg.GetYaw(dir));
_tpLoc.add(dir.multiply(0.1));
//Move
GetEntity().teleport(_tpLoc);
}
}

View File

@ -0,0 +1,89 @@
package nautilus.game.arcade.game.games.halloween.creatures;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
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.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Skeleton;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.inventory.ItemStack;
public class MobSkeletonArcher extends CreatureBase<Skeleton>
{
public MobSkeletonArcher(Game game, Location loc)
{
super(game, null, Skeleton.class, loc);
}
@Override
public void SpawnCustom(Skeleton ent)
{
ent.getEquipment().setItemInHand(new ItemStack(Material.BOW));
}
@Override
public void Damage(CustomDamageEvent event)
{
}
@Override
public void Target(EntityTargetEvent event)
{
}
@Override
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
//New Target via Distance
if (GetTarget() == null ||
UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 ||
UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 ||
UtilTime.elapsed(GetTargetTime(), 10000))
{
SetTarget(GetRoamTarget());
return;
}
//Untarget
if (GetEntity().getTarget() != null)
{
if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10)
{
GetEntity().setTarget(null);
}
}
//Move
else
{
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f);
}
}
}
}

View File

@ -0,0 +1,112 @@
package nautilus.game.arcade.game.games.halloween.creatures;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
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.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Spider;
import org.bukkit.event.entity.EntityTargetEvent;
public class MobSpider extends CreatureBase<Spider>
{
public MobSpider(Game game, Location loc)
{
super(game, null, Spider.class, loc);
}
@Override
public void SpawnCustom(Spider ent)
{
}
@Override
public void Damage(CustomDamageEvent event)
{
}
@Override
public void Target(EntityTargetEvent event)
{
}
@Override
public void Update(UpdateEvent event)
{
if (event.getType() == UpdateType.FAST)
Move();
if (event.getType() == UpdateType.SEC)
Leap();
}
private void Leap()
{
if (GetTarget() == null)
return;
if (Math.random() > 0.5)
return;
if (!UtilEnt.isGrounded(GetEntity()))
return;
if (GetEntity().getTarget() != null)
UtilAction.velocity(GetEntity(), UtilAlg.getTrajectory2d(GetEntity(), GetEntity().getTarget()), 1, true, 0.6, 0, 10, true);
else
UtilAction.velocity(GetEntity(), UtilAlg.getTrajectory2d(GetEntity().getLocation(), GetTarget()), 1, true, 0.6, 0, 10, true);
}
private void Move()
{
//New Target via Distance
if (GetTarget() == null ||
UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 ||
UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 ||
UtilTime.elapsed(GetTargetTime(), 10000))
{
SetTarget(GetRoamTarget());
return;
}
//Untarget
if (GetEntity().getTarget() != null)
{
if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10)
{
GetEntity().setTarget(null);
}
}
//Move
else
{
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1.6f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1.2f);
}
}
}
}

View File

@ -0,0 +1,87 @@
package nautilus.game.arcade.game.games.halloween.creatures;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
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.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.EntityTargetEvent;
public class MobZombie extends CreatureBase<Zombie>
{
public MobZombie(Game game, Location loc)
{
super(game, null, Zombie.class, loc);
}
@Override
public void SpawnCustom(Zombie ent)
{
}
@Override
public void Damage(CustomDamageEvent event)
{
}
@Override
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
//New Target via Distance
if (GetTarget() == null ||
UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 ||
UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 ||
UtilTime.elapsed(GetTargetTime(), 10000))
{
SetTarget(GetRoamTarget());
return;
}
//Untarget
if (GetEntity().getTarget() != null)
{
if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10)
{
GetEntity().setTarget(null);
}
}
//Move
else
{
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1.6f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1.2f);
}
}
}
@Override
public void Target(EntityTargetEvent event)
{
}
}

View File

@ -0,0 +1,673 @@
package nautilus.game.arcade.game.games.halloween.creatures;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilDisplay;
import mineplex.core.common.util.UtilEnt;
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.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game;
import net.minecraft.server.v1_6_R3.EntityArrow;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftArrow;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.MagmaCube;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class PumpkinKing extends CreatureBase<Skeleton>
{
private int _state = 0;
private long _stateTime = System.currentTimeMillis();
private ArrayList<Skeleton> _minions = new ArrayList<Skeleton>();
private int _minionsMax = 12; //12
private HashMap<Entity, Player> _minionTargets = new HashMap<Entity, Player>();
private boolean _minionSpawn = true;
private ArrayList<Slime> _shields = new ArrayList<Slime>();
private int _shieldsMax = 6; //6
private long _shieldSpawn = 0;
private Location _kingLocation;
private Player _kingTarget = null;
private HashSet<Arrow> _arrows = new HashSet<Arrow>();
public PumpkinKing(Game game, Location loc)
{
super(game, null, Skeleton.class, loc);
_kingLocation = loc;
}
@Override
public void SpawnCustom(Skeleton ent)
{
ent.setSkeletonType(SkeletonType.WITHER);
ent.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
ent.setMaxHealth(200);
ent.setHealth(ent.getMaxHealth());
ent.getWorld().strikeLightningEffect(ent.getLocation());
ent.getWorld().strikeLightningEffect(ent.getLocation());
ent.getWorld().strikeLightningEffect(ent.getLocation());
}
@Override
public void Damage(CustomDamageEvent event)
{
//Attacked King
if (event.GetDamageeEntity().equals(GetEntity()))
{
if (_shields.size() > 0)
{
event.SetCancelled("Shielded");
UtilPlayer.message(event.GetDamagerPlayer(true), F.main("Boss", "You must destroy " + F.elem("Flame Shields") + " first!"));
}
else if (_minions.size() > 0)
{
event.SetCancelled("Shielded");
UtilPlayer.message(event.GetDamagerPlayer(true), F.main("Boss", "You must destroy " + F.elem("Pumpkin Minions") + " first!"));
}
if (event.GetCause() == DamageCause.ENTITY_EXPLOSION)
event.SetCancelled("Explosion Resist");
event.SetKnockback(false);
}
//Attacked Minion
else if (_minions.contains(event.GetDamageeEntity()))
{
if (_shields.size() > 0)
{
event.SetCancelled("Shielded");
UtilPlayer.message(event.GetDamagerPlayer(true), F.main("Boss", "You must destroy " + F.elem("Flame Shields") + " first!"));
}
else if (event.GetProjectile() != null)
{
event.SetCancelled("Projectile");
UtilPlayer.message(event.GetDamagerPlayer(true), F.main("Boss", "Projectiles cannot harm " + F.elem("Pumpkin Minions") + "!"));
}
}
//Attacked Shield
else if (_shields.contains(event.GetDamageeEntity()))
{
event.SetCancelled("Shield Break");
if (event.GetProjectile() == null)
return;
event.GetProjectile().remove();
//Effect
Host.Manager.GetBlood().Effects(event.GetDamageeEntity().getLocation(), 10, 0.2, null, 0f, 0f, Material.FIRE, (byte)0, 10, false);
event.GetDamageeEntity().getWorld().playEffect(event.GetDamageeEntity().getLocation(), Effect.STEP_SOUND, 51);
//Remove
_shields.remove(event.GetDamageeEntity());
event.GetDamageeEntity().remove();
//Health
KingUpdateHealth();
//Shield Spawn Delay
_shieldSpawn = System.currentTimeMillis();
}
}
@Override
public void Update(UpdateEvent event)
{
//Main
if (event.getType() == UpdateType.FASTER)
StateUpdate();
if (event.getType() == UpdateType.FAST)
KingDestroyBlocks();
if (event.getType() == UpdateType.TICK)
KingUpdateHealth();
//Minions
if (event.getType() == UpdateType.TICK)
MinionControl();
if (event.getType() == UpdateType.FASTEST)
MinionArrow();
if (event.getType() == UpdateType.FAST)
MinionSpawn();
//Final
if (event.getType() == UpdateType.FAST)
KingControl();
if (event.getType() == UpdateType.SEC)
KingLeap();
if (event.getType() == UpdateType.SEC)
KingBomb();
if (event.getType() == UpdateType.SLOW)
KingTarget();
//Shield
if (event.getType() == UpdateType.TICK)
ShieldOrbit(false);
if (event.getType() == UpdateType.FAST)
ShieldSpawn();
}
private void KingTarget()
{
if (Math.random() > 0.25)
_kingTarget = GetRandomPlayer();
}
private void KingControl()
{
if (GetState() >= 4)
{
if (_kingTarget == null)
_kingTarget = GetRandomPlayer();
GetEntity().setTarget(_kingTarget);
Location loc = _kingTarget.getLocation();
if (UtilMath.offset(loc, GetEntity().getLocation()) > 16)
loc = GetEntity().getLocation().add(UtilAlg.getTrajectory(GetEntity().getLocation(), loc).multiply(16));
//Move
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle();
Navigation nav = ec.getNavigation();
nav.a(loc.getX(), loc.getY(), loc.getZ(), 1f);
}
else
{
GetEntity().teleport(_kingLocation);
}
}
private void KingLeap()
{
if (GetState() < 4)
return;
if (_kingTarget == null)
return;
if (Math.random() > 0.4)
return;
UtilAction.velocity(GetEntity(), UtilAlg.getTrajectory2d(GetEntity(), _kingTarget), 1.2, false, 0, 0.4, 10, true);
}
private void KingBomb()
{
if (GetState() < 4)
return;
if (_kingTarget == null)
return;
if (Math.random() > 0.4)
return;
TNTPrimed tnt = GetEntity().getWorld().spawn(GetEntity().getEyeLocation().add(GetEntity().getLocation().getDirection()), TNTPrimed.class);
Player target = GetRandomPlayer();
UtilAction.velocity(tnt, UtilAlg.getTrajectory(tnt, target), 1.2, false, 0, 0.4, 10, false);
}
private void KingUpdateHealth()
{
for (Player player : UtilServer.getPlayers())
{
if (_shields.size() > 0)
{
double percent = (double)_shields.size() / (double)_shieldsMax;
UtilDisplay.displayTextBar(Host.Manager.GetPlugin(), player, percent, C.cGold + C.Bold + "The Pumpkin King" + C.cWhite + C.Bold + " - " + C.cYellow + C.Bold + "Flame Shield");
}
else
{
if (_minions.size() > 0)
{
double percent = (double)_minions.size() / (double)_minionsMax;
UtilDisplay.displayTextBar(Host.Manager.GetPlugin(), player, percent, C.cGold + C.Bold + "The Pumpkin King" + C.cWhite + C.Bold + " - " + C.cYellow + C.Bold + "Pumpkin Soldiers");
}
else
{
double percent = GetEntity().getHealth()/GetEntity().getMaxHealth();
UtilDisplay.displayTextBar(Host.Manager.GetPlugin(), player, percent, C.cGold + C.Bold + "The Pumpkin King" + C.cWhite + C.Bold + " - " + C.cYellow + C.Bold + "Final Stage");
}
}
}
}
private void KingDestroyBlocks()
{
Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation(), 7d).keySet(), GetEntity().getLocation(), true);
}
@EventHandler
public void MinionSpawn()
{
Iterator<Skeleton> shieldIterator = _minions.iterator();
while (shieldIterator.hasNext())
{
Skeleton skel = shieldIterator.next();
if (!skel.isValid())
shieldIterator.remove();
}
if (!_minionSpawn)
return;
if (_minions.size() >= _minionsMax)
{
_minionSpawn = false;
return;
}
Host.CreatureAllowOverride = true;
Skeleton skel = GetEntity().getWorld().spawn(GetEntity().getLocation(), Skeleton.class);
Host.Manager.GetCondition().Factory().Invisible("Cloak", skel, skel, 999999, 0, false, false, false);
skel.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
skel.getEquipment().setItemInHand(new ItemStack(Material.BOW));
skel.setMaxHealth(50);
skel.setHealth(skel.getMaxHealth());
_minions.add(skel);
Host.CreatureAllowOverride = false;
}
public void MinionControl()
{
for (int i=0 ; i<_minions.size() ; i++)
{
Skeleton minion = _minions.get(i);
//Orbit
if (GetState() == 0 || GetState() == 1 || GetState() == 2)
{
minion.setTarget(null);
double lead = i * ((2d * Math.PI)/_minions.size());
double sizeMod = 2 + (_minions.size() / 12);
//Orbit
double speed = 20d;
double oX = Math.sin(GetEntity().getTicksLived()/speed + lead) * 2 * sizeMod;
double oY = 1;
double oZ = Math.cos(GetEntity().getTicksLived()/speed + lead) * 2 * sizeMod;
Location loc = GetEntity().getLocation().add(oX, oY, oZ);
if (UtilMath.offset(loc, minion.getLocation()) > 16)
loc = minion.getLocation().add(UtilAlg.getTrajectory(minion.getLocation(), GetEntity().getLocation().add(oX, oY, oZ)).multiply(16));
//Move
EntityCreature ec = ((CraftCreature)minion).getHandle();
Navigation nav = ec.getNavigation();
nav.a(loc.getX(), loc.getY(), loc.getZ(), 1.2f);
}
//Attack
else
{
LivingEntity target = _minionTargets.get(minion);
if (target == null)
continue;
minion.setTarget(target);
Location loc = target.getLocation();
if (UtilMath.offset(loc, minion.getLocation()) > 12)
loc = minion.getLocation().add(UtilAlg.getTrajectory(minion.getLocation(), loc).multiply(12));
//Move
EntityCreature ec = ((CraftCreature)minion).getHandle();
Navigation nav = ec.getNavigation();
nav.a(loc.getX(), loc.getY(), loc.getZ(), 1f);
}
}
}
public void MinionArrow()
{
//Clean
Iterator<Arrow> arrowIterator = _arrows.iterator();
while (arrowIterator.hasNext())
{
Arrow arrow = arrowIterator.next();
if (arrow.getTicksLived() > 200 || arrow.isOnGround())
{
if (arrow.isValid() && Math.random() > 0.90)
{
try
{
EntityArrow entityArrow = ((CraftArrow)arrow).getHandle();
Field fieldX = EntityArrow.class.getDeclaredField("d");
Field fieldY = EntityArrow.class.getDeclaredField("e");
Field fieldZ = EntityArrow.class.getDeclaredField("f");
fieldX.setAccessible(true);
fieldY.setAccessible(true);
fieldZ.setAccessible(true);
int x = fieldX.getInt(entityArrow);
int y = fieldY.getInt(entityArrow);
int z = fieldZ.getInt(entityArrow);
Block block = arrow.getWorld().getBlockAt(x, y, z);
if (block.getY() > GetEntity().getLocation().getY())
block.breakNaturally();
}
catch (Exception e)
{
e.printStackTrace();
}
}
arrow.remove();
arrowIterator.remove();
}
}
if (GetState() != 1)
return;
for (int i=0 ; i<_minions.size() ; i++)
{
Skeleton minion = _minions.get(i);
if (!minion.isValid())
continue;
Vector traj = UtilAlg.getTrajectory2d(GetEntity(), minion);
traj.add(new Vector(0,Math.random()*0.2,0));
Arrow arrow = GetEntity().getWorld().spawnArrow(minion.getEyeLocation().add(traj), traj, 2f, 16f);
arrow.setShooter(minion);
_arrows.add(arrow);
}
}
@EventHandler
public void ShieldSpawn()
{
if (GetState() == 3 || GetState() == 4)
return;
Iterator<Slime> shieldIterator = _shields.iterator();
while (shieldIterator.hasNext())
{
Slime slime = shieldIterator.next();
if (!slime.isValid())
shieldIterator.remove();
}
if (!UtilTime.elapsed(_shieldSpawn, 3000))
return;
if (_shields.size() >= _shieldsMax)
return;
//Delay
_shieldSpawn = System.currentTimeMillis();
int toSpawn = 1;
if (_shields.size() == 0)
toSpawn = _shieldsMax;
for (int i=0 ; i<toSpawn ; i++)
{
//Spawn
Host.CreatureAllowOverride = true;
MagmaCube ent = GetEntity().getWorld().spawn(GetEntity().getLocation().add(0, 6, 0), MagmaCube.class);
ent.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
_shields.add(ent);
UtilEnt.Vegetate(ent);
ent.setSize(1);
Host.CreatureAllowOverride = false;
//Orbit
ShieldOrbit(false);
}
}
public void ShieldOrbit(boolean teleport)
{
for (int i=0 ; i<_shields.size() ; i++)
{
Slime shield = _shields.get(i);
shield.setFireTicks(10);
double lead = i * ((2d * Math.PI)/_shields.size());
double sizeMod = 2;
//Orbit
double speed = 10d;
double oX = -Math.sin(GetEntity().getTicksLived()/speed + lead) * 2 * sizeMod;
double oY = 6;
double oZ = Math.cos(GetEntity().getTicksLived()/speed + lead) * 2 * sizeMod;
if (teleport)
{
shield.teleport(GetEntity().getLocation().add(oX, oY, oZ));
}
else
{
UtilAction.velocity(shield,
UtilAlg.getTrajectory(shield.getLocation(), GetEntity().getLocation().add(oX, oY, oZ)),
0.4, false, 0, 0.1, 1, true);
}
}
if (_shields.size() > 0)
GetEntity().getWorld().playEffect(GetEntity().getLocation().add(0, 6, 0), Effect.ENDER_SIGNAL, 0);
}
public int GetState()
{
return _state;
}
public void SetState(int state)
{
_state = state;
_stateTime = System.currentTimeMillis();
if (state == 3)
{
//Update Gear
for (int i=0 ; i<_minions.size() ; i++)
{
Skeleton minion = _minions.get(i);
minion.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
minion.getEquipment().setItemInHand(new ItemStack(Material.WOOD_AXE));
//Speed
Host.Manager.GetCondition().Factory().Speed("Minion Speed", minion, minion, 15, 0, false, false, false);
//Sound
GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.WITHER_SPAWN, 10f, 1.5f);
//Target
_minionTargets.put(minion, GetRandomPlayer());
}
}
}
public void StateUpdate()
{
if (GetEntity() == null)
return;
if (GetState() == 0)
{
if (UtilTime.elapsed(_stateTime, 10000))
{
double r = Math.random();
SetState(1);
}
}
//Outward Arrows
else if (GetState() == 1)
{
if (UtilTime.elapsed(_stateTime, 5000))
{
SetState(0);
}
}
//Upwards Arrows
else if (GetState() == 2)
{
if (UtilTime.elapsed(_stateTime, 5000))
{
SetState(0);
}
}
else if (GetState() == 3)
{
if (UtilTime.elapsed(_stateTime, 15000))
{
SetState(0);
//Update Minions
for (int i=0 ; i<_minions.size() ; i++)
{
Skeleton minion = _minions.get(i);
minion.setTarget(null);
minion.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
minion.getEquipment().setItemInHand(new ItemStack(Material.BOW));
}
ShieldSpawn();
_minionTargets.clear();
}
}
//Skeleton Scatter
if (GetState() != 3 && UtilTime.elapsed(_stateTime, 2000))
{
if (_shields.size() == 0 && _minions.size() > 0)
{
SetState(3);
}
}
//Final Stage
if (GetState() != 4 && UtilTime.elapsed(_stateTime, 2000))
{
if (_shields.size() == 0 && _minions.size() == 0)
{
SetState(4);
//Sound
GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.WITHER_SPAWN, 10f, 1.5f);
GetEntity().getWorld().playSound(GetEntity().getLocation(), Sound.ZOMBIE_PIG_ANGRY, 10f, 0.5f);
//Speed
Host.Manager.GetCondition().Factory().Speed("King Speed", GetEntity(), GetEntity(), 9999, 1, false, false, false);
//Equip
GetEntity().getEquipment().setItemInHand(new ItemStack(Material.IRON_SWORD));
}
}
}
public void Target(EntityTargetEvent event)
{
if (event.getEntity().equals(GetEntity()))
{
if (GetState() != 4 || _kingTarget == null || !_kingTarget.equals(event.getTarget()))
{
event.setCancelled(true);
}
}
if (_minions.contains(event.getEntity()))
{
if (GetState() != 3)
{
event.setCancelled(true);
}
else
{
if (!_minionTargets.containsKey(event.getEntity()))
{
event.setCancelled(true);
}
else
{
Player player = _minionTargets.get(event.getEntity());
if (!player.equals(event.getTarget()))
event.setCancelled(true);
if (!Host.IsAlive(player))
_minionTargets.put(event.getEntity(), GetRandomPlayer());
}
}
}
}
public Player GetRandomPlayer()
{
if (Host.GetPlayers(true).isEmpty())
return null;
return Host.GetPlayers(true).get(UtilMath.r(Host.GetPlayers(true).size()));
}
}

View File

@ -0,0 +1,60 @@
package nautilus.game.arcade.game.games.halloween.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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 KitDefault extends Kit
{
public KitDefault(ArcadeManager manager)
{
super(manager, "Halloween Dude", KitAvailability.Free,
new String[]
{
"Just a dude, at halloween."
},
new Perk[]
{
},
EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, 64));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.JACK_O_LANTERN));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
}
@Override
public void SpawnCustom(LivingEntity ent)
{
ent.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
ent.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
ent.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
}
}

View File

@ -58,7 +58,7 @@ public class KitGolem extends SmashKit
new String[]
{
ChatColor.RESET + "Take a mighty leap into the air, then",
ChatColor.RESET + "slam back into the gruond with huge force.",
ChatColor.RESET + "slam back into the ground with huge force.",
ChatColor.RESET + "Nearby opponents take damage and knockback.",
}));

View File

@ -9,6 +9,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftWolf;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;

View File

@ -1,366 +0,0 @@
package nautilus.game.pvp.worldevent.creature;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
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.Creature;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import me.chiss.Core.Items.IThrown;
import me.chiss.Core.Managers.Throw.IProjectileUser;
import me.chiss.Core.Updater.UpdateEvent;
import me.chiss.Core.Updater.UpdateEvent.UpdateType;
import me.chiss.Core.Utility.UtilAction;
import me.chiss.Core.Utility.UtilTime;
import nautilus.game.pvp.worldevent.EventBase;
import nautilus.game.pvp.worldevent.EventCreatureBase;
public class BroodMother extends EventCreatureBase implements IThrown
{
private ArrayList<Broodling> _minions = new ArrayList<Broodling>();
private int _minionsMax = 100;
private HashMap<Block, Long> _eggs = new HashMap<Block, Long>();
private long _eggLast = System.currentTimeMillis();
private int _eggSpawns = 0;
private long _webLast = System.currentTimeMillis();
private int _webSpawns = 0;
private int _webMax = 100;
private int _eggItems = 0;
private int _eggItemMax = 20;
private long _stateLast = System.currentTimeMillis();
private int _state = 0;
//Normal
//Eggs
//Run
//Webs
public BroodMother(EventBase event, Location location)
{
super(event, location, "Brood Mother", true, 800, EntityType.SPIDER);
}
@EventHandler
public void Heal(UpdateEvent event)
{
if (GetEntity() == null)
return;
if (event.getType() != UpdateType.SEC)
return;
ModifyHealth(1);
}
@Override
public void Die()
{
Event.Manager.Blood().Effects(GetEntity().getEyeLocation(), 50, 0.8,
Sound.SPIDER_DEATH, 2f, 0.5f, Material.BONE, (byte)0, false);
Loot();
Remove();
}
@Override
public void Loot()
{
Event.Manager.Loot().DropLoot(GetEntity().getEyeLocation(), 40, 40, 0.2f, 0.05f, 3d);
}
@EventHandler
public void StateSwitch(UpdateEvent event)
{
if (_state != 0)
return;
if (event.getType() != UpdateType.SEC)
return;
if (!UtilTime.elapsed(_stateLast, 12000))
return;
if (Math.random() > 0.5 || _minions.size() + _eggs.size() < 6)
{
if (_minions.size() + _eggs.size() < 6 || UtilTime.elapsed(_eggLast, 30000))
{
_eggLast = System.currentTimeMillis();
_state = 1;
_eggSpawns = GetMinionsMax();
((Creature)GetEntity()).setTarget(null);
}
}
else
{
if (UtilTime.elapsed(_webLast, 30000))
{
_webLast = System.currentTimeMillis();
_state = 2;
_webSpawns = Scale(_webMax);
((Creature)GetEntity()).setTarget(null);
}
}
}
private int Scale(int a)
{
return (int) (a * (0.1 + (0.9 - 0.9 * (GetHealthCur() / GetHealthMax()))));
}
private int GetMinionsMax()
{
int max = Scale(_minionsMax);
max -= _minions.size();
return max;
}
@EventHandler
public void WebSpawn(UpdateEvent event)
{
if (_state != 2)
return;
if (event.getType() != UpdateType.FASTEST)
return;
if (GetEntity() == null)
return;
if (_webSpawns <= 0)
{
_state = 0;
_stateLast = System.currentTimeMillis();
return;
}
_webSpawns--;
//Item
Item item = GetEntity().getWorld().dropItem(GetEntity().getLocation().add(0, 0.5, 0),
Event.Manager.Item().CreateStack(Material.WEB));
//Velocity
UtilAction.velocity(item, new Vector(Math.random()-0.5, 0, Math.random()-0.5).normalize(),
Math.random() * 0.4 + 0.2, false, 0, Math.random() * 0.6 + 0.4, 10, false);
//Sound
item.getWorld().playSound(item.getLocation(), Sound.BREATH, 0.5f, 0.2f);
//Thrown
Event.Manager.Throw().AddThrow(item, GetEntity(), this,
-1, false, false, true,
null, 2f, 0.5f,
null, 0, UpdateType.TICK, 1.5d);
}
@EventHandler
public void EggSpawn(UpdateEvent event)
{
if (_state != 1)
return;
if (event.getType() != UpdateType.FASTEST)
return;
if (GetEntity() == null)
return;
if (_eggSpawns <= 0)
{
_state = 0;
_stateLast = System.currentTimeMillis();
return;
}
if (_eggItems >= _eggItemMax)
return;
_eggSpawns--;
//Item
Item item = GetEntity().getWorld().dropItem(GetEntity().getLocation().add(0, 0.5, 0),
Event.Manager.Item().CreateStack(Material.DRAGON_EGG));
//Velocity
UtilAction.velocity(item, new Vector(Math.random()-0.5, 0, Math.random()-0.5).normalize(),
Math.random() * 0.4 + 0.2, false, 0, Math.random() * 0.6 + 0.4, 10, false);
//Sound
item.getWorld().playSound(item.getLocation(), Sound.CHICKEN_EGG_POP, 1f, 1f);
//Thrown
Event.Manager.Throw().AddThrow(item, GetEntity(), this,
-1, false, false, true,
null, 2f, 0.5f,
null, 0, UpdateType.TICK, 1.5d);
_eggItems++;
}
@Override
public void Collide(LivingEntity target, Block block, IProjectileUser data)
{
//Null
}
@Override
public void Idle(IProjectileUser data)
{
BlockForm(data);
}
@Override
public void Expire(IProjectileUser data)
{
BlockForm(data);
}
public void BlockForm(IProjectileUser data)
{
Material mat = ((Item)data.GetThrown()).getItemStack().getType();
if (mat == Material.DRAGON_EGG)
{
Block egg = data.GetThrown().getLocation().getBlock();
if (egg.getRelative(BlockFace.DOWN).getType() != Material.DRAGON_EGG &&
egg.getRelative(BlockFace.DOWN).getType() != Material.WEB)
{
egg.setType(Material.DRAGON_EGG);
_eggs.put(egg, System.currentTimeMillis());
}
_eggItems--;
}
else if (mat == Material.WEB)
{
Block web = data.GetThrown().getLocation().getBlock();
if (web.getType() != Material.WATER && web.getType() != Material.STATIONARY_WATER)
Event.Manager.BlockRestore().Add(web, 30, (byte)0, Scale(40000));
}
data.GetThrown().remove();
}
@EventHandler
public void EggHatch(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_eggs.isEmpty())
return;
HashSet<Block> hatch = new HashSet<Block>();
for (Block block : _eggs.keySet())
if (Math.random() > 0.98)
if (UtilTime.elapsed(_eggs.get(block), 12000))
hatch.add(block);
for (Block block : hatch)
{
_eggs.remove(block);
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setTypeId(0);
Event.CreatureRegister(new Broodling(Event, block.getLocation().add(0.5, 0.5, 0.5), this));
}
}
@EventHandler
public void EggCrush(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player cur : GetEntity().getWorld().getPlayers())
{
Block below = cur.getLocation().getBlock().getRelative(BlockFace.DOWN);
if (below.getType() != Material.DRAGON_EGG)
continue;
if (!_eggs.containsKey(below))
continue;
_eggs.remove(below);
below.setTypeId(0);
below.getWorld().playEffect(below.getLocation(), Effect.STEP_SOUND, 122);
UtilAction.velocity(cur, cur.getLocation().getDirection(), 0.3, true, 0.3, 0, 10, true);
}
}
@EventHandler
public void EggHit(PlayerInteractEvent event)
{
if (event.getClickedBlock() == null)
return;
if (!_eggs.containsKey(event.getClickedBlock()))
return;
event.setCancelled(true);
}
public void MinionRegister(Broodling minion)
{
_minions.add(minion);
}
public void MinionDeregister(Broodling minion)
{
_minions.remove(minion);
}
public ArrayList<Broodling> GetMinions()
{
return _minions;
}
@EventHandler(priority = EventPriority.LOWEST)
public void TargetCancel(EntityTargetEvent event)
{
if (!event.getEntity().equals(GetEntity()))
return;
if (_state == 0 && (GetHealthCur() / GetHealthMax()) < 0.5)
return;
event.setCancelled(true);
}
public boolean CanTarget(LivingEntity ent)
{
int i = 0;
for (Broodling cur : _minions)
{
LivingEntity target = ((Creature)cur.GetEntity()).getTarget();
if (target != null && target.equals(ent))
i++;
}
return i < Scale(20);
}
}