Fix up iron golem, add slam attack

This commit is contained in:
libraryaddict 2015-08-28 11:42:33 -07:00
parent 379ee9271a
commit 1f5cd624a4
8 changed files with 325 additions and 30 deletions

View File

@ -10,6 +10,7 @@ import java.util.TreeSet;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -354,10 +355,25 @@ public class UtilAlg
return bestLoc; return bestLoc;
} }
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, Entity entity)
{
if (entity instanceof LivingEntity)
{
return calculateVelocity(from, to, heightGain, 1.15);
}
else
{
return calculateVelocity(from, to, heightGain, 0.115);
}
}
public static Vector calculateVelocity(Vector from, Vector to, double heightGain) public static Vector calculateVelocity(Vector from, Vector to, double heightGain)
{ {
// Gravity of a potion return calculateVelocity(from, to, heightGain, 0.115);
double gravity = 0.115; }
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, double gravity)
{
// Block locations // Block locations
int endGain = to.getBlockY() - from.getBlockY(); int endGain = to.getBlockY() - from.getBlockY();

View File

@ -53,7 +53,7 @@ public abstract class WorldEvent implements Listener
private List<EventCreature> _creatures; private List<EventCreature> _creatures;
// Block Restore // Block Restore
private BlockRestoreMap _blocks; private BlockRestoreMap _blocks;
private boolean _instantSchematic; private boolean _isArcade;
private double _difficulty = 1; private double _difficulty = 1;
public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name,
@ -99,9 +99,9 @@ public abstract class WorldEvent implements Listener
_difficulty = difficulty; _difficulty = difficulty;
} }
public void setInstantSchematic(boolean instantSchematic) public void setArcadeGame(boolean isArcade)
{ {
_instantSchematic = instantSchematic; _isArcade = isArcade;
} }
public void loadMap() public void loadMap()
@ -289,16 +289,19 @@ public abstract class WorldEvent implements Listener
@Override @Override
public void run(List<BlockData> data) public void run(List<BlockData> data)
{ {
for (BlockData blockData : data) if (!_isArcade)
{ {
_blocks.addBlockData(blockData); for (BlockData blockData : data)
{
_blocks.addBlockData(blockData);
}
} }
onComplete.run(); onComplete.run();
} }
}); });
task.setBlocksPerTick(_instantSchematic ? 2000000 : 100); task.setBlocksPerTick(_isArcade ? 2000000 : 100);
task.start(); task.start();
} }

View File

@ -12,7 +12,6 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -25,6 +24,7 @@ import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemEarthquake;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemExplodingAura; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemExplodingAura;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemMeleeAttack; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemMeleeAttack;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemRupture; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemRupture;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemSlam;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemWallExplode; import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemWallExplode;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -52,6 +52,7 @@ public class GolemCreature extends EventCreature<IronGolem>
private ArrayList<GolemAbility> _currentAbilities = new ArrayList<GolemAbility>(); private ArrayList<GolemAbility> _currentAbilities = new ArrayList<GolemAbility>();
private double _canCaveIn = 450; private double _canCaveIn = 450;
private Vector _afkWalk = new Vector(); private Vector _afkWalk = new Vector();
private long _lastSlam;
public GolemCreature(GolemBoss boss, Location location, double maxHealth) public GolemCreature(GolemBoss boss, Location location, double maxHealth)
{ {
@ -197,7 +198,7 @@ public class GolemCreature extends EventCreature<IronGolem>
} }
} }
{ // Rumble { // Rupture
ArrayList<Player> players = getPlayers(dist, 30); ArrayList<Player> players = getPlayers(dist, 30);
if (!players.isEmpty()) if (!players.isEmpty())
@ -206,6 +207,15 @@ public class GolemCreature extends EventCreature<IronGolem>
} }
} }
{ // Slam
ArrayList<Player> players = getPlayers(dist, 30);
if (!players.isEmpty() && UtilTime.elapsed(_lastSlam, 20000))
{
weight.put(GolemSlam.class, 6);
}
}
if (_canCaveIn <= 0) // Cave in if (_canCaveIn <= 0) // Cave in
{ {
ArrayList<Player> players = getPlayers(dist, 30); ArrayList<Player> players = getPlayers(dist, 30);
@ -318,10 +328,14 @@ public class GolemCreature extends EventCreature<IronGolem>
{ {
_canCaveIn = 450; _canCaveIn = 450;
} }
else if (ability instanceof GolemSlam)
{
_lastSlam = System.currentTimeMillis();
}
Bukkit.getPluginManager().registerEvents(ability, _boss.getPlugin()); Bukkit.getPluginManager().registerEvents(ability, _boss.getPlugin());
// Bukkit.broadcastMessage("Ability: " + _currentAbility.getClass().getSimpleName()); // Bukkit.broadcastMessage("Prepare fair maidens for " + ability.getClass().getSimpleName() + "!");
System.out.print("Golem boss is using " + ability.getClass().getSimpleName()); System.out.print("Golem boss is using " + ability.getClass().getSimpleName());

View File

@ -33,6 +33,7 @@ import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -215,6 +216,15 @@ public class GolemCaveIn extends GolemAbility
} }
} }
@EventHandler
public void onPhysics(BlockPhysicsEvent event)
{
if (_blocks.contains(event.getBlock()))
{
event.setCancelled(true);
}
}
@Override @Override
public void tick() public void tick()
{ {
@ -242,23 +252,6 @@ public class GolemCaveIn extends GolemAbility
} }
} }
} }
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);
b.setType(Material.FENCE);
}
}
}
} }
if (_tick % 5 == 0) if (_tick % 5 == 0)

