Update Iron Wizard attack priority to use Earthquake when surrounded, lower blocks thrown during Cave In and implement Iron Skin arrow resistance

This commit is contained in:
AlexTheCoder 2016-07-02 17:39:04 -04:00 committed by samczsun
parent 1655811d43
commit d4be749edc
2 changed files with 123 additions and 103 deletions

View File

@ -6,6 +6,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Random;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
@ -30,7 +31,9 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -153,7 +156,14 @@ public class GolemCreature extends EventCreature<IronGolem>
if (!players.isEmpty())
{
weight.put(GolemMeleeAttack.class, 999);
if (players.size() >= 4)
{
weight.put(GolemEarthquake.class, 999);
}
else
{
weight.put(GolemMeleeAttack.class, 999);
}
}
}
@ -502,6 +512,16 @@ public class GolemCreature extends EventCreature<IronGolem>
{
if (event.GetDamageePlayer() != null)
{
if (event.GetProjectile() != null && event.GetProjectile() instanceof Arrow)
{
if (new Random().nextDouble() <= .5)
{
event.SetCancelled("Iron Skin Reflection");
getEntity().getWorld().playSound(getEntity().getLocation(), Sound.ZOMBIE_METAL, 0.5f, 1.6f);
return;
}
}
double dist = event.GetDamageePlayer().getLocation().distance(getEntity().getLocation());
double maxRange = _usedFinalAttack ? 20 : 45;

View File

@ -223,108 +223,108 @@ public class GolemCaveIn extends BossAbility<GolemCreature, IronGolem>
@Override
public void tick()
{
// if (_tick++ == 0)
// {
// Location l = getLocation();
//
// ArrayList<Location> blocks = UtilShapes.getSphereBlocks(l, 3, 3, true);
//
// for (Location loc : blocks)
// {
// if (loc.getBlockY() >= l.getBlockY())
// {
// Block b = loc.getBlock();
//
// if (b.getType() == Material.AIR)
// {
// _blocks.add(b);
//
// loc.setY(l.getY() - 1);
//
// b.setType(loc.getBlock().getType());
//
// b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, loc.getBlock().getTypeId());
// }
// }
// }
// }
//
// if (_tick % 5 == 0)
//
// {
// for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true))
// {
// player.teleport(player.getLocation().add(0, 4, 0));
// UtilAction.velocity(player, new Vector(UtilMath.r(10) - 5, 3, UtilMath.r(10) - 5).normalize());
// }
// }
//
// if (_tick < 200)
//
// {
// Location loc = getLocation();
// loc.setY(loc.getY() + 4);
//
// for (int i = 0; i < 30; i++)
// {
// loc.setY(loc.getY() + 1);
// Block b = loc.getBlock();
//
// if (UtilBlock.solid(b))
// {
// break;
// }
// }
//
// if (!UtilBlock.solid(loc.getBlock()))
// {
// return;
// }
//
// List<Player> players = UtilPlayer.getNearby(getLocation(), 50, true);
//
// for (int i = 0; i < players.size() * 4; i++)
// {
// int dist = UtilMath.r(10);
//
// if (dist < 3)
// {
// dist = 2;
// }
// else if (dist < 5)
// {
// dist = 5;
// }
// else
// {
// dist = 10;
// }
//
// Location l = players.get(UtilMath.r(players.size())).getLocation().add(UtilMath.r(dist * 2) - dist, 0,
// UtilMath.r(dist * 2) - dist);
// l.setY(loc.getY());
//
// Block b = l.getBlock();
// l.subtract(0, 1, 0);
//
// if (UtilBlock.solid(b))
// {
// if (l.getBlock().getType() == Material.AIR)
// {
// if (UtilAlg.HasSight(l, getLocation().add(0, 4, 0)))
// {
// FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, -1, 0.5), b.getTypeId(),
// b.getData());
//
// block.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, block.getBlockId());
// block.setDropItem(false);
//
// _fallingBlocks.add(block);
// }
// }
// }
// }
// }
if (_tick++ == 0)
{
Location l = getLocation();
ArrayList<Location> blocks = UtilShapes.getSphereBlocks(l, 3, 3, true);
for (Location loc : blocks)
{
if (loc.getBlockY() >= l.getBlockY())
{
Block b = loc.getBlock();
if (b.getType() == Material.AIR)
{
_blocks.add(b);
loc.setY(l.getY() - 1);
b.setType(loc.getBlock().getType());
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, loc.getBlock().getTypeId());
}
}
}
}
if (_tick % 5 == 0)
{
for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true))
{
player.teleport(player.getLocation().add(0, 4, 0));
UtilAction.velocity(player, new Vector(UtilMath.r(10) - 5, 3, UtilMath.r(10) - 5).normalize());
}
}
if (_tick < 200)
{
Location loc = getLocation();
loc.setY(loc.getY() + 4);
for (int i = 0; i < 30; i++)
{
loc.setY(loc.getY() + 1);
Block b = loc.getBlock();
if (UtilBlock.solid(b))
{
break;
}
}
if (!UtilBlock.solid(loc.getBlock()))
{
return;
}
List<Player> players = UtilPlayer.getNearby(getLocation(), 50, true);
for (int i = 0; i < players.size() * 2; i++)
{
int dist = UtilMath.r(10);
if (dist < 3)
{
dist = 2;
}
else if (dist < 5)
{
dist = 5;
}
else
{
dist = 10;
}
Location l = players.get(UtilMath.r(players.size())).getLocation().add(UtilMath.r(dist * 2) - dist, 0,
UtilMath.r(dist * 2) - dist);
l.setY(loc.getY());
Block b = l.getBlock();
l.subtract(0, 1, 0);
if (UtilBlock.solid(b))
{
if (l.getBlock().getType() == Material.AIR)
{
if (UtilAlg.HasSight(l, getLocation().add(0, 4, 0)))
{
FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, -1, 0.5), b.getTypeId(),
b.getData());
block.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, block.getBlockId());
block.setDropItem(false);
_fallingBlocks.add(block);
}
}
}
}
}
}