Xmas Game

This commit is contained in:
Chiss 2013-12-21 10:17:22 +11:00
parent 5dc0a7d4d6
commit bc9c309aa1
27 changed files with 3258 additions and 23 deletions

15
.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
.metadata
*.class
Testing
*.orig
bin
MagicMC
/Plugins/Mineplex.Core/.externalToolBuilders/Core Builder.launch
/Plugins/Mineplex.AntiCheat
update

View File

@ -0,0 +1,45 @@
package mineplex.hub.gadget.gadgets;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseSnowman;
import mineplex.hub.gadget.GadgetManager;
import mineplex.hub.gadget.types.ArmorGadget;
public class Christmas2013_Helmet extends ArmorGadget
{
public Christmas2013_Helmet(GadgetManager manager)
{
super(manager, "Snowmans Head", new String[]
{
C.cWhite + "Transforms the wearer into",
C.cWhite + "a Christmas Snowman!",
"",
C.cYellow + "Earned by defeating the Pumpkin King",
C.cYellow + "in the 2013 Christmas Chaos Event.",
},
-1,
ArmorSlot.Helmet, Material.SNOW_BLOCK, (byte)0);
}
@Override
public void Enable(final Player player)
{
this.ApplyArmor(player);
DisguiseSnowman disguise = new DisguiseSnowman(player);
disguise.SetName(player.getName());
disguise.SetCustomNameVisible(true);
Manager.Manager.GetDisguise().disguise(disguise);
}
@Override
public void Disable(Player player)
{
this.RemoveArmor(player);
Manager.Manager.GetDisguise().undisguise(player);
}
}

View File

@ -0,0 +1,178 @@
package mineplex.hub.gadget.gadgets;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.gadget.GadgetManager;
import mineplex.hub.gadget.types.ItemGadget;
public class Christmas2013_SnowCannon extends ItemGadget
{
private HashMap<Player, Long> _active = new HashMap<Player, Long>();
private HashMap<Player, Location> _velocity = new HashMap<Player, Location>();
private HashMap<Player, ArrayList<Bat>> _bats = new HashMap<Player, ArrayList<Bat>>();
public Christmas2013_SnowCannon(GadgetManager manager)
{
super(manager, "Snow Cannon", new String[]
{
C.cWhite + "Launch waves of annoying bats",
C.cWhite + "at people you don't like!",
},
-1,
Material.IRON_BARDING, (byte)0);
}
@Override
public void Enable(Player player)
{
this.ApplyItem(player);
}
@Override
public void Disable(Player player)
{
this.RemoveItem(player);
Clear(player);
}
@EventHandler
public void Activate(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.IRON_BARDING))
return;
Player player = event.getPlayer();
if (!IsActive(player))
return;
if (Manager.Manager.GetParkour().InParkour(player))
{
UtilPlayer.message(player, F.main("Parkour", "You cannot use Bat Blaster near Parkour Challenges."));
return;
}
if (!Recharge.Instance.use(player, GetName(), 8000, true))
return;
//Start
_velocity.put(player, player.getEyeLocation());
_active.put(player, System.currentTimeMillis());
_bats.put(player, new ArrayList<Bat>());
for (int i=0 ; i<16 ; i++)
_bats.get(player).add(player.getWorld().spawn(player.getEyeLocation(), Bat.class));
//Inform
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player cur : UtilServer.getPlayers())
{
if (!_active.containsKey(cur))
continue;
if (UtilTime.elapsed(_active.get(cur), 3000))
{
Clear(cur);
continue;
}
Location loc = _velocity.get(cur);
//Bat Movement
for (Bat bat : _bats.get(cur))
{
if (!bat.isValid())
continue;
Vector rand = new Vector((Math.random() - 0.5)/3, (Math.random() - 0.5)/3, (Math.random() - 0.5)/3);
bat.setVelocity(loc.getDirection().clone().multiply(0.5).add(rand));
for (Player other : UtilServer.getPlayers())
{
if (other.equals(cur))
continue;
if (!Recharge.Instance.usable(other, "Hit by Bat"))
continue;
if (UtilEnt.hitBox(bat.getLocation(), other, 2, null))
{
//Damage Event
UtilAction.velocity(other, UtilAlg.getTrajectory(cur, other), 0.4, false, 0, 0.2, 10, true);
//Effect
bat.getWorld().playSound(bat.getLocation(), Sound.BAT_HURT, 1f, 1f);
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3);
bat.remove();
//Recharge on hit
Recharge.Instance.useForce(other, "Hit by Bat", 200);
//No Portal
Manager.Manager.SetPortalDelay(other);
}
}
}
}
}
public void Clear(Player player)
{
_active.remove(player);
_velocity.remove(player);
if (_bats.containsKey(player))
{
for (Bat bat : _bats.get(player))
{
if (bat.isValid())
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3);
bat.remove();
}
_bats.remove(player);
}
}
}

View File

@ -0,0 +1,47 @@
package mineplex.hub.mount.types;
import org.bukkit.Material;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.mount.Mount;
import mineplex.hub.mount.MountManager;
public class Frost extends Mount
{
public Frost(MountManager manager)
{
super(manager, "Frosty Steed", new String[]
{
C.cWhite + "From the North Pole itself,",
C.cWhite + "one of Santa's own steeds",
C.cWhite + "used to pull his Sleigh!",
" ",
C.cYellow + "Only available on website.",
C.cYellow + "www.mineplex.com/Shop",
},
Material.BONE,
(byte)0,
-1,
Color.WHITE, Style.WHITE, Variant.HORSE, 0.8, null);
}
@EventHandler
public void Trail(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
{
}
}
}

View File

@ -20,6 +20,7 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.MapUtil;
@ -142,20 +143,20 @@ public class Christmas extends SoloGame
_parts.add(new Part2(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetDataLocs("YELLOW"),
WorldData.GetDataLocs("BROWN"),
WorldData.GetDataLocs("PURPLE"),
WorldData.GetCustomLocs("48")));
_parts.add(new Part3(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetDataLocs("GRAY"),
WorldData.GetDataLocs("SILVER"),
WorldData.GetDataLocs("WHITE"),
WorldData.GetCustomLocs("121")));
WorldData.GetDataLocs("PURPLE")));
_parts.add(new Part4(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetCustomLocs("56"),
WorldData.GetDataLocs("MAGENTA"),
WorldData.GetCustomLocs("22"),
WorldData.GetCustomLocs("45"),
WorldData.GetCustomLocs("121"),
_sleighWaypoints.get(0)));
_parts.add(new Part5(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
@ -522,7 +523,7 @@ public class Christmas extends SoloGame
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
out = C.cWhite + "Presents Found:";
out = C.cWhite + "Presents:";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
@ -572,4 +573,33 @@ public class Christmas extends SoloGame
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
}
@Override
public Location GetSpectatorLocation()
{
if (SpectatorSpawn == null)
{
SpectatorSpawn = new Location(this.WorldData.World, 0,0,0);
}
Vector vec = new Vector(0,0,0);
double count = 0;
for (Player player : GetPlayers(true))
{
count++;
vec.add(player.getLocation().toVector());
}
if (count == 0)
count++;
vec.multiply(1d/count);
SpectatorSpawn.setX(vec.getX());
SpectatorSpawn.setY(vec.getY() + 10);
SpectatorSpawn.setZ(vec.getZ());
return SpectatorSpawn;
}
}

View File

@ -133,23 +133,14 @@ public class Sleigh
SleighHorses = new ArrayList<SleighHorse>();
SleighHorses.add(new SleighHorse(CentralEntity, loc.clone(), -1.5, 8));
SleighHorses.add(new SleighHorse(CentralEntity, loc.clone(), 1.5, 8));
SleighHorses.add(new SleighHorse(loc.clone(), -1.5, 8));
SleighHorses.add(new SleighHorse(loc.clone(), 1.5, 8));
SleighHorses.add(new SleighHorse(CentralEntity, loc.clone(), -1.5, 11));
SleighHorses.add(new SleighHorse(CentralEntity, loc.clone(), 1.5, 11));
SleighHorses.add(new SleighHorse(loc.clone(), -1.5, 11));
SleighHorses.add(new SleighHorse(loc.clone(), 1.5, 11));
for (SleighHorse horse : SleighHorses)
{
UtilEnt.Lhorse.Ent.
}
}
public void AddPresent(FallingBlock block)
{
block.leaveVehicle();
//Add to Sleigh
UtilEnt.Leash(horse.Ent, santa.GetTop(), false, false);
}
public Location GetLocation()

View File

@ -3,23 +3,27 @@ package nautilus.game.arcade.game.games.christmas;
import mineplex.core.common.util.UtilEnt;
import org.bukkit.Location;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.LivingEntity;
public class SleighHorse
{
public Chicken Ent;
public Horse Ent;
public double OffsetX;
public double OffsetZ;
public SleighHorse(Entity owner, Location loc, double x, double z)
public SleighHorse(Location loc, double x, double z)
{
Ent = loc.getWorld().spawn(loc.add(x, 0, z), Chicken.class);
//Ent.setLeashHolder(owner);
Ent = loc.getWorld().spawn(loc.add(x, 0, z), Horse.class);
UtilEnt.Vegetate(Ent);
UtilEnt.ghost(Ent, true);
Ent.setStyle(Style.WHITE_DOTS);
Ent.setColor(Color.CHESTNUT);
OffsetX = x;
OffsetZ = z;
}

View File

@ -158,4 +158,16 @@ public class SleighPart
return false;
}
public Entity GetTop()
{
Entity ent = Ent;
while (ent.getPassenger() != null)
{
ent = ent.getPassenger();
}
return ent;
}
}

