Wizard modifications

This commit is contained in:
libraryaddict 2015-04-03 09:22:31 +13:00
parent a772d4cbf2
commit bb821996b1
6 changed files with 271 additions and 219 deletions

View File

@ -1,102 +0,0 @@
package nautilus.game.arcade.game.games.wizards.spells;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.scheduler.BukkitRunnable;
public class SpellBridge extends Spell implements SpellClickBlock
{
final BlockFace[] radial =
{
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH,
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST
};
private HashMap<Block, Long> _wallExpires = new HashMap<Block, Long>();
@EventHandler
public void onUpdate(UpdateEvent event)
{
Iterator<Entry<Block, Long>> itel = _wallExpires.entrySet().iterator();
while (itel.hasNext())
{
Entry<Block, Long> entry = itel.next();
if (entry.getValue() < System.currentTimeMillis())
{
itel.remove();
if (entry.getKey().getType() == Material.DIRT)
{
entry.getKey().setType(Material.AIR);
}
}
}
}
@Override
public void castSpell(Player p, final Block target)
{
final BlockFace facing = radial[Math.round(p.getEyeLocation().getYaw() / 45f) & 0x7];
p.getWorld().playEffect(target.getLocation(), Effect.STEP_SOUND, Material.DIRT.getId());
final int maxDist = 10 * getSpellLevel(p);
new BukkitRunnable()
{
Block block = target;
int blocks = 0;
@Override
public void run()
{
if (!Wizards.IsLive() || blocks++ >= maxDist)
{
cancel();
return;
}
block = block.getRelative(facing);
Block bs[] = UtilShapes.getSideBlocks(block, facing);
bs = new Block[]
{
bs[0], bs[1], block
};
for (Block b : bs)
{
if (UtilBlock.solid(b))
{
continue;
}
b.setType(Material.DIRT);
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId());
_wallExpires.put(b, System.currentTimeMillis() + ((20 + UtilMath.r(10)) * 1000L));
}
}
}.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 5, 1);
charge(p);
}
}

View File

@ -0,0 +1,35 @@
package nautilus.game.arcade.game.games.wizards.spells;
import java.util.HashMap;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class SpellGust extends Spell implements SpellClick
{
@Override
public void castSpell(Player player)
{
Vector vector = player.getLocation().getDirection().normalize().multiply(0.3);
HashMap<Player, Double> effected = UtilPlayer.getPlayersInPyramid(player, 45, 10 * getSpellLevel(player));
for (Player target : effected.keySet())
{
target.setVelocity(vector);
target.getWorld().playSound(target.getLocation(), Sound.BAT_TAKEOFF, 1, 0.7F);
}
if (!effected.isEmpty())
{
player.playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1, 0.7F);
charge(player);
}
}
}

View File

@ -1,40 +0,0 @@
package nautilus.game.arcade.game.games.wizards.spells;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickEntity;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class SpellLaunch extends Spell implements SpellClickEntity
{
@Override
public void castSpell(Player player, final Entity entity)
{
if (entity instanceof LivingEntity)
{
Wizards.getArcadeManager().GetCondition().Factory()
.Falling("Launch", (LivingEntity) entity, player, 10, false, false);
final int spellLevel = getSpellLevel(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable()
{
public void run()
{
((LivingEntity) entity).setVelocity(new Vector(0, 1F + (spellLevel * 0.15F), 0));
entity.getWorld().playSound(((LivingEntity) entity).getLocation(), Sound.BAT_TAKEOFF, 2, 0);
entity.setFallDistance(-spellLevel * 1.5F);
}
});
charge(player);
}
}
}

View File