View File

@ -105,7 +105,7 @@ public class GolemExplodingAura extends GolemAbility
@Override @Override
public void tick() public void tick()
{ {
if (_tick < 25 * 25) if (_tick < 25 * 25 && getGolem().getHealth() > 30)
{ {
double angle = (2 * Math.PI) / UtilMath.random.nextDouble(); double angle = (2 * Math.PI) / UtilMath.random.nextDouble();
double x = 1.7 * Math.cos(angle); double x = 1.7 * Math.cos(angle);

View File

@ -12,6 +12,7 @@ import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftIronGolem;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -36,6 +37,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
import net.minecraft.server.v1_7_R4.EntityIronGolem;
public class GolemRupture extends GolemAbility public class GolemRupture extends GolemAbility
{ {
@ -191,6 +193,12 @@ public class GolemRupture extends GolemAbility
target.setY(loc.getY()); target.setY(loc.getY());
_ruptures.add(new HashMap.SimpleEntry(loc, target)); _ruptures.add(new HashMap.SimpleEntry(loc, target));
UtilEnt.CreatureLook(getEntity(), player.getLocation());
EntityIronGolem golem = ((CraftIronGolem) getEntity()).getHandle();
golem.world.broadcastEntityEffect(golem, (byte) 4);
} }
else else
{ {

View File

@ -0,0 +1,259 @@
package mineplex.minecraft.game.core.boss.ironwizard.abilities;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
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.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class GolemSlam extends GolemAbility
{
private ArrayList<Item> _items = new ArrayList<Item>();
private int _ticksFinished;
private int _stage;
private Vector _target;
private int _ticksJumped;
public GolemSlam(GolemCreature creature)
{
super(creature);
Player target = getTarget();
if (target != null)
{
_target = UtilAlg.calculateVelocity(getLocation().toVector(),
target.getLocation().toVector().setY(getLocation().getY()), 2, getEntity());
}
}
@Override
public boolean canMove()
{
return !UtilEnt.isGrounded(getEntity()) && _stage == 1;
}
@Override
public boolean hasFinished()
{
return _stage == 2 && --_ticksFinished <= 0;
}
@Override
public void setFinished()
{
for (Item item : _items)
{
item.remove();
}
}
@Override
public void tick()
{
Entity entity = getEntity();
if (_stage == 0)
{
UtilEnt.CreatureLook(getEntity(), getLocation().add(_target));
entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 4, 0);
entity.setVelocity(_target);
_stage++;
}
else if (_stage == 1)
{
_ticksJumped++;
if (_ticksJumped > 4 && getLocation().subtract(0, 0.2, 0).getBlock().getType() != Material.AIR)
{
explodeRupture(getLocation());
_stage = 2;
}
}
}
@EventHandler
public void HopperPickup(InventoryPickupItemEvent event)
{
if (_items.contains(event.getItem()))
event.setCancelled(true);
}
@EventHandler
public void ItemDestroy(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_items.isEmpty())
return;
Iterator<Item> itemIterator = _items.iterator();
while (itemIterator.hasNext())
{
Item item = itemIterator.next();
if (item.isDead() || !item.isValid())
{
item.remove();
itemIterator.remove();
}
else if (UtilEnt.isGrounded(item) || item.getTicksLived() > 60)
{
item.getWorld().playEffect(item.getLocation(), Effect.STEP_SOUND, item.getItemStack().getTypeId());
item.remove();
itemIterator.remove();
}
}
}
@Override
public boolean inProgress()
{
return true;
}
@Override
public Player getTarget()
{
Player target = null;
double dist = 0;
for (Player player : UtilPlayer.getNearby(getLocation(), 30, true))
{
if (!player.hasLineOfSight(getEntity()))
{
continue;
}
double d = player.getLocation().distance(getLocation());
if (d < 10)
{
continue;
}
if (target == null || dist > d)
{
target = player;
dist = d;
}
}
return target;
}
private void explodeRupture(Location loc)
{
loc.add(0, 1.1, 0);
loc.setX(loc.getBlockX() + 0.5);
loc.setZ(loc.getBlockZ() + 0.5);
// Fling
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(loc, 3.5);
for (LivingEntity cur : targets.keySet())
{
if (cur.equals(getEntity()))
{
continue;
}
// Velocity
UtilAction.velocity(cur,
UtilAlg.getTrajectory2d(loc.toVector().add(new Vector(0.5, 0, 0.5)), cur.getLocation().toVector()),
0.8 + 0.8 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.4, true);
// Condition
getGolem().getEvent().getCondition().Factory().Falling("Rupture", cur, getEntity(), 10, false, true);
// Damage Event
getGolem().getEvent().getDamageManager().NewDamageEvent(cur, getEntity(), null, DamageCause.CUSTOM,
4 * getGolem().getDifficulty(), false, true, false, "Iron Wizard", "Rupture");
}
ArrayList<Block> blocks = new ArrayList<Block>();
for (int x = -3; x <= 3; x++)
{
for (int z = -3; z <= 3; z++)
{
for (int y = 0; y <= 1; y++)
{
for (int i = 0; i < 2; i++)
{
if (Math.sqrt(x * x + z * z + y * y) <= 3)
{
blocks.add(loc.clone().add(x, y, z).getBlock());
}
}
}
}
}
Collections.shuffle(blocks);
// Blocks
int done = 0;
Iterator<Block> itel = blocks.iterator();
while (done < 30 && itel.hasNext())
{
Block block = itel.next();
Vector vec = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5).normalize();
if (!UtilBlock.airFoliage(block))
continue;
// Add Directional
vec.add(UtilAlg.getTrajectory(loc.getBlock().getLocation(), block.getLocation().add(0.5, 0, 0.5)));
// Add Up
vec.add(new Vector(0, 1.6, 0));
vec.normalize();
// Scale
vec.multiply(0.1 + 0.3 * Math.random() + 0.6);
// Block!
Item item = loc.getWorld().dropItem(block.getLocation().add(0.5, 0, 0.5), new ItemStack(Material.DIRT.getId(), 0));
item.setVelocity(vec);
item.setPickupDelay(50000);
_items.add(item);
// Effect
loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.DIRT.getId());
done++;
}
_ticksFinished = 20;
}
}

View File

@ -248,6 +248,8 @@ public class BossBattles extends TeamGame
bossDisplay.start(); bossDisplay.start();
bossDisplay.spawnHologram(); bossDisplay.spawnHologram();
_displays.add(bossDisplay);
System.out.print( System.out.print(
"Registered " + bossDisplay.getClass().getSimpleName()); "Registered " + bossDisplay.getClass().getSimpleName());
} }
@ -327,7 +329,7 @@ public class BossBattles extends TeamGame
_currentBoss = createInstance(boss.getBoss(), _currentBoss = createInstance(boss.getBoss(),
new Location(WorldData.World, 0, 6, 0)); new Location(WorldData.World, 0, 6, 0));
_currentBoss.setInstantSchematic(true); _currentBoss.setArcadeGame(true);
_currentBoss.setDifficulty(0.6); _currentBoss.setDifficulty(0.6);
_currentBoss.loadMap(); _currentBoss.loadMap();