View File

@ -0,0 +1,164 @@
package nautilus.game.arcade.game.games.christmas.content;
import java.util.ArrayList;
import java.util.HashMap;
import mineplex.core.common.util.C;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.game.games.christmas.Christmas;
import nautilus.game.arcade.game.games.christmas.parts.Part5;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
public class BossFloor
{
private Part5 Host;
private boolean _active = false;
private int _difficulty = 0;
private HashMap<Location, Byte> _floor;
private boolean _inProgress = false;
private int _state = 0;
private long _stateTime = 0;
private byte _color = 0;
private long _last = 0;
private Location _restoreLoc = null;
public BossFloor(Part5 host, ArrayList<Location> floor)
{
Host = host;
_floor = new HashMap<Location, Byte>();
for (Location loc : floor)
{
loc.getBlock().setType(Material.AIR);
loc.add(0, 1, 0);
_floor.put(loc, loc.getBlock().getData());
}
}
public void SetActive(boolean active, int difficulty)
{
_active = active;
_difficulty = difficulty;
}
public void Remove(byte ignore)
{
for (Location loc : _floor.keySet())
{
if (_floor.get(loc) == ignore)
continue;
MapUtil.QuickChangeBlockAt(loc, Material.AIR);
}
}
public void Restore()
{
for (Location loc : _floor.keySet())
{
if (loc.getBlock().getType() == Material.AIR)
loc.getBlock().setTypeIdAndData(35, _floor.get(loc), false);
}
}
public void Update()
{
//Normal
if (_active && _state == 0 && UtilTime.elapsed(_last, 6000 - (1000 * _difficulty)))
{
for (Player player : UtilServer.getPlayers())
player.setExp(0f);
_state = 1;
_last = System.currentTimeMillis();
_color = Host.GetBoss().GetEntity().getLocation().getBlock().getRelative(BlockFace.DOWN).getData();
String color = "White";
ChatColor textColor = ChatColor.WHITE;
if (_color == 1) {color = "Orange"; textColor = ChatColor.GOLD;}
else if (_color == 2) {color = "Purple"; textColor = ChatColor.LIGHT_PURPLE;}
else if (_color == 3) {color = "Blue"; textColor = ChatColor.BLUE;}
else if (_color == 4) {color = "Yellow"; textColor = ChatColor.YELLOW;}
else if (_color == 5) {color = "Green"; textColor = ChatColor.GREEN;}
else if (_color == 6) {color = "Pink"; textColor = ChatColor.RED;}
else if (_color == 7) {color = "Gray"; textColor = ChatColor.GRAY;}
else if (_color == 8) {color = "Gray"; textColor = ChatColor.GRAY;}
else if (_color == 9) {color = "Blue"; textColor = ChatColor.BLUE;}
else if (_color == 10) {color = "Purple"; textColor = ChatColor.LIGHT_PURPLE;}
else if (_color == 11) {color = "Blue"; textColor = ChatColor.BLUE;}
else if (_color == 12) {color = "Brown"; textColor = ChatColor.DARK_GRAY;}
else if (_color == 13) {color = "Green"; textColor = ChatColor.GREEN;}
else if (_color == 14) {color = "Red"; textColor = ChatColor.RED;}
else if (_color == 15) {color = "Black"; textColor = ChatColor.BLACK;}
Host.Host.SantaSay("Stay on " + textColor + C.Bold + color.toUpperCase());
_restoreLoc = Host.GetBoss().GetEntity().getLocation().getBlock().getLocation().add(0.5, 0, 0.5);
//Give Wool
for (Player player : UtilServer.getPlayers())
for (int i=3 ; i<9 ; i++)
player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(Material.WOOL, _color));
}
//Countdown
else if (_state == 1)
{
long req = 5000 - (1500 * _difficulty);
for (Player player : UtilServer.getPlayers())
player.setExp(Math.min(0.99f, Math.max(0.0f, (req - (System.currentTimeMillis() - _last)) / req)));
if (UtilTime.elapsed(_last, req))
{
_last = System.currentTimeMillis();
_state = 2;
Remove(_color);
}
}
//Disappear
else if (_state == 2)
{
for (Player player : UtilServer.getPlayers())
player.setExp(0.99f);
if (UtilTime.elapsed(_last, 3000 - (1000 * _difficulty)))
{
_last = System.currentTimeMillis();
_state = 0;
Restore();
Host.GetBoss().GetEntity().teleport(_restoreLoc);
for (Player player : UtilServer.getPlayers())
player.getInventory().remove(Material.WOOL);
}
}
}
public boolean ShouldBossMove()
{
return _state == 0;
}
}

View File

@ -0,0 +1,114 @@
package nautilus.game.arcade.game.games.christmas.content;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.games.christmas.parts.Part5;
import net.minecraft.server.v1_6_R3.EntityCreature;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.inventory.ItemStack;
public class BossMobs
{
private Part5 Host;
private boolean _active = false;
private int _difficulty = 0;
private ArrayList<Location> _spawns;
private long _lastSpawn;
private HashMap<Creature, Player> _ents = new HashMap<Creature, Player>();
public BossMobs(Part5 host, ArrayList<Location> spawns)
{
Host = host;
_spawns = spawns;
}
public void SetActive(boolean active, int difficulty)
{
_active = active;
_difficulty = difficulty;
}
public void Update()
{
MoveDieHit();
if (!_active)
return;
//Timer
if (!UtilTime.elapsed(_lastSpawn, 1000 - 250 * _difficulty))
return;
_lastSpawn = System.currentTimeMillis();
//Spawn
Host.Host.CreatureAllowOverride = true;
Creature ent = UtilAlg.Random(_spawns).getWorld().spawn(UtilAlg.Random(_spawns), Skeleton.class);
Host.Host.CreatureAllowOverride = false;
//Weapon
double r = Math.random();
if (r > 0.66) ent.getEquipment().setItemInHand(new ItemStack(Material.STONE_SWORD));
else if (r > 0.33) ent.getEquipment().setItemInHand(new ItemStack(Material.IRON_AXE));
else ent.getEquipment().setItemInHand(new ItemStack(Material.BOW));
ent.setHealth(5);
//Target
Player player = UtilAlg.Random(Host.Host.GetPlayers(true));
//Add
_ents.put(ent, player);
}
private void MoveDieHit()
{
Iterator<Creature> entIterator = _ents.keySet().iterator();
//Move & Die
while (entIterator.hasNext())
{
Creature ent = entIterator.next();
//Get Target
Player target = _ents.get(ent);
if (target == null || !target.isValid() || !Host.Host.IsAlive(target))
{
if (Host.Host.GetPlayers(true).size() > 0)
{
target = UtilAlg.Random(Host.Host.GetPlayers(true));
_ents.put(ent, target);
}
else
{
continue;
}
}
//Move
EntityCreature ec = ((CraftCreature)ent).getHandle();
ec.getControllerMove().a(target.getLocation().getX(), target.getLocation().getY(), target.getLocation().getZ(), 1.2 + 0.3 * _difficulty);
//Remove
if (!ent.isValid() )
{
ent.remove();
entIterator.remove();
}
}
}
}

View File

@ -0,0 +1,18 @@
package nautilus.game.arcade.game.games.christmas.content;
import org.bukkit.Location;
import org.bukkit.entity.Snowman;
public class BossSnowman
{
public Snowman Entity;
public Location Spawn;
public int Direction;
public BossSnowman(Snowman ent, Location loc, int dir)
{
Entity = ent;
Spawn = loc;
Direction = dir;
}
}

View File

@ -0,0 +1,182 @@
package nautilus.game.arcade.game.games.christmas.content;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.christmas.Christmas;
import nautilus.game.arcade.game.games.christmas.parts.Part5;
import net.minecraft.server.v1_6_R3.EntityCreature;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowman;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.util.Vector;
public class BossSnowmanPattern
{
private boolean _active = false;
private int _difficulty = 0;
private Part5 Host;
private ArrayList<Location> _spawnA;
private ArrayList<Location> _spawnB;
private int _aDir = 1;
private int _bDir = -1;
private long _lastSpawn = 0;
private int _lastGap = 0;
private ArrayList<BossSnowman> _ents = new ArrayList<BossSnowman>();
public BossSnowmanPattern(Part5 host, ArrayList<Location> spawnA, ArrayList<Location> spawnB, Location waypoint)
{
Host = host;
_spawnA = new ArrayList<Location>();
_spawnB = new ArrayList<Location>();
//Order A Spawns
while (!spawnA.isEmpty())
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : spawnA)
{
double dist = UtilMath.offset(waypoint, loc);
if (bestLoc == null || bestDist > dist)
{
bestLoc = loc;
bestDist = dist;
}
}
_spawnA.add(bestLoc);
spawnA.remove(bestLoc);
}
//Order B Spawns
while (!spawnB.isEmpty())
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : spawnB)
{
double dist = UtilMath.offset(waypoint, loc);
if (bestLoc == null || bestDist > dist)
{
bestLoc = loc;
bestDist = dist;
}
}
_spawnB.add(bestLoc);
spawnB.remove(bestLoc);
}
}
public void SetActive(boolean active, int difficulty)
{
_active = active;
_difficulty = difficulty;
}
public void Update()
{
MoveDieHit();
if (!_active)
return;
//Timer
if (!UtilTime.elapsed(_lastSpawn, 4000 - (500 * _difficulty)))
return;
_lastSpawn = System.currentTimeMillis();
Host.Host.CreatureAllowOverride = true;
//Spawn A
for (int i=0 ; i<_spawnA.size() ; i++)
{
if (i%6 < 3)
continue;
Location loc = _spawnA.get(i);
Snowman ent = loc.getWorld().spawn(loc, Snowman.class);
UtilEnt.Vegetate(ent);
UtilEnt.ghost(ent, true);
_ents.add(new BossSnowman(ent, loc, _aDir));
}
//Spawn B
for (int i=0 ; i<_spawnB.size() ; i++)
{
if (i%6 >= 3)
continue;
Location loc = _spawnB.get(i);
Snowman ent = loc.getWorld().spawn(loc, Snowman.class);
UtilEnt.Vegetate(ent);
UtilEnt.ghost(ent, true);
_ents.add(new BossSnowman(ent, loc, _bDir));
}
Host.Host.CreatureAllowOverride = false;
}
private void MoveDieHit()
{
Iterator<BossSnowman> entIterator = _ents.iterator();
//Move & Die
while (entIterator.hasNext())
{
BossSnowman ent = entIterator.next();
EntityCreature ec = ((CraftCreature)ent.Entity).getHandle();
ec.getControllerMove().a(ent.Entity.getLocation().getX()+ent.Direction, ent.Entity.getLocation().getY(), ent.Entity.getLocation().getZ(), 1.5 + 0.25*_difficulty);
if (!ent.Entity.isValid() || UtilMath.offset(ent.Entity.getLocation(), ent.Spawn) > 43)
{
ent.Entity.remove();
entIterator.remove();
}
}
//Hit Players
for (Player player : Host.Host.GetPlayers(true))
{
if (!Recharge.Instance.usable(player, "Snowman Hit"))
return;
for (BossSnowman snowman : _ents)
{
if (UtilMath.offset(player, snowman.Entity) < 1)
{
UtilAction.velocity(player, new Vector(snowman.Direction,0,0), 2, false, 0, 0.8, 0.8, true);
Recharge.Instance.useForce(player, "Snowman Hit", 1000);
//Damage Event
Host.Host.Manager.GetDamage().NewDamageEvent(player, snowman.Entity, null,
DamageCause.ENTITY_ATTACK, 3, true, false, false,
null, null);
}
}
}
}
}

View File

@ -0,0 +1,110 @@
package nautilus.game.arcade.game.games.christmas.content;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.christmas.parts.Part4;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Giant;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.util.Vector;
public class CaveGiant
{
private Part4 Host;
private Giant _ent;
private Location _target;
private Location _tpLoc;
public CaveGiant(Part4 host, Location loc)
{
Host = host;
Host.Host.CreatureAllowOverride = true;
_ent = loc.getWorld().spawn(loc, Giant.class);
Host.Host.CreatureAllowOverride = false;
UtilEnt.Vegetate(_ent);
UtilEnt.ghost(_ent, true);
_tpLoc = _ent.getLocation();
for (Player player : UtilServer.getPlayers())
player.playSound(_ent.getLocation(), Sound.ZOMBIE_PIG_ANGRY, 10f, 0.5f);
}
public boolean IsDead()
{
return (_ent != null && !_ent.isValid());
}
public void SetTarget(Location loc)
{
_target = loc;
}
public Location GetTarget()
{
return _target;
}
public Giant GetEntity()
{
return _ent;
}
public void MoveUpdate()
{
if (IsDead())
return;
Destroy();
SetTarget(Host.Host.GetSleigh().GetLocation());
//Move
Vector dir = UtilAlg.getTrajectory2d(GetEntity().getLocation(), GetTarget());
_tpLoc.setPitch(UtilAlg.GetPitch(dir));
_tpLoc.setYaw(UtilAlg.GetYaw(dir));
_tpLoc.add(dir.multiply(0.075));
GetEntity().teleport(_tpLoc);
//Attack
for (Player player : Host.Host.GetPlayers(true))
{
if (UtilMath.offset(player, _ent) > 5)
continue;
if (!Recharge.Instance.usable(player, "Giant Damage"))
continue;
//Damage Event
Host.Host.Manager.GetDamage().NewDamageEvent(player, _ent, null,
DamageCause.ENTITY_ATTACK, 6, true, false, false,
UtilEnt.getName(_ent), null);
Recharge.Instance.useForce(player, "Giant Damage", 1000);
}
if (UtilMath.offset(_ent.getLocation(), Host.Host.GetSleigh().GetLocation()) < 8)
{
Host.Host.End();
}
}
private void Destroy()
{
Host.Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 8, 0), 6d).keySet(), GetEntity().getLocation().add(0, 8, 0), false);
Host.Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 2, 0), 5d).keySet(), GetEntity().getLocation(), true);
Host.Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 0, 0), 5d).keySet(), GetEntity().getLocation(), true);
}
}

View File

@ -0,0 +1,134 @@
package nautilus.game.arcade.game.games.christmas.content;
import java.util.ArrayList;
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 nautilus.game.arcade.game.games.christmas.parts.Part5;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class PumpkinKing
{
private Part5 Host;
private Skeleton _ent;
private Location _target;
private ArrayList<Location> _grid;
private ArrayList<TNTPrimed> _tnt = new ArrayList<TNTPrimed>();
private long _lastTNT = 0;
public PumpkinKing(Part5 host, Location loc, ArrayList<Location> grid)
{
Host = host;
_grid = grid;
Host.Host.CreatureAllowOverride = true;
_ent = loc.getWorld().spawn(loc, Skeleton.class);
Host.Host.CreatureAllowOverride = false;
UtilEnt.Vegetate(_ent);
UtilEnt.ghost(_ent, true);
_ent.setSkeletonType(SkeletonType.WITHER);
_ent.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
_ent.getEquipment().setItemInHand(new ItemStack(Material.TNT));
_ent.setCustomName("The Pumpkin King");
_ent.setCustomNameVisible(true);
_ent.getWorld().strikeLightningEffect(_ent.getLocation());
}
public boolean IsDead()
{
return (_ent != null && !_ent.isValid());
}
public void SetTarget(Location loc)
{
_target = loc;
}
public Location GetTarget()
{
return _target;
}
public Entity GetEntity()
{
return _ent;
}
public void MoveUpdate()
{
if (IsDead())
return;
if (_target == null || UtilMath.offset(_ent.getLocation(), _target) < 1)
SetTarget(UtilAlg.Random(_grid).clone().add(0, 0.5, 0));
else
UtilEnt.CreatureMoveFast(_ent, _target, (float) (1.2 + (0.06 * Host.GetState())));
for (Player player : Host.Host.GetPlayers(true))
{
if (UtilMath.offset(player, _ent) > 1.5)
continue;
//Damage Event
Host.Host.Manager.GetDamage().NewDamageEvent(player, _ent, null,
DamageCause.ENTITY_ATTACK, 6, true, false, false,
UtilEnt.getName(_ent), null);
}
}
public void TNTUpdate()
{
if (IsDead())
return;
if (!UtilTime.elapsed(Host.GetStateTime(), 4000))
return;
if (!UtilTime.elapsed(_lastTNT, 6000 - (200 * Host.GetState())))
return;
_lastTNT = System.currentTimeMillis();
Player player = UtilAlg.Random(Host.Host.GetPlayers(true));
TNTPrimed tnt = _ent.getWorld().spawn(_ent.getEyeLocation(), TNTPrimed.class);
UtilAction.velocity(tnt, UtilAlg.getTrajectory(tnt, player), 1, false, 0, 0.2, 10, false);
double mult = 0.5 + (0.6 * (UtilMath.offset(tnt, player)/24d));
//Velocity
tnt.setVelocity(player.getLocation().toVector().subtract(tnt.getLocation().toVector()).normalize().add(new Vector(0, 0.4, 0)).multiply(mult));
_tnt.add(tnt);
}
public void StayIdle()
{
if (IsDead())
return;
UtilEnt.CreatureMoveFast(_ent, _ent.getLocation().getBlock().getLocation().add(0.5, 0, 0.5), 0.6f);
}
}

View File