@ -0,0 +1,130 @@
package nautilus.game.arcade.game.games.wizards.spells;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock;
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.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class SpellRainbowPath extends Spell implements SpellClick, SpellClickBlock
{
final BlockFace[] radial =
{
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH,
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST
};
final int[] _rainbow = new int[]
{
1, 2, 3, 4, 5, 6, 9, 10, 11, 13, 14
};
private HashMap<Block, Long> _wallExpires = new HashMap<Block, Long>();
@EventHandler
public void onUpdate(UpdateEvent event)
{
Iterator<Entry<Block, Long>> itel = _wallExpires.entrySet().iterator();
while (itel.hasNext())
{
Entry<Block, Long> entry = itel.next();
if (entry.getValue() < System.currentTimeMillis())
{
itel.remove();
if (entry.getKey().getType() == Material.STAINED_GLASS)
{
entry.getKey().setType(Material.AIR);
}
}
}
}
@Override
public void castSpell(Player p)
{
Vector vector = p.getEyeLocation().getDirection().setY(0).normalize();
vector.setX(Math.round(vector.getX()));
vector.setZ(Math.round(vector.getZ()));
castSpell(p, p.getLocation().add(vector).getBlock());
}
@Override
public void castSpell(Player p, final Block target)
{
final Vector vector = p.getEyeLocation().getDirection().normalize().multiply(0.5);
vector.setY(Math.max(Math.min(vector.getY(), -0.5), 0.5));
vector.normalize();
p.getWorld().playEffect(target.getLocation(), Effect.STEP_SOUND, Material.WOOL.getId(), _rainbow[UtilMath.r(_rainbow.length)]);
p.getWorld().playSound(p.getLocation(), Sound.ZOMBIE_UNFECT, 1.5F, 1);
final int maxDist = 10 * getSpellLevel(p);
new BukkitRunnable()
{
Location loc = target.getLocation().add(0.5, 0.5, 0.5);
int blocks;
int colorProgress;
@Override
public void run()
{
if (!Wizards.IsLive() || blocks++ >= maxDist)
{
cancel();
return;
}
loc.add(vector);
Block block = loc.getBlock();
Block[] bs = new Block[]
{
block, UtilAlg.getLeft(vector).toLocation(block.getWorld()).getBlock(),
UtilAlg.getRight(vector).toLocation(block.getWorld()).getBlock()
};
for (Block b : bs)
{
if (UtilBlock.solid(b))
{
continue;
}
b.setType(Material.STAINED_GLASS);
b.setData((byte) _rainbow[colorProgress++ % _rainbow.length]);
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WOOL, b.getData());
_wallExpires.put(b, System.currentTimeMillis() + ((20 + UtilMath.r(10)) * 1000L));
}
block.getWorld().playSound(block.getLocation(), Sound.ZOMBIE_UNFECT, 1.5F, 1);
}
}.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 5, 1);
charge(p);
}
}

View File

@ -1,77 +0,0 @@
package nautilus.game.arcade.game.games.wizards.spells;
import mineplex.core.common.util.UtilBlock;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class SpellSpiderman extends Spell implements SpellClick
{
@Override
public void castSpell(final Player player)
{
shoot(player);
for (int i = 1; i < getSpellLevel(player) * 2; i++)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable()
{
@Override
public void run()
{
shoot(player);
}
}, i * 10);
}
charge(player);
}
private void shoot(Player player)
{
if (Wizards.IsAlive(player))
{
final FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation(), Material.WEB, (byte) 0);
block.setVelocity(player.getEyeLocation().getDirection().multiply(2));
block.getWorld().playSound(block.getLocation(), Sound.CLICK, 0.5F, 0);
block.setDropItem(false);
new BukkitRunnable()
{
public void run()
{
if (!Wizards.IsLive())
{
cancel();
}
else if (!block.isValid())
{
cancel();
Block b = block.getLocation().getBlock();
if (UtilBlock.airFoliage(b) && b.getType() != Material.WEB)
{
b.setType(Material.WEB);
}
}
}
}.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 0);
}
}
}

View File

@ -0,0 +1,106 @@
package nautilus.game.arcade.game.games.wizards.spells;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.util.Vector;
public class SpellWebShot extends Spell implements SpellClick, IThrown
{
@Override
public void castSpell(final Player player)
{
shoot(player);
for (int i = 1; i < getSpellLevel(player) * 2; i++)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable()
{
@Override
public void run()
{
shoot(player);
}
}, i * 10);
}
charge(player);
}
private void shoot(Player player)
{
if (Wizards.IsAlive(player))
{
// Boost
UtilAction.velocity(player, 1.2, 0.2, 1.2, true);
org.bukkit.entity.Item ent = player.getWorld().dropItem(
player.getLocation().add(0, 0.5, 0),
ItemStackFactory.Instance.CreateStack(Material.WEB, (byte) 0, 1,
"Web " + player.getName() + " " + System.currentTimeMillis()));
Vector random = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
random.normalize();
random.multiply(0.2);
UtilAction.velocity(ent, player.getLocation().getDirection().multiply(-1).add(random), 1 + Math.random() * 0.4,
false, 0, 0.2, 10, false);
Wizards.getArcadeManager().GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 2d);
}
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
if (target != null)
{
data.GetThrown().remove();
// Damage Event
Wizards.getArcadeManager().GetDamage().NewDamageEvent(target, data.GetThrower(), null, DamageCause.PROJECTILE, 2, false, false, false,
UtilEnt.getName(data.GetThrower()), "Web Shot");
}
Web(data);
}
@Override
public void Idle(ProjectileUser data)
{
Web(data);
}
@Override
public void Expire(ProjectileUser data)
{
Web(data);
}
public void Web(ProjectileUser data)
{
Location loc = data.GetThrown().getLocation();
data.GetThrown().remove();
if (data.GetThrown().getTicksLived() > 3 && UtilBlock.airFoliage(loc.getBlock()))
loc.getBlock().setType(Material.WEB);
}
}