@ -0,0 +1,104 @@
package nautilus.game.arcade.game.games.christmas.content;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class Snake
{
private ArrayList<Location> _path = new ArrayList<Location>();
private byte _color = 0;
private int _index = 0;
private boolean _colorTick = false;
private int _pathId = 39;
public Snake(Location loc, ArrayList<Location> path)
{
_path = new ArrayList<Location>();
//First
_path.add(loc);
MapUtil.QuickChangeBlockAt(loc, _pathId, (byte)0);
//Direction
for (Block block : UtilBlock.getSurrounding(loc.getBlock(), false))
{
if (block.getType() == Material.WOOL)
{
_path.add(block.getLocation().add(0.5,0.5,0.5));
_color = block.getData();
MapUtil.QuickChangeBlockAt(block.getLocation(), _pathId, (byte)0);
break;
}
}
//Path
for (int i=0 ; i<100 ; i++)
{
Iterator<Location> pathIterator = path.iterator();
while (pathIterator.hasNext())
{
Location pathLoc = pathIterator.next();
if (UtilMath.offset(_path.get(_path.size()-1).getBlock().getLocation(), pathLoc.getBlock().getLocation()) <= 1)
{
_path.add(pathLoc);
MapUtil.QuickChangeBlockAt(pathLoc, _pathId, (byte)0);
pathIterator.remove();
}
}
}
}
public void Update()
{
if (_path.isEmpty())
return;
//Set Block
MapUtil.QuickChangeBlockAt(_path.get(_index), 35, GetColor());
int back = _index - 8;
if (back < 0)
back += _path.size();
//Unset Tail
MapUtil.QuickChangeBlockAt(_path.get(back), _pathId, (byte) 0);
//ALT
if (_path.size() > 50)
{
int newIndex = (_index + (_path.size()/2))%_path.size();
//Set Block
MapUtil.QuickChangeBlockAt(_path.get(newIndex), 35, GetColor());
back = newIndex - 8;
if (back < 0)
back += _path.size();
//Unset Tail
MapUtil.QuickChangeBlockAt(_path.get(back), _pathId, (byte) 0);
}
_index = (_index+1)%_path.size();
_colorTick = !_colorTick;
}
public byte GetColor()
{
if (_colorTick)
return _color;
return 0;
}
}

View File

@ -0,0 +1,201 @@
package nautilus.game.arcade.game.games.christmas.content;
import java.util.ArrayList;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Snowman;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.christmas.Christmas;
import net.minecraft.server.v1_6_R3.EntityCreature;
public class SnowmanBoss
{
private Christmas Host;
private Location _spawn;
private ArrayList<SnowmanMinion> _minions;
private Creature _heart;
public SnowmanBoss(Christmas host, Location spawn)
{
Host = host;
_spawn = spawn;
_minions = new ArrayList<SnowmanMinion>();
//Spawn
Host.CreatureAllowOverride = true;
for (int i=0 ; i<20 ; i++)
_minions.add(new SnowmanMinion(_spawn.getWorld().spawn(_spawn, Snowman.class)));
_heart = _spawn.getWorld().spawn(_spawn, IronGolem.class);
_heart.setMaxHealth(200);
_heart.setHealth(200);
UtilEnt.Vegetate(_heart);
Host.CreatureAllowOverride = false;
//Stack
Entity base = null;
for (SnowmanMinion ent : _minions)
{
if (base != null)
base.setPassenger(ent.Ent);
base = ent.Ent;
}
base.setPassenger(_heart);
}
public void UpdateMove()
{
for (SnowmanMinion minion : _minions)
{
if (minion.Ent.getVehicle() != null)
continue;
if (!minion.CanStack())
continue;
Entity minionStack = minion.Ent;
while (minionStack.getPassenger() != null)
minionStack = minionStack.getPassenger();
//Move Towards Heart
if (!(minionStack instanceof Slime))
{
EntityCreature ec = ((CraftCreature)minion.Ent).getHandle();
ec.getControllerMove().a(_heart.getLocation().getX(), minion.Ent.getLocation().getY(), _heart.getLocation().getZ(), 1f);
}
//Move Towards Spawn
else
{
EntityCreature ec = ((CraftCreature)minion.Ent).getHandle();
ec.getControllerMove().a(_spawn.getX(), _spawn.getY(), _spawn.getZ(), 1f);
}
}
//Clean
if (_heart != null && !_heart.isValid())
{
for (SnowmanMinion minion : _minions)
{
minion.Ent.getWorld().playEffect(minion.Ent.getLocation(), Effect.STEP_SOUND, 80);
minion.Ent.remove();
}
_minions.clear();
}
}
public void UpdateCombine()
{
for (SnowmanMinion minion : _minions)
{
if (minion.Ent.getVehicle() != null)
continue;
if (!minion.CanStack())
continue;
Entity minionStack = minion.Ent;
while (minionStack.getPassenger() != null)
minionStack = minionStack.getPassenger();
//Combine Heart
if (_heart.getVehicle() == null)
{
if (UtilMath.offset(minion.Ent, _heart) < 3)
{
minionStack.setPassenger(_heart);
return;
}
}
//Combine Stacks
if (minionStack instanceof Slime)
{
for (SnowmanMinion other : _minions)
{
if (other.Ent.getVehicle() != null)
continue;
if (!other.CanStack())
continue;
if (minion.equals(other))
continue;
if (UtilMath.offset(minion.Ent, other.Ent) > 2)
continue;
Entity otherStack = other.Ent;
while (otherStack.getPassenger() != null)
otherStack = otherStack.getPassenger();
if (minionStack instanceof Slime)
{
otherStack.setPassenger(minion.Ent);
}
else
{
minionStack.setPassenger(other.Ent);
}
return;
}
}
}
}
public void Damage(CustomDamageEvent event)
{
//Stack Shatter
if (event.GetDamageeEntity().equals(_heart))
{
Entity cur = _heart;
while (cur.getVehicle() != null)
{
Entity past = cur;
cur = cur.getVehicle();
cur.eject();
past.setVelocity(new Vector((Math.random() - 0.5)*2, (Math.random())*1, (Math.random() - 0.5)*2));
}
for (SnowmanMinion minion : _minions)
minion.StackDelay = System.currentTimeMillis();
return;
}
//Snowman Immunity
for (SnowmanMinion minion : _minions)
{
if (event.GetDamageeEntity().equals(minion.Ent))
{
event.SetCancelled("Snowman Immunity");
return;
}
}
}
public boolean IsDead()
{
return !_heart.isValid();
}
}

View File

@ -0,0 +1,31 @@
package nautilus.game.arcade.game.games.christmas.content;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilTime;
import org.bukkit.Location;
import org.bukkit.entity.Snowman;
public class SnowmanMinion
{
public Snowman Ent;
public Location OrbitLocation;
public long StackDelay;
public long AttackDelay;
public SnowmanMinion(Snowman ent)
{
Ent = ent;
UtilEnt.Vegetate(Ent);
StackDelay = 0;
AttackDelay = System.currentTimeMillis();
}
public boolean CanStack()
{
return UtilTime.elapsed(StackDelay, 5000);
}
}

View File

@ -0,0 +1,147 @@
package nautilus.game.arcade.game.games.christmas.content;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.christmas.Christmas;
import net.minecraft.server.v1_6_R3.EntityCreature;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowman;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.util.Vector;
public class SnowmanWaveA
{
private Christmas Host;
private ArrayList<Location> _spawns;
private Location _present;
private int xDir = 1;
private long lastSpawn = 0;
private int lastGap = 0;
private ArrayList<Snowman> _ents = new ArrayList<Snowman>();
public SnowmanWaveA(Christmas host, ArrayList<Location> spawns, Location waypoint, Location[] presents)
{
Host = host;
_spawns = new ArrayList<Location>();
//Order Spawns
while (!spawns.isEmpty())
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : spawns)
{
double dist = UtilMath.offset(waypoint, loc);
if (bestLoc == null || bestDist > dist)
{
bestLoc = loc;
bestDist = dist;
}
}
_spawns.add(bestLoc);
spawns.remove(bestLoc);
}
//Set Present
if (UtilMath.offset(presents[0], _spawns.get(0)) < UtilMath.offset(presents[0], _spawns.get(0)))
{
_present = presents[0].getBlock().getLocation();
}
else
{
_present = presents[1].getBlock().getLocation();
}
}
public void Update()
{
//Spawn
if (!Host.GetSleigh().HasPresent(_present))
{
if (UtilTime.elapsed(lastSpawn, 2000))
{
lastSpawn = System.currentTimeMillis();
int gap = 1 + UtilMath.r(_spawns.size() - 1);
//Ensure Gap is different to last
while (Math.abs(lastGap - gap) < 5 || Math.abs(lastGap - gap) > 13)
gap = 1 + UtilMath.r(_spawns.size() - 1);
lastGap = gap;
for (int i=0 ; i<_spawns.size() ; i++)
{
if (Math.abs(gap - i) <= 2)
continue;
Location loc = _spawns.get(i);
Host.CreatureAllowOverride = true;
Snowman ent = loc.getWorld().spawn(loc, Snowman.class);
Host.CreatureAllowOverride = false;
UtilEnt.Vegetate(ent);
UtilEnt.ghost(ent, true);
_ents.add(ent);
}
}
}
Iterator<Snowman> entIterator = _ents.iterator();
//Move & Die
while (entIterator.hasNext())
{
Snowman ent = entIterator.next();
EntityCreature ec = ((CraftCreature)ent).getHandle();
ec.getControllerMove().a(ent.getLocation().getX()+xDir, ent.getLocation().getY(), ent.getLocation().getZ(), 1.8f);
double dist = Math.abs(_spawns.get(0).getX() - ent.getLocation().getX());
if (ent.getTicksLived() > 500 || dist > 52)
{
ent.getWorld().playEffect(ent.getLocation(), Effect.STEP_SOUND, 80);
ent.remove();
entIterator.remove();
}
}
//Hit Players
for (Player player : Host.GetPlayers(true))
{
if (!Recharge.Instance.usable(player, "Snowman Hit"))
return;
for (Snowman snowman : _ents)
{
if (UtilMath.offset(player, snowman) < 1)
{
UtilAction.velocity(player, new Vector(xDir,0,0), 4, false, 0, 1.2, 1.2, true);
Recharge.Instance.useForce(player, "Snowman Hit", 2000);
//Damage Event
Host.Manager.GetDamage().NewDamageEvent(player, snowman, null,
DamageCause.ENTITY_ATTACK, 4, false, false, false,
null, null);
}
}
}
}
}

View File

@ -0,0 +1,143 @@
package nautilus.game.arcade.game.games.christmas.content;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.christmas.Christmas;
import net.minecraft.server.v1_6_R3.EntityCreature;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowman;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.util.Vector;
public class SnowmanWaveB
{
private Christmas Host;
private ArrayList<Location> _spawns;
private Location _present;
private int xDir = -1;
private long _lastSpawn = 0;
private ArrayList<Integer> _lastPositions = new ArrayList<Integer>();
private ArrayList<Snowman> _ents = new ArrayList<Snowman>();
public SnowmanWaveB(Christmas host, ArrayList<Location> spawns, Location waypoint, Location[] presents)
{
Host = host;
_spawns = new ArrayList<Location>();
//Order Spawns
while (!spawns.isEmpty())
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : spawns)
{
double dist = UtilMath.offset(waypoint, loc);
if (bestLoc == null || bestDist > dist)
{
bestLoc = loc;
bestDist = dist;
}
}
_spawns.add(bestLoc);
spawns.remove(bestLoc);
}
//Set Present
if (UtilMath.offset(presents[0], _spawns.get(0)) < UtilMath.offset(presents[1], _spawns.get(0)))
{
_present = presents[0].getBlock().getLocation();
}
else
{
_present = presents[1].getBlock().getLocation();
}
}
public void Update()
{
//Spawn
if (!Host.GetSleigh().HasPresent(_present))
{
if (Math.random() > 0.25)
{
_lastSpawn = System.currentTimeMillis();
while (_lastPositions.size() > 6)
_lastPositions.remove(0);
int i = UtilMath.r(_spawns.size());
while (_lastPositions.contains(i))
i = UtilMath.r(_spawns.size());
_lastPositions.add(i);
Location loc = _spawns.get(i);
Host.CreatureAllowOverride = true;
Snowman ent = loc.getWorld().spawn(loc, Snowman.class);
Host.CreatureAllowOverride = false;
UtilEnt.Vegetate(ent);
UtilEnt.ghost(ent, true);
_ents.add(ent);
}
}
Iterator<Snowman> entIterator = _ents.iterator();
//Move & Die
while (entIterator.hasNext())
{
Snowman ent = entIterator.next();
EntityCreature ec = ((CraftCreature)ent).getHandle();
ec.getControllerMove().a(ent.getLocation().getX()+xDir, ent.getLocation().getY(), ent.getLocation().getZ(), 2f);
double dist = Math.abs(_spawns.get(0).getX() - ent.getLocation().getX());
if (ent.getTicksLived() > 500 || dist > 52)
{
ent.getWorld().playEffect(ent.getLocation(), Effect.STEP_SOUND, 80);
ent.remove();
entIterator.remove();
}
}
//Hit Players
for (Player player : Host.GetPlayers(true))
{
if (!Recharge.Instance.usable(player, "Snowman Hit"))
return;
for (Snowman snowman : _ents)
{
if (UtilMath.offset(player, snowman) < 1)
{
UtilAction.velocity(player, new Vector(xDir,0,0), 4, false, 0, 1.2, 1.2, true);
Recharge.Instance.useForce(player, "Snowman Hit", 2000);
//Damage Event
Host.Manager.GetDamage().NewDamageEvent(player, snowman, null,
DamageCause.ENTITY_ATTACK, 4, false, false, false,
null, null);
}
}
}
}
}

View File

@ -0,0 +1,60 @@
package nautilus.game.arcade.game.games.christmas.kits;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public class KitPlayer extends Kit
{
public KitPlayer(ArcadeManager manager)
{
super(manager, "Santa's Helper", KitAvailability.Free,
new String[]
{
"Help Santa retreive the lost presents!"
},
new Perk[]
{
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_SWORD));
}
@Override
public void GiveItems(Player player)
{
//Sword
ItemStack item = ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, C.cGreen + C.Bold + "Santas Sword");
player.getInventory().setItem(0, item);
//Bow
item = ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, C.cGreen + C.Bold + "Christmas Bow");
item.addEnchantment(Enchantment.ARROW_INFINITE, 1);
player.getInventory().setItem(1, item);
player.getInventory().setItem(28, ItemStackFactory.Instance.CreateStack(Material.ARROW));
//Axe
item = ItemStackFactory.Instance.CreateStack(Material.DIAMOND_PICKAXE, (byte)0, 1, C.cGreen + C.Bold + "Elf Pickaxe");
player.getInventory().setItem(2, item);
//Armor
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET));
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));
Manager.GetCondition().Factory().Regen("Perm", player, player, 3600000, 0, false, false, true);
}
}

View File

@ -0,0 +1,265 @@
package nautilus.game.arcade.game.games.christmas.parts;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilDisplay;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.christmas.Christmas;
import net.minecraft.server.v1_6_R3.EntityCreature;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
public abstract class Part implements Listener
{
public Christmas Host;
protected Location _sleigh;
protected Location[] _presents;
protected boolean _presentsAnnounce = false;
protected String _objective = "Follow Santa";
protected double _objectiveHealth = 1;
protected HashMap<Creature, Player> _creatures = new HashMap<Creature, Player>();
public Part(Christmas host, Location sleigh, Location[] presents)
{
Host = host;
_sleigh = sleigh;
_presents = presents;
for (Location loc : _presents)
loc.getBlock().setType(Material.AIR);
}
public void Prepare()
{
Activate();
for (Location loc : _presents)
{
Block present = loc.getBlock();
present.setTypeIdAndData(Material.SKULL.getId(), (byte)1, true);
Skull skull = (Skull) present.getState();
skull.setSkullType(SkullType.PLAYER);
//Present Type
double r = Math.random();
if (r > 0.75) skull.setOwner("CruXXx");
else if (r > 0.5) skull.setOwner("CruXXx");
else if (r > 0.25) skull.setOwner("CruXXx");
else skull.setOwner("CruXXx");
//Angle
BlockFace face = BlockFace.UP;
while (face == BlockFace.UP || face == BlockFace.DOWN || face == BlockFace.SELF)
face = BlockFace.values()[UtilMath.r(BlockFace.values().length)];
skull.setRotation(face);
skull.update();
//Beacon
present.getRelative(BlockFace.DOWN).setType(Material.BEACON);
for (int x=-1 ; x<=1 ; x++)
for (int z=-1 ; z<=1 ; z++)
present.getRelative(x, -2, z).setType(Material.IRON_BLOCK);
}
}
public abstract void Activate();
public boolean IsDone()
{
if (CanFinish())
{
if (HasPresents())
{
//Deregister
HandlerList.unregisterAll(this);
//Clean
KillCreatures();
SetObjectiveText("Follow Santa", 1);
Host.SantaSay("Let's move!");
return true;
}
else if (!_presentsAnnounce)
{
SetObjectivePresents();
Host.SantaSay("Collect the presents and we can get out of here!");
_presentsAnnounce = true;
}
}
return false;
}
public void SetObjectivePresents()
{
SetObjectiveText("Collect the two Presents", 1);
}
public abstract boolean CanFinish();
public Location GetSleighWaypoint()
{
return _sleigh;
}
public Location[] GetPresents()
{
return _presents;
}
public boolean HasPresents()
{
for (Location loc : _presents)
if (!Host.GetSleigh().HasPresent(loc.getBlock().getLocation()))
return false;
return true;
}
@EventHandler
public void PresentCollect(PlayerInteractEvent event)
{
if (event.getClickedBlock() == null)
return;
boolean contains = false;
for (Location loc : _presents)
if (loc.getBlock().equals(event.getClickedBlock()))
contains = true;
if (!contains)
return;
event.setCancelled(true);
if (!Host.IsLive())
return;
if (!Host.IsAlive(event.getPlayer()))
return;
if (Host.GetSleigh().HasPresent(event.getClickedBlock().getLocation()))
return;
Host.GetSleigh().AddPresent(event.getClickedBlock().getLocation());
Host.SantaSay("Well done " + event.getPlayer().getName() + "! You collected a present!");
}
public void SetObjectiveText(String text, double percent)
{
_objective = text;
_objectiveHealth = percent;
}
@EventHandler
public void ObjectiveDisplay(UpdateEvent event)
{
if (!Host.InProgress())
return;
if (event.getType() != UpdateType.TICK)
return;
for (Player player : UtilServer.getPlayers())
UtilDisplay.displayTextBar(Host.Manager.GetPlugin(), player, _objectiveHealth, C.cYellow + C.Bold + _objective);
}
public void AddCreature(Creature ent)
{
_creatures.put(ent, null);
}
public HashMap<Creature, Player> GetCreatures()
{
return _creatures;
}
@EventHandler
public void UpdateCreatures(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Creature> entIterator = _creatures.keySet().iterator();
//Move & Die
while (entIterator.hasNext())
{
Creature ent = entIterator.next();
//Get Target
Player target = _creatures.get(ent);
if (target == null || !target.isValid() || !Host.IsAlive(target))
{
if (Host.GetPlayers(true).size() > 0)
{
target = UtilAlg.Random(Host.GetPlayers(true));
_creatures.put(ent, target);
}
else
{
continue;
}
}
//Speed
float speed = 1f;
if (ent instanceof Ageable)
{
if (!((Ageable)ent).isAdult())
speed = 0.6f;
}
//Move
EntityCreature ec = ((CraftCreature)ent).getHandle();
ec.getControllerMove().a(target.getLocation().getX(), target.getLocation().getY(), target.getLocation().getZ(), speed);
//Remove
if (!ent.isValid())
{
ent.remove();
entIterator.remove();
}
}
}
public void KillCreatures()
{
//for (Creature ent : _creatures.keySet())
// ent.damage(5000);
_creatures.clear();
}
}

View File

@ -0,0 +1,199 @@
package nautilus.game.arcade.game.games.christmas.parts;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
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.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.christmas.Christmas;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
public class Part1 extends Part
{
private ArrayList<Location> _skeletons;
private ArrayList<Location> _tnt;
private ArrayList<Location> _blocks;
private ArrayList<Location> _clear;
private long _presents = -1;
private long _ignited = -1;
private long _exploded = -1;
private long _cleared = -1;
public Part1(Christmas host, Location sleigh, Location[] presents, ArrayList<Location> skeletons, ArrayList<Location> tnt, ArrayList<Location> blocks, ArrayList<Location> clear)
{
super(host, sleigh, presents);
_skeletons = skeletons;
_tnt = tnt;
_blocks = blocks;
_clear = clear;
for (Location loc : _blocks)
if (loc.getBlock().getRelative(BlockFace.UP).getType() == Material.AIR)
loc.getBlock().setType(Material.SNOW);
else
loc.getBlock().setType(Material.STONE);
//Clear
Iterator<Location> locIterator = _clear.iterator();
while (locIterator.hasNext())
{
Location loc = locIterator.next();
if (UtilMath.offset(loc, GetSleighWaypoint()) > 50)
locIterator.remove();
loc.getBlock().setType(Material.AIR);
}
}
@Override
public void Activate()
{
Host.SantaSay("Follow me! Let's find those stolen presents!");
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() == UpdateType.FAST)
UpdatePresents();
if (event.getType() == UpdateType.FAST)
UpdateIgnite();
if (event.getType() == UpdateType.FAST)
UpdateExplode();
if (event.getType() == UpdateType.FAST)
UpdateClear();
if (event.getType() == UpdateType.FAST)
UpdateSkeleton();
}
private void UpdateSkeleton()
{
if (_exploded < 0)
return;
if (GetCreatures().size() > 40)
return;
//Create
Location loc = UtilAlg.Random(_skeletons);
Host.CreatureAllowOverride = true;
Skeleton skel = loc.getWorld().spawn(loc, Skeleton.class);
skel.getEquipment().setItemInHand(new ItemStack(Material.WOOD_HOE));
skel.setHealth(4);
Host.CreatureAllowOverride = false;
this.AddCreature(skel);
}
private void UpdatePresents()
{
if (_presents > 0)
return;
if (UtilMath.offset(Host.GetSleigh().GetLocation(), GetSleighWaypoint()) > 35)
return;
_presents = System.currentTimeMillis();
Host.SantaSay("Theres some of the presents up ahead!");
SetObjectivePresents();
}
private void UpdateIgnite()
{
if (_ignited > 0)
return;
if (UtilMath.offset(Host.GetSleigh().GetLocation(), GetSleighWaypoint()) > 20)
return;
_ignited = System.currentTimeMillis();
for (Location loc : _tnt)
loc.getWorld().spawn(loc, TNTPrimed.class);
Host.SantaSay("LOOK OUT! IT'S A TRAP!!!");
}
private void UpdateExplode()
{
if (_exploded > 0)
return;
if (_ignited < 0)
return;
if (!UtilTime.elapsed(_ignited, 4000))
return;
_exploded = System.currentTimeMillis();
for (Location loc : _blocks)
{
Block block = loc.getBlock();
block.setType(Material.AIR);
loc.getWorld().spawnFallingBlock(loc, Material.COBBLESTONE, (byte) 0);
}
Host.SantaSay("Clear the path! Watch out for the undead!");
SetObjectiveText("Clear a path for Santas Sleigh!", 1);
}
private void UpdateClear()
{
if (_cleared > 0)
return;
//Not Exploded
if (_exploded < 0 || !UtilTime.elapsed(_exploded, 5000))
return;
//Not Clear
for (Location loc : _clear)
if (loc.getBlock().getType() != Material.AIR)
return;
_cleared = System.currentTimeMillis();
}
public boolean CanFinish()
{
if (_cleared < 0 || !UtilTime.elapsed(_cleared, 2000))
return false;
return true;
}
}

View File

@ -0,0 +1,237 @@
package nautilus.game.arcade.game.games.christmas.parts;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.disguise.disguises.DisguiseSpider;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.christmas.Christmas;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Spider;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class Part2 extends Part
{
private ArrayList<Location> _spiders;
private ArrayList<Location> _switches;
private ArrayList<Location> _switchLights;
private ArrayList<Location> _switched = new ArrayList<Location>();
private boolean _a = false;
private boolean _b = false;
public Part2(Christmas host, Location sleigh, Location[] presents, ArrayList<Location> spiders, ArrayList<Location> switches, ArrayList<Location> switchLights)
{
super(host, sleigh, presents);
_spiders = spiders;
_switches = new ArrayList<Location>();
for (Location loc : switches)
_switches.add(loc.getBlock().getLocation());
_switchLights = switchLights;
for (Location loc : _switchLights)
loc.getBlock().setTypeIdAndData(35, (byte)14, false);
}
@Override
public void Activate()
{
for (Location loc : _switches)
loc.getBlock().setTypeIdAndData(69, (byte)5, false);
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() == UpdateType.FAST)
UpdateIntroA();
if (event.getType() == UpdateType.FAST)
UpdateIntroB();
if (event.getType() == UpdateType.FAST)
UpdateSpiders();
if (event.getType() == UpdateType.FASTER)
UpdateSpiderLeap();
if (event.getType() == UpdateType.SEC)
{
if (_switched.size() == 4 && HasPresents())
{
SetObjectiveText("Wait for the Magic Bridge", 1);
}
}
}
private void UpdateIntroA()
{
if (_a)
return;
if (UtilMath.offset(Host.GetSleigh().GetLocation(), GetSleighWaypoint()) > 20)
return;
_a = true;
Host.SantaSay("Oh no! My magic bridge has been turned off!");
}
private void UpdateIntroB()
{
if (_b)
return;
if (UtilMath.offset(Host.GetSleigh().GetLocation(), GetSleighWaypoint()) > 10)
return;
_b = true;
Host.SantaSay("Turn on all four switches to rebuild it!");
SetObjectiveText("Turn on the 4 switches", 0);
}
private void UpdateSpiders()
{
if (GetCreatures().size() > 40)
return;
if (!_a)
return;
//Create
Location loc = UtilAlg.Random(_spiders);
Host.CreatureAllowOverride = true;
Skeleton ent = loc.getWorld().spawn(loc, Skeleton.class);
Host.CreatureAllowOverride = false;
DisguiseSpider disguise = new DisguiseSpider(ent);
Host.Manager.GetDisguise().disguise(disguise);
ent.setHealth(10);
this.AddCreature(ent);
}
private void UpdateSpiderLeap()
{
for (Creature ent : GetCreatures().keySet())
{
if (!UtilEnt.isGrounded(ent))
continue;
if (Math.random() > 0.05)
continue;
Player target = GetCreatures().get(ent);
if (target == null || !target.isValid())
continue;
double flatDist = UtilMath.offset(ent, target);
double yDiff = target.getLocation().getY() - ent.getLocation().getY();
UtilAction.velocity(ent, UtilAlg.getTrajectory(ent, target), Math.min(1.6, 0.2 + (0.1 * flatDist)), false, 0, 0.1 + (0.1 * yDiff), 1.4, true);
ent.getWorld().playSound(ent.getLocation(), Sound.SPIDER_IDLE, 1.5f, 2f);
}
}
@EventHandler
public void ToggleSwitch(PlayerInteractEvent event)
{
if (event.getClickedBlock() == null)
return;
if (!_switches.contains(event.getClickedBlock().getLocation()))
return;
if (_switched.contains(event.getClickedBlock().getLocation()))
return;
event.setCancelled(true);
if (!Host.IsLive())
return;
if (!Host.IsAlive(event.getPlayer()))
return;
//Set
_switched.add(event.getClickedBlock().getLocation());
//Visual
Location bestLoc = null;
double bestDist = 0;
for (Location loc : _switchLights)
{
double dist = UtilMath.offset(event.getClickedBlock().getLocation(), loc);
if (bestLoc == null || bestDist > dist)
{
bestLoc = loc;
bestDist = dist;
}
}
bestLoc.getBlock().setData((byte)5);
UtilFirework.playFirework(bestLoc, FireworkEffect.builder().flicker(true).withColor(Color.GREEN).with(Type.BALL).trail(true).build());
//Announce
if (_switched.size() == 1)
{
Host.SantaSay("Great job, " + event.getPlayer().getName() + "! Only 3 switches to go!");
SetObjectiveText("Turn on the 4 switches", 0.25);
}
else if (_switched.size() == 2)
{
Host.SantaSay("Well done, " + event.getPlayer().getName() + "! Only 2 switches to go!");
SetObjectiveText("Turn on the 4 switches", 0.5);
}
else if (_switched.size() == 3)
{
Host.SantaSay("Wonderful, " + event.getPlayer().getName() + "! Only 1 switch to go!");
SetObjectiveText("Turn on the 4 switches", 0.75);
}
else if (_switched.size() == 4)
{
Host.SantaSay("Congratulations, " + event.getPlayer().getName() + "! The bridge is spawning!");
if (!HasPresents())
SetObjectivePresents();
}
}
@Override
public boolean CanFinish()
{
return _switched.size() >= 4;
}
}

View File

@ -0,0 +1,156 @@
package nautilus.game.arcade.game.games.christmas.parts;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.christmas.Christmas;
import nautilus.game.arcade.game.games.christmas.content.SnowmanBoss;
import nautilus.game.arcade.game.games.christmas.content.SnowmanWaveA;
import nautilus.game.arcade.game.games.christmas.content.SnowmanWaveB;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.event.EventHandler;
public class Part3 extends Part
{
private ArrayList<Location> _snowmenA;
private ArrayList<Location> _snowmenB;
private ArrayList<Location> _boss;
private ArrayList<Location> _bridge;
private SnowmanBoss _snowman;
private SnowmanWaveA _waveA;
private SnowmanWaveB _waveB;
private boolean _a = false;
public Part3(Christmas host, Location sleigh, Location[] presents, ArrayList<Location> snowmenA, ArrayList<Location> snowmenB, ArrayList<Location> boss, ArrayList<Location> bridge)
{
super(host, sleigh, presents);
_snowmenA = snowmenA;
_snowmenB = snowmenB;
_boss = boss;
_bridge = bridge;
}
@Override
public void Activate()
{
_waveA = new SnowmanWaveA(Host, _snowmenA, GetSleighWaypoint(), GetPresents());
_waveB = new SnowmanWaveB(Host, _snowmenB, GetSleighWaypoint(), GetPresents());
}
private void UpdateBridge()
{
if (_bridge.isEmpty())
return;
int lowest = 1000;
for (Location loc : _bridge)
if (loc.getBlockZ() < lowest)
lowest = loc.getBlockZ();
Iterator<Location> gateIterator = _bridge.iterator();
boolean sound = true;
while (gateIterator.hasNext())
{
Location loc = gateIterator.next();
if (loc.getBlockZ() == lowest)
{
byte color = 14;
if (lowest % 6 == 1) color = 1;
else if (lowest % 6 == 2) color = 4;
else if (lowest % 6 == 3) color = 5;
else if (lowest % 6 == 4) color = 3;
else if (lowest % 6 == 5) color = 2;
loc.getBlock().setTypeIdAndData(35, color, false);
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 35);
gateIterator.remove();
if (sound)
{
loc.getWorld().playSound(loc, Sound.ZOMBIE_UNFECT, 1f, 1f);
sound = false;
}
}
}
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() == UpdateType.FASTER)
UpdateBridge();
if (event.getType() == UpdateType.TICK)
if (_snowman != null)
_snowman.UpdateMove();
if (event.getType() == UpdateType.FASTER)
if (_snowman != null)
_snowman.UpdateCombine();
if (event.getType() == UpdateType.TICK)
if (_waveA != null)
_waveA.Update();
if (event.getType() == UpdateType.TICK)
if (_waveB != null)
_waveB.Update();
if (event.getType() == UpdateType.FAST)
if (_snowman == null)
if (HasPresents())
{
_snowman = new SnowmanBoss(Host, _boss.get(0));
Host.SantaSay("WATCH OUT! It's some kind of snow beast!");
SetObjectiveText("Kill the Snow Monster", 1);
}
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (_snowman != null)
_snowman.Damage(event);
}
@EventHandler
public void UpdateIntro(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!_a)
{
if (UtilMath.offset(Host.GetSleigh().GetLocation(), GetSleighWaypoint()) > 10)
return;
_a = true;
Host.SantaSay("Collect those presents, I'll try to open the gate!");
SetObjectivePresents();
}
}
@Override
public boolean CanFinish()
{
return (_snowman != null && _snowman.IsDead() && HasPresents());
}
}

View File

@ -0,0 +1,230 @@
package nautilus.game.arcade.game.games.christmas.parts;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.christmas.Christmas;
import nautilus.game.arcade.game.games.christmas.content.CaveGiant;
import nautilus.game.arcade.game.games.christmas.content.Snake;
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.FallingBlock;
import org.bukkit.entity.Giant;
import org.bukkit.entity.Spider;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
public class Part4 extends Part
{
private ArrayList<Location> _roofIce;
private ArrayList<Location> _mobSpawns;
private ArrayList<Location> _gate;
private ArrayList<Snake> _snakes;
private Location _giantSpawn;
private CaveGiant _giant;
private boolean _a = false;
public Part4(Christmas host, Location sleigh, Location[] presents, ArrayList<Location> roofIce, ArrayList<Location> mobs,
ArrayList<Location> snakeHead, ArrayList<Location> snakeTrail, ArrayList<Location> gate, Location giant)
{
super(host, sleigh, presents);
_roofIce = roofIce;
_mobSpawns = mobs;
_giantSpawn = giant;
_gate = gate;
for (Location loc : roofIce)
loc.getBlock().setType(Material.AIR);
for (Location loc : gate)
loc.getBlock().setType(Material.FENCE);
//Create Snakes
_snakes = new ArrayList<Snake>();
for (Location loc : snakeHead)
_snakes.add(new Snake(loc, snakeTrail));
}
@Override
public void Activate()
{
}
@EventHandler
public void GateUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
if (_gate.isEmpty())
return;
int lowest = 255;
for (Location loc : _gate)
if (loc.getBlockY() < lowest)
lowest = loc.getBlockY();
Iterator<Location> gateIterator = _gate.iterator();
boolean sound = true;
while (gateIterator.hasNext())
{
Location loc = gateIterator.next();
if (loc.getBlockY() == lowest)
{
loc.getBlock().setType(Material.AIR);
gateIterator.remove();
if (sound)
{
loc.getWorld().playSound(loc, Sound.PISTON_RETRACT, 3f, 1f);
sound = false;
}
}
}
}
@EventHandler
public void SnakeUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
for (Snake snake : _snakes)
snake.Update();
}
@EventHandler
public void IceUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
/*
Block block = UtilAlg.Random(_roofIce).getBlock().getRelative(BlockFace.DOWN);
while (block.getType() != Material.AIR && block.getY() > 0)
block = block.getRelative(BlockFace.DOWN);
block.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 0.5, 0.5), Material.ICE, (byte)0);
*/
}
@EventHandler
public void IceLand(EntityChangeBlockEvent event)
{
if (event.getEntity() instanceof FallingBlock)
{
event.setCancelled(true);
event.getEntity().getWorld().playEffect(event.getEntity().getLocation(), Effect.STEP_SOUND, 79);
event.getEntity().remove();
}
}
@EventHandler
public void MonstersUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (HasPresents())
return;
if (GetCreatures().size() > 40)
return;
//Create
Location loc = UtilAlg.Random(_mobSpawns);
Host.CreatureAllowOverride = true;
Zombie ent = loc.getWorld().spawn(loc, Zombie.class);
Host.CreatureAllowOverride = false;
ent.getEquipment().setItemInHand(new ItemStack(Material.WOOD_PICKAXE));
ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
ent.setVillager(true);
ent.setHealth(12);
if (Math.random() > 0.8)
ent.setBaby(true);
this.AddCreature(ent);
}
@EventHandler
public void GiantUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_giant == null && HasPresents())
{
_giant = new CaveGiant(this, _giantSpawn);
Host.SantaSay("OH NO! WHAT WAS THAT?");
SetObjectiveText("Kill the Giant before it reaches Santa", 1);
}
else if (_giant != null)
{
_giant.MoveUpdate();
SetObjectiveText("Kill the Giant before it reaches Santa", _giant.GetEntity().getHealth()/_giant.GetEntity().getMaxHealth());
}
}
@EventHandler
public void UpdateIntro(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!_a)
{
if (UtilMath.offset(Host.GetSleigh().GetLocation(), GetSleighWaypoint()) > 10)
return;
_a = true;
Host.SantaSay("What is that wall of ice?!");
Host.SantaSay("Get those presents while I think of a plan!");
SetObjectivePresents();
}
}
@Override
public boolean CanFinish()
{
return (_giant != null && _giant.IsDead());
}
@EventHandler(priority = EventPriority.LOWEST)
public void GiantKnockback(CustomDamageEvent event)
{
if (event.GetDamageeEntity() instanceof Giant)
event.SetKnockback(false);
}
}

View File

@ -0,0 +1,417 @@
package nautilus.game.arcade.game.games.christmas.parts;
import java.util.ArrayList;
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.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.games.christmas.Christmas;
import nautilus.game.arcade.game.games.christmas.content.*;
import net.minecraft.server.v1_6_R3.EntityCreature;
import org.bukkit.EntityEffect;
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.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class Part5 extends Part
{
private ArrayList<Location> _spawn;
private ArrayList<Location> _floor;
private ArrayList<Location> _playerSpawns;
private ArrayList<Location> _hurt;
private ArrayList<Location> _mobs;
private ArrayList<Location> _snowmenA;
private ArrayList<Location> _snowmenB;
private PumpkinKing _boss;
private BossSnowmanPattern _bossSnowmen;
private BossFloor _bossFloor;
private BossMobs _bossMob;
private long _bossDamageDelay = 0;
private int _state = 0;
private long _stateTime = 0;
private int _stateHealthMax = 8;
private int _stateHealth = 8;
private boolean _a = false;
private boolean _b = false;
private boolean _c = false;
private boolean _d = false;
private boolean _e = false;
private boolean _f = false;
private boolean _g = false;
private boolean _h = false;
private boolean _i = false;
private long _dialogueDelay = 0;
private long _delayTime = 4000;
public Part5(Christmas host, Location sleigh, Location[] presents,
ArrayList<Location> snowmenA, ArrayList<Location> snowmenB, ArrayList<Location> mobs,
ArrayList<Location> floor, ArrayList<Location> playerSpawns, ArrayList<Location> hurt, ArrayList<Location> spawn)
{
super(host, sleigh, presents);
_floor = floor;
_playerSpawns = playerSpawns;
_spawn = spawn;
_hurt = hurt;
_mobs = mobs;
_snowmenA = snowmenA;
_snowmenB = snowmenB;
for (Location loc : _spawn)
loc.getBlock().setType(Material.AIR);
for (Location loc : _playerSpawns)
loc.getBlock().setType(Material.AIR);
for (Location loc : _hurt)
loc.getBlock().setType(Material.AIR);
for (Location loc : _mobs)
loc.getBlock().setType(Material.AIR);
for (Location loc : _snowmenA)
loc.getBlock().setType(Material.AIR);
for (Location loc : _snowmenB)
loc.getBlock().setType(Material.AIR);
}
@Override
public void Activate()
{
_bossSnowmen = new BossSnowmanPattern(this, _snowmenA, _snowmenB, GetSleighWaypoint());
_bossFloor = new BossFloor(this, _floor);
_bossMob = new BossMobs(this, _mobs);
}
@Override
public boolean CanFinish()
{
return (_boss != null && _boss.IsDead());
}
public int GetState()
{
return _state;
}
public long GetStateTime()
{
return _stateTime;
}
@EventHandler
public void UpdateIntro(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!_a)
{
//if (UtilMath.offset(Host.GetSleigh().GetLocation(), GetSleighWaypoint()) > 1)
// return;
_a = true;
_dialogueDelay = System.currentTimeMillis();
Host.SantaSay("WHAT IS THIS?! Who's castle is this?!");
}
else if (_a && !_b && UtilTime.elapsed(_dialogueDelay, _delayTime))
{
_b = true;
_dialogueDelay = System.currentTimeMillis();
Host.BossSay("Unknown Voice", "I will destroy Christmas, Santa Claus!");
}
else if (_b && !_c && UtilTime.elapsed(_dialogueDelay, _delayTime))
{
_c = true;
_dialogueDelay = System.currentTimeMillis();
Host.BossSay("Unknown Voice", "Not even your friends can save you now!");
}
else if (_c && !_d && UtilTime.elapsed(_dialogueDelay, _delayTime))
{
_d = true;
_dialogueDelay = System.currentTimeMillis();
Host.SantaSay("WHO IS THAT?! Reveal yourself!");
}
else if (_d && !_e && UtilTime.elapsed(_dialogueDelay, _delayTime))
{
_e = true;
_dialogueDelay = System.currentTimeMillis();
Host.BossSay("Unknown Voice", "It is me... THE PUMPKIN KING!");
//Start Battle
_boss = new PumpkinKing(this, _spawn.get(0), _floor);
}
else if (_e && !_f && UtilTime.elapsed(_dialogueDelay, _delayTime))
{
_f = true;
_dialogueDelay = System.currentTimeMillis();
Host.BossSay("Pumpkin King", "Revenge shall be mine! You will all die!");
}
else if (_f && !_g && UtilTime.elapsed(_dialogueDelay, _delayTime))
{
_g = true;
_dialogueDelay = System.currentTimeMillis();
Host.SantaSay("My friends beat you before, and they'll do it again!");
}
else if (_g && !_h && UtilTime.elapsed(_dialogueDelay, _delayTime))
{
_h = true;
_dialogueDelay = System.currentTimeMillis();
Host.SantaSay("Prepare yourselves for battle!");
//Teleport
for (int i=0 ; i<Host.GetPlayers(true).size() ; i++)
{
Host.GetPlayers(true).get(i).teleport(_playerSpawns.get(i%_playerSpawns.size()));
Host.GetPlayers(true).get(i).playSound(Host.GetPlayers(true).get(i).getLocation(), Sound.ZOMBIE_UNFECT, 2f, 1f);
}
}
else if (_h && !_i && UtilTime.elapsed(_dialogueDelay, _delayTime))
{
_i = true;
_dialogueDelay = System.currentTimeMillis();
Host.BossSay("Pumpkin King", "Prepare to die, you pathetic humans!");
}
}
@EventHandler
public void ElementUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!_i)
return;
if (_bossSnowmen != null)
_bossSnowmen.Update();
if (_bossFloor != null)
_bossFloor.Update();
if (_bossMob != null)
_bossMob.Update();
}
public void NextState()
{
_state++;
_stateTime = System.currentTimeMillis();
_stateHealth = _stateHealthMax;
_bossSnowmen.SetActive(false, 0);
_bossFloor.SetActive(false, 0);
_bossMob.SetActive(false, 0);
}
@EventHandler
public void HurtPlayer(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : Host.GetPlayers(true))
{
if (_hurt.contains(player.getLocation().getBlock()))
{
player.damage(1);
}
}
}
@EventHandler
public void StateUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_boss == null || _boss.IsDead())
return;
if (!_i)
return;
//Health
SetObjectiveText("Defeat the Pumpkin King!", ((13 * _stateHealthMax) - (_state * _stateHealthMax) - (_stateHealthMax - _stateHealth))/(13d * _stateHealthMax));
if (_bossFloor.ShouldBossMove())
{
_boss.MoveUpdate();
_boss.TNTUpdate();
}
else
{
_boss.StayIdle();
}
//TNT Only
if (_state == 0)
{
}
//Floor (Easy)
else if (_state == 1)
{
_bossFloor.SetActive(true, 0);
}
//Mobs (Easy)
else if (_state == 2)
{
_bossMob.SetActive(true, 0);
}
//Snowmen (Easy)
else if (_state == 3)
{
_bossSnowmen.SetActive(true, 0);
}
//Floor (Medium)
else if (_state == 4)
{
_bossFloor.SetActive(true, 1);
}
//Mobs (Medium)
else if (_state == 5)
{
_bossMob.SetActive(true, 1);
}
//Snowmen (Medium)
else if (_state == 6)
{
_bossSnowmen.SetActive(true, 1);
}
//Floor (Hard)
else if (_state == 7)
{
_bossFloor.SetActive(true, 2);
}
//Mobs (Hard)
else if (_state == 8)
{
_bossMob.SetActive(true, 2);
}
//Snowmen (Hard)
else if (_state == 9)
{
_bossSnowmen.SetActive(true, 2);
}
//Floor + Mobs + Snowmen (Easy)
else if (_state == 10)
{
_bossSnowmen.SetActive(true, 0);
_bossMob.SetActive(true, 0);
_bossFloor.SetActive(true, 0);
}
//Floor + Mobs + Snowmen (Medium)
else if (_state == 11)
{
_bossSnowmen.SetActive(true, 1);
_bossMob.SetActive(true, 1);
_bossFloor.SetActive(true, 1);
}
//Floor + Mobs + Snowmen (Hard)
else if (_state == 12)
{
_bossSnowmen.SetActive(true, 2);
_bossMob.SetActive(true, 2);
_bossFloor.SetActive(true, 2);
}
}
@EventHandler
public void Skip(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().equals("/boss"))
if (event.getPlayer().getName().equals("Chiss"))
{
event.setCancelled(true);
NextState();
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void TNTExplosion(EntityExplodeEvent event)
{
/*
for (Block block : event.blockList())
{
if (block.getType() == Material.WOOL)
{
Host.Manager.GetBlockRestore().Add(block, 0, (byte)0, (long) (1500 + Math.random()*1000));
}
}
*/
event.blockList().clear();
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (_boss == null)
return;
if (!_boss.GetEntity().equals(event.GetDamageeEntity()))
return;
event.SetCancelled("Boss Damage");
if (!UtilTime.elapsed(_bossDamageDelay, 1000))
return;
_bossDamageDelay = System.currentTimeMillis();
event.GetDamageeEntity().playEffect(EntityEffect.HURT);
_stateHealth--;
//Damage Sound
_boss.GetEntity().getWorld().playSound(_boss.GetEntity().getLocation(), Sound.ENDERDRAGON_GROWL, 0.5f, 2f);
//Knockback
Player damager = event.GetDamagerPlayer(false);
if (event.GetCause() == DamageCause.ENTITY_ATTACK)
{
UtilAction.velocity(damager, UtilAlg.getTrajectory(event.GetDamageeEntity(), damager), 1, true, 0.6, 0, 1, true);
}
if (_stateHealth <= 0)
{
NextState();
_boss.GetEntity().getWorld().playSound(_boss.GetEntity().getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.5f);
}
}
public PumpkinKing GetBoss()
{
return _boss;
}
}

1
UNDANGLE THEM BLOBS.bat Normal file
View File

@ -0,0 +1 @@
git fsck