Progress on spider
This commit is contained in:
parent
6474f5a9e9
commit
655283e008
@ -8,6 +8,7 @@ import mineplex.core.disguise.disguises.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguiseInsentient;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -301,6 +302,10 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
return;
|
||||
|
||||
DamageCause cause = event.GetCause();
|
||||
|
||||
if (cause == DamageCause.FALL && !getEvent().getCondition().HasCondition(_entity, ConditionType.FALLING, null))
|
||||
event.SetCancelled("Cancel");
|
||||
|
||||
if (cause == DamageCause.DROWNING || cause == DamageCause.FALL || cause == DamageCause.SUFFOCATION)
|
||||
event.SetCancelled("Cancel");
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ public abstract class WorldEvent implements Listener
|
||||
return _map == null ? _cornerLocation : _map.getCenterLocation();
|
||||
}
|
||||
|
||||
protected List<EventCreature> getCreatures()
|
||||
public List<EventCreature> getCreatures()
|
||||
{
|
||||
return _creatures;
|
||||
}
|
||||
|
@ -1,11 +1,22 @@
|
||||
package mineplex.minecraft.game.core.boss.spider;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.EventState;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
@ -15,11 +26,97 @@ import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
|
||||
public class SpiderBoss extends WorldEvent
|
||||
{
|
||||
private HashMap<Block, Double> _webDurability = new HashMap<Block, Double>();
|
||||
|
||||
public SpiderBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager,
|
||||
BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation)
|
||||
{
|
||||
super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, "schematic/Golem.schematic");
|
||||
super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation,
|
||||
"schematic/Golem.schematic");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWebDura(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : getCenterLocation().getWorld().getPlayers())
|
||||
{
|
||||
if (!getEventMap().isInMap(player.getLocation()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = player.getLocation().getBlock();
|
||||
|
||||
if (block.getType() != Material.WEB)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_webDurability.containsKey(block))
|
||||
{
|
||||
_webDurability.put(block, 0D);
|
||||
}
|
||||
|
||||
_webDurability.put(block, _webDurability.get(block) + 0.04);
|
||||
|
||||
if (_webDurability.get(block) > 1)
|
||||
{
|
||||
_webDurability.remove(block);
|
||||
|
||||
block.setType(Material.AIR);
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB);
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<Block> itel = _webDurability.keySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Block block = itel.next();
|
||||
|
||||
_webDurability.put(block, _webDurability.get(block) - 0.01);
|
||||
|
||||
if (_webDurability.get(block) < 0)
|
||||
{
|
||||
itel.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//@EventHandler
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (!getEventMap().isInMap(block.getLocation()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.getType() != Material.WEB)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_webDurability.containsKey(block))
|
||||
{
|
||||
_webDurability.put(block, 0D);
|
||||
}
|
||||
|
||||
_webDurability.put(block, _webDurability.get(block) + 0.4);
|
||||
|
||||
if (_webDurability.get(block) > 1)
|
||||
{
|
||||
_webDurability.remove(block);
|
||||
|
||||
block.setType(Material.AIR);
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
@ -32,6 +33,9 @@ import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderCeilingCling;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderEggplosm;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderPoisonBarrage;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderWebBarrage;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderWebStomp;
|
||||
|
||||
public class SpiderCreature extends EventCreature<Pig>
|
||||
{
|
||||
@ -42,6 +46,7 @@ public class SpiderCreature extends EventCreature<Pig>
|
||||
private Location _standing;
|
||||
private Vector _afkWalk = new Vector();
|
||||
private HashMap<Class, Long> _cooldowns = new HashMap<Class, Long>();
|
||||
private long _lastAttack;
|
||||
|
||||
public SpiderCreature(SpiderBoss boss, Location location, double maxHealth)
|
||||
{
|
||||
@ -121,19 +126,46 @@ public class SpiderCreature extends EventCreature<Pig>
|
||||
|
||||
if (!dist.isEmpty())
|
||||
{
|
||||
{// Egg explosion
|
||||
{// Eggsplosm
|
||||
ArrayList<Player> players = getPlayers(dist, 30);
|
||||
|
||||
if (getHealthPercent() < 0.8 && !players.isEmpty())
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
weight.put(SpiderEggplosm.class, 4);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// Web hang
|
||||
{ // Ceiling Cling
|
||||
weight.put(SpiderCeilingCling.class, 2);
|
||||
}
|
||||
|
||||
{ // Poison barrage
|
||||
if (!getPlayers(dist, 10, 30).isEmpty())
|
||||
{
|
||||
weight.put(SpiderPoisonBarrage.class, 4);
|
||||
}
|
||||
}
|
||||
|
||||
{// Spider egg scatter
|
||||
if (!getPlayers(dist, 20, 40).isEmpty())
|
||||
{
|
||||
weight.put(SpiderPoisonBarrage.class, 4);
|
||||
}
|
||||
}
|
||||
|
||||
{ // Spider web barrage
|
||||
if (!getPlayers(dist, 30).isEmpty())
|
||||
{
|
||||
weight.put(SpiderWebBarrage.class, 4);
|
||||
}
|
||||
}
|
||||
|
||||
{ // Spider web stomp
|
||||
if (!getPlayers(dist, 20).isEmpty())
|
||||
{
|
||||
weight.put(SpiderWebStomp.class, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
@ -223,6 +255,7 @@ public class SpiderCreature extends EventCreature<Pig>
|
||||
{
|
||||
Player target = null;
|
||||
double dist = 0;
|
||||
boolean canAttack = UtilTime.elapsed(_lastAttack, 4000);
|
||||
|
||||
for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true))
|
||||
{
|
||||
@ -233,13 +266,32 @@ public class SpiderCreature extends EventCreature<Pig>
|
||||
|
||||
double d = player.getLocation().distance(getEntity().getLocation());
|
||||
|
||||
if (d > 1.5 && (d < 7 || d > 15) && (target == null || (d < 50 && dist > d)))
|
||||
if ((!canAttack || d > 1.5) && (d < 7 || d > 15) && (target == null || (d < 50 && dist > d)))
|
||||
{
|
||||
target = player;
|
||||
dist = d;
|
||||
}
|
||||
}
|
||||
|
||||
if (target != null && dist < 2 && canAttack)
|
||||
{
|
||||
UtilEnt.CreatureMoveFast(getEntity(), target.getLocation(), 1F);
|
||||
|
||||
_lastAttack = System.currentTimeMillis();
|
||||
Vector vec = UtilAlg.getTrajectory2d(getEntity(), target);
|
||||
vec.multiply(0.4).setY(0.3);
|
||||
|
||||
getEntity().setVelocity(vec);
|
||||
|
||||
getEvent().getCondition().Factory().Confuse("Spider Bite", target, getEntity(), 4, 0, false, true, true);
|
||||
getEvent().getCondition().Factory().Blind("Spider Bite", target, getEntity(), 1.5, 0, false, true, true);
|
||||
getEvent().getCondition().Factory().Slow("Spider Bite", target, getEntity(), 4, 0, false, true, true, true);
|
||||
|
||||
getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK,
|
||||
2 * getDifficulty(), true, false, false, "Spider Attack", "Spider Attack");
|
||||
return;
|
||||
}
|
||||
|
||||
Vector vec = null;
|
||||
boolean superWalk = false;
|
||||
|
||||
@ -319,13 +371,18 @@ public class SpiderCreature extends EventCreature<Pig>
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<Player> getPlayers(final HashMap<Player, Double> map, double maxDist)
|
||||
private ArrayList<Player> getPlayers(HashMap<Player, Double> map, double maxDist)
|
||||
{
|
||||
return getPlayers(map, 0, maxDist);
|
||||
}
|
||||
|
||||
private ArrayList<Player> getPlayers(final HashMap<Player, Double> map, double minDist, double maxDist)
|
||||
{
|
||||
ArrayList<Player> list = new ArrayList<Player>();
|
||||
|
||||
for (Player p : map.keySet())
|
||||
{
|
||||
if (map.get(p) <= maxDist)
|
||||
if (map.get(p) >= minDist && map.get(p) <= maxDist)
|
||||
{
|
||||
list.add(p);
|
||||
}
|
||||
|
@ -8,14 +8,15 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -23,26 +24,24 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.disguise.disguises.DisguiseMonster;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class SpiderCeilingCling extends BossAbility<SpiderCreature, Pig>
|
||||
public class SpiderCeilingCling extends SpiderEggAbility
|
||||
{
|
||||
private double _startedHealth;
|
||||
private boolean _isClinging;
|
||||
private int _tick;
|
||||
private Location _clingTo;
|
||||
private double _y;
|
||||
private double _originalY;
|
||||
private int _eggsToLay = UtilMath.r(10) + 10;
|
||||
|
||||
public SpiderCeilingCling(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
|
||||
_startedHealth = creature.getHealth();
|
||||
_y = getLocation().getY();
|
||||
_originalY = getLocation().getY();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@ -127,6 +126,8 @@ public class SpiderCeilingCling extends BossAbility<SpiderCreature, Pig>
|
||||
getBoss().setUseName(true);
|
||||
getBoss().setShowHealthName(true);
|
||||
getBoss().setName(null);
|
||||
|
||||
setEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -145,7 +146,8 @@ public class SpiderCeilingCling extends BossAbility<SpiderCreature, Pig>
|
||||
{
|
||||
_isClinging = true;
|
||||
}
|
||||
else if (!UtilBlock.airFoliage(getLocation().getBlock().getRelative(BlockFace.UP)) && getLocation().getY() - _y > 10)
|
||||
else if (!UtilBlock.airFoliage(getLocation().getBlock().getRelative(BlockFace.UP))
|
||||
&& getLocation().getY() - _originalY > 10)
|
||||
{
|
||||
_isClinging = true;
|
||||
}
|
||||
@ -163,7 +165,13 @@ public class SpiderCeilingCling extends BossAbility<SpiderCreature, Pig>
|
||||
{
|
||||
Item item = getLocation().getWorld().dropItem(getLocation(), new ItemStack(Material.SLIME_BALL));
|
||||
|
||||
item.setVelocity(UtilAlg.getTrajectory(getEntity(), target));
|
||||
Vector vec = UtilAlg.getTrajectory2d(getEntity(), target);
|
||||
|
||||
double dis = getLocation().toVector().subtract(target.getLocation().toVector()).setY(0).length();
|
||||
|
||||
vec.multiply(dis / 3);
|
||||
|
||||
item.setVelocity(vec);
|
||||
|
||||
new SpiderPoison(getBoss(), item);
|
||||
|
||||
@ -171,7 +179,8 @@ public class SpiderCeilingCling extends BossAbility<SpiderCreature, Pig>
|
||||
}
|
||||
}
|
||||
|
||||
if (_tick > 30 * 20 || _startedHealth - getBoss().getHealth() > 150)
|
||||
if (getBoss().getEvent().getCreatures().size() <= 3
|
||||
&& (_tick > 30 * 20 || _startedHealth - getBoss().getHealth() > 150))
|
||||
{
|
||||
_isClinging = false;
|
||||
_clingTo = null;
|
||||
@ -181,7 +190,7 @@ public class SpiderCeilingCling extends BossAbility<SpiderCreature, Pig>
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (Location loc : UtilShapes.getLinesDistancedPoints(getLocation(), _clingTo, 0.1))
|
||||
for (Location loc : UtilShapes.getLinesDistancedPoints(getLocation(), _clingTo, 0.3))
|
||||
{
|
||||
if (i++ % 3 == _tick % 3)
|
||||
{
|
||||
@ -190,10 +199,37 @@ public class SpiderCeilingCling extends BossAbility<SpiderCreature, Pig>
|
||||
}
|
||||
}
|
||||
|
||||
getEntity().setVelocity(UtilAlg.getTrajectory(getLocation(), _clingTo).multiply(0.4));
|
||||
if (_eggsToLay > 0 && _tick % 3 == 0)
|
||||
{
|
||||
Vector vec = new Vector(UtilMath.rr(1, true), UtilMath.rr(0.5, false), UtilMath.rr(1, true));
|
||||
UtilEnt.CreatureLook(getEntity(), getLocation().add(vec));
|
||||
|
||||
shootEgg(vec);
|
||||
|
||||
_eggsToLay--;
|
||||
}
|
||||
else
|
||||
{
|
||||
getEntity().setVelocity(UtilAlg.getTrajectory(getLocation(), _clingTo).multiply(0.4));
|
||||
}
|
||||
}
|
||||
|
||||
_tick++;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (!event.GetDamageeEntity().equals(getEntity()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.GetCause() != DamageCause.FALL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.SetCancelled("Cancelled");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,221 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
import net.minecraft.server.v1_7_R4.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_7_R4.Vec3D;
|
||||
|
||||
public abstract class SpiderEggAbility extends BossAbility<SpiderCreature, Pig>
|
||||
{
|
||||
private HashMap<Block, Long> _eggs = new HashMap<Block, Long>();
|
||||
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
||||
|
||||
public SpiderEggAbility(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
||||
Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
if (!_eggs.containsKey(block))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_eggs.remove(block);
|
||||
|
||||
block.setType(Material.AIR);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.DIG_SNOW, 2.5F, 0F);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BURP, 2.5F, 1.5F);
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.SNOW_BLOCK, 0),
|
||||
block.getLocation().add(0.5, 0.4, 0.5), 0.4F, 0.4F, 0.4F, 0, 40, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DRAGON_EGG, 0),
|
||||
block.getLocation().add(0.5, 0.6, 0.5), 0.6F, 0.5F, 0.6F, 0, 80, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
}
|
||||
|
||||
public boolean hasEggsFinished()
|
||||
{
|
||||
return _fallingBlocks.isEmpty() && _eggs.isEmpty();
|
||||
}
|
||||
|
||||
public void setEggsFinished()
|
||||
{
|
||||
for (FallingBlock block : _fallingBlocks)
|
||||
{
|
||||
block.remove();
|
||||
}
|
||||
|
||||
for (Block b : _eggs.keySet())
|
||||
{
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
protected void shootEgg(Vector vector)
|
||||
{
|
||||
FallingBlock block = getLocation().getWorld().spawnFallingBlock(getLocation(), Material.DRAGON_EGG, (byte) 0);
|
||||
block.setDropItem(false);
|
||||
block.setVelocity(vector);
|
||||
|
||||
_fallingBlocks.add(block);
|
||||
|
||||
getLocation().getWorld().playSound(getLocation(), Sound.SHEEP_SHEAR, 2.5F, 0F);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEggTeleport(BlockFromToEvent event)
|
||||
{
|
||||
if (!_eggs.containsKey(event.getBlock()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEggyUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<Entry<Block, Long>> itel = _eggs.entrySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Entry<Block, Long> entry = itel.next();
|
||||
|
||||
if (entry.getValue() < System.currentTimeMillis())
|
||||
{
|
||||
itel.remove();
|
||||
entry.getKey().setType(Material.AIR);
|
||||
|
||||
entry.getKey().getWorld()
|
||||
.playEffect(entry.getKey().getLocation(), Effect.STEP_SOUND, Material.DRAGON_EGG.getId());
|
||||
|
||||
((SpiderBoss) getBoss().getEvent()).spawnMinion(entry.getKey().getLocation().add(0.5, 0.1, 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<FallingBlock> fallingIterator = _fallingBlocks.iterator();
|
||||
|
||||
while (fallingIterator.hasNext())
|
||||
{
|
||||
FallingBlock cur = fallingIterator.next();
|
||||
|
||||
if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
fallingIterator.remove();
|
||||
|
||||
Block block = cur.getLocation().getBlock();
|
||||
|
||||
if (UtilBlock.airFoliage(block) || block.getType() == Material.DRAGON_EGG)
|
||||
{
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
}
|
||||
|
||||
// Expire
|
||||
if (cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
|
||||
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ
|
||||
+ nmsEntity.motZ);
|
||||
|
||||
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
|
||||
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ);
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
|
||||
}
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d);
|
||||
|
||||
if (!UtilBlock.airFoliage(block) && !block.isLiquid())
|
||||
{
|
||||
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
|
||||
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
|
||||
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
|
||||
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ
|
||||
* nmsEntity.motZ);
|
||||
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
|
||||
|
||||
if (UtilBlock.airFoliage(block) || block.getType() == Material.DRAGON_EGG)
|
||||
{
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
}
|
||||
|
||||
fallingIterator.remove();
|
||||
cur.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation()
|
||||
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
|
||||
public class SpiderEggScatter extends SpiderEggAbility
|
||||
{
|
||||
private int _eggsToSpray = 25;
|
||||
private float _yaw;
|
||||
private float _addYaw;
|
||||
|
||||
public SpiderEggScatter(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
|
||||
_eggsToSpray = 6 + UtilMath.r(5);
|
||||
|
||||
_addYaw = 360F / _eggsToSpray;
|
||||
}
|
||||
|
||||
public int getCooldown()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return inProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return _eggsToSpray > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _eggsToSpray <= 0 && hasEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
setEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_eggsToSpray > 0)
|
||||
{
|
||||
_eggsToSpray--;
|
||||
|
||||
UtilEnt.CreatureLook(getEntity(), 0, _yaw);
|
||||
|
||||
_yaw += _addYaw;
|
||||
|
||||
Vector vec = getEntity().getLocation().getDirection();
|
||||
|
||||
vec.setY(0).normalize().setY(0.4 + (UtilMath.rr(0.4, false)));
|
||||
|
||||
shootEgg(vec);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,49 +1,14 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
import net.minecraft.server.v1_7_R4.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_7_R4.Vec3D;
|
||||
|
||||
public class SpiderEggplosm extends BossAbility<SpiderCreature, Pig>
|
||||
public class SpiderEggplosm extends SpiderEggAbility
|
||||
{
|
||||
private int _eggsToSpray = 25;
|
||||
private HashMap<Block, Long> _eggs = new HashMap<Block, Long>();
|
||||
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
||||
private int _tick;
|
||||
private float _yaw;
|
||||
private float _addYaw;
|
||||
|
||||
@ -51,14 +16,14 @@ public class SpiderEggplosm extends BossAbility<SpiderCreature, Pig>
|
||||
{
|
||||
super(creature);
|
||||
|
||||
_eggsToSpray = 5 + (int) Math.ceil(30 * (1 - creature.getHealthPercent()));
|
||||
_eggsToSpray = 20 + (int) Math.ceil(15 * (1 - creature.getHealthPercent()));
|
||||
|
||||
_addYaw = 360F / _eggsToSpray;
|
||||
}
|
||||
|
||||
public int getCooldown()
|
||||
{
|
||||
return 30;
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,36 +32,6 @@ public class SpiderEggplosm extends BossAbility<SpiderCreature, Pig>
|
||||
return inProgress();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
||||
Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
if (!_eggs.containsKey(block))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_eggs.remove(block);
|
||||
|
||||
block.setType(Material.AIR);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.DIG_SNOW, 2.5F, 0F);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BURP, 2.5F, 1.5F);
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.SNOW_BLOCK, 0),
|
||||
block.getLocation().add(0.5, 0.4, 0.5), 0.4F, 0.4F, 0.4F, 0, 40, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DRAGON_EGG, 0),
|
||||
block.getLocation().add(0.5, 0.6, 0.5), 0.6F, 0.5F, 0.6F, 0, 80, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
@ -106,27 +41,19 @@ public class SpiderEggplosm extends BossAbility<SpiderCreature, Pig>
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _eggsToSpray <= 0 && _fallingBlocks.isEmpty() && _eggs.isEmpty();
|
||||
return _eggsToSpray <= 0 && hasEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
for (FallingBlock block : _fallingBlocks)
|
||||
{
|
||||
block.remove();
|
||||
}
|
||||
|
||||
for (Block b : _eggs.keySet())
|
||||
{
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
setEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_eggsToSpray > 0 && _tick % 10 == 0)
|
||||
if (_eggsToSpray > 0)
|
||||
{
|
||||
_eggsToSpray--;
|
||||
|
||||
@ -138,131 +65,8 @@ public class SpiderEggplosm extends BossAbility<SpiderCreature, Pig>
|
||||
|
||||
vec.setY(0).normalize().setY(0.4 + (UtilMath.rr(0.4, false)));
|
||||
|
||||
FallingBlock block = getLocation().getWorld().spawnFallingBlock(getLocation(), Material.DRAGON_EGG, (byte) 0);
|
||||
block.setDropItem(false);
|
||||
block.setVelocity(vec);
|
||||
|
||||
_fallingBlocks.add(block);
|
||||
|
||||
getLocation().getWorld().playSound(getLocation(), Sound.SHEEP_SHEAR, 2.5F, 0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
Iterator<Entry<Block, Long>> itel = _eggs.entrySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Entry<Block, Long> entry = itel.next();
|
||||
|
||||
if (entry.getValue() < System.currentTimeMillis())
|
||||
{
|
||||
itel.remove();
|
||||
entry.getKey().setType(Material.AIR);
|
||||
|
||||
entry.getKey().getWorld().playEffect(entry.getKey().getLocation(), Effect.STEP_SOUND,
|
||||
Material.DRAGON_EGG.getId());
|
||||
|
||||
((SpiderBoss) getBoss().getEvent()).spawnMinion(entry.getKey().getLocation().add(0.5, 0.1, 0.5));
|
||||
}
|
||||
}
|
||||
shootEgg(vec);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEggTeleport(BlockFromToEvent event)
|
||||
{
|
||||
if (!_eggs.containsKey(event.getBlock()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<FallingBlock> fallingIterator = _fallingBlocks.iterator();
|
||||
|
||||
while (fallingIterator.hasNext())
|
||||
{
|
||||
FallingBlock cur = fallingIterator.next();
|
||||
|
||||
if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
fallingIterator.remove();
|
||||
|
||||
Block block = cur.getLocation().getBlock();
|
||||
|
||||
if (UtilBlock.airFoliage(block) || block.getType() == Material.DRAGON_EGG)
|
||||
{
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
}
|
||||
|
||||
// Expire
|
||||
if (cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
|
||||
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
|
||||
nmsEntity.locZ + nmsEntity.motZ);
|
||||
|
||||
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
|
||||
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ);
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
|
||||
}
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d);
|
||||
|
||||
if (!UtilBlock.airFoliage(block) && !block.isLiquid())
|
||||
{
|
||||
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
|
||||
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
|
||||
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
|
||||
float f2 = MathHelper.sqrt(
|
||||
nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
|
||||
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
|
||||
|
||||
if (UtilBlock.airFoliage(block) || block.getType() == Material.DRAGON_EGG)
|
||||
{
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
}
|
||||
|
||||
fallingIterator.remove();
|
||||
cur.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
|
||||
cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL,
|
||||
UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,26 +6,24 @@ import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.projectile.IThrown;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
|
||||
public class SpiderPoison implements IThrown
|
||||
{
|
||||
private SpiderCreature _boss;
|
||||
private EventCreature _boss;
|
||||
|
||||
public SpiderPoison(SpiderCreature boss, Item item)
|
||||
public SpiderPoison(EventCreature boss, Item item)
|
||||
{
|
||||
_boss = boss;
|
||||
|
||||
((SpiderBoss) boss.getEvent()).getProjectileManager().AddThrow(item, boss.getEntity(), this, -1, true, true, true, false,
|
||||
2f);
|
||||
boss.getEvent().getProjectileManager().AddThrow(item, boss.getEntity(), this, -1, true, true, true, false, 2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,10 +31,12 @@ public class SpiderPoison implements IThrown
|
||||
{
|
||||
if (target instanceof Player)
|
||||
{
|
||||
_boss.getEvent().getCondition().Factory().Poison("Spider Poison", target, _boss.getEntity(), 60, 1, false, true,
|
||||
false);
|
||||
_boss.getEvent().getDamageManager().NewDamageEvent(target, _boss.getEntity(), null, DamageCause.PROJECTILE, 2, true,
|
||||
false, false, "Spider Poison", "Spider Poison");
|
||||
_boss.getEvent().getCondition().Factory()
|
||||
.Poison("Spider Poison", target, _boss.getEntity(), 60, 1, false, true, false);
|
||||
_boss.getEvent()
|
||||
.getDamageManager()
|
||||
.NewDamageEvent(target, _boss.getEntity(), null, DamageCause.PROJECTILE, 2, true, false, false,
|
||||
"Spider Poison", "Spider Poison");
|
||||
}
|
||||
|
||||
burst(data);
|
||||
|
@ -0,0 +1,116 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
|
||||
public class SpiderPoisonBarrage extends BossAbility<SpiderCreature, Pig>
|
||||
{
|
||||
private int _poisonAmount = UtilMath.r(10) + 20;
|
||||
private int _tick;
|
||||
private float _yawToFace;
|
||||
|
||||
public SpiderPoisonBarrage(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return _poisonAmount > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return !canMove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _poisonAmount <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getTarget()
|
||||
{
|
||||
return getTarget(12, 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_tick == 0)
|
||||
{
|
||||
Player target = getTarget();
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
UtilEnt.CreatureLook(getEntity(), target);
|
||||
}
|
||||
}
|
||||
|
||||
if (_tick % 20 == 0)
|
||||
{
|
||||
Player target = getTarget();
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
Vector vec = UtilAlg.getTrajectory(getEntity(), target);
|
||||
|
||||
_yawToFace = UtilAlg.GetYaw(vec);
|
||||
}
|
||||
}
|
||||
|
||||
float currentYaw = getLocation().getYaw();
|
||||
|
||||
if ((int) currentYaw != (int) _yawToFace)
|
||||
{
|
||||
float first = ((_yawToFace + 720) - currentYaw) % 360;
|
||||
float second = ((currentYaw + 720) - _yawToFace) % 360;
|
||||
|
||||
float diff = Math.max(-3, Math.min(3, first > second ? first : -second));
|
||||
|
||||
UtilEnt.CreatureLook(getEntity(), 0, currentYaw + diff);
|
||||
}
|
||||
|
||||
if (_tick % 3 == 0)
|
||||
{
|
||||
Vector vec = getLocation().getDirection();
|
||||
vec.setY(0).normalize().multiply(1 - UtilMath.rr(0.2, true));
|
||||
vec.setY(0.5 + UtilMath.rr(0.3, false));
|
||||
|
||||
Item item = getLocation().getWorld().dropItem(getLocation(), new ItemStack(Material.SLIME_BALL));
|
||||
|
||||
item.setVelocity(vec);
|
||||
|
||||
new SpiderPoison(getBoss(), item);
|
||||
getLocation().getWorld().playSound(getLocation(), Sound.CREEPER_HISS, 2, 0F);
|
||||
}
|
||||
|
||||
_tick++;
|
||||
}
|
||||
}
|
@ -0,0 +1,179 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
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.event.EventHandler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
|
||||
public class SpiderWebBarrage extends BossAbility
|
||||
{
|
||||
|
||||
private double _strength = 2;
|
||||
private int _canShoot;
|
||||
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
||||
private HashMap<Block, Long> _expires = new HashMap<Block, Long>();
|
||||
private int _tick;
|
||||
|
||||
public SpiderWebBarrage(EventCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
|
||||
_canShoot = (int) (10 + ((1 - creature.getHealthPercent()) * 30));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return _canShoot > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _canShoot <= 0 && _fallingBlocks.isEmpty() && _expires.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
for (Block block : _expires.keySet())
|
||||
{
|
||||
if (block.getType() != Material.WEB)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
|
||||
for (FallingBlock block : _fallingBlocks)
|
||||
{
|
||||
block.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public Player getTarget()
|
||||
{
|
||||
return getTarget(10, 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_tick == 0)
|
||||
{
|
||||
Player target = getTarget();
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
UtilEnt.CreatureLook(getEntity(), target);
|
||||
}
|
||||
}
|
||||
|
||||
if (_canShoot > 0 && _tick % 2 == 0)
|
||||
{
|
||||
_canShoot--;
|
||||
|
||||
Vector vec = getLocation().getDirection().setY(0).normalize();
|
||||
|
||||
vec.add(new Vector(UtilMath.rr(0.2, true), 0, UtilMath.rr(0.2, true)));
|
||||
|
||||
vec.setY(0.6).multiply(_strength);
|
||||
|
||||
_strength -= 0.03;
|
||||
|
||||
FallingBlock block = getLocation().getWorld().spawnFallingBlock(getLocation(), Material.WEB, (byte) 0);
|
||||
block.setDropItem(false);
|
||||
|
||||
_fallingBlocks.add(block);
|
||||
|
||||
block.setVelocity(vec);
|
||||
getLocation().getWorld().playSound(getLocation(), Sound.SHEEP_SHEAR, 2, 2F);
|
||||
}
|
||||
|
||||
Iterator<Entry<Block, Long>> itel = _expires.entrySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Entry<Block, Long> entry = itel.next();
|
||||
|
||||
if (entry.getValue() < System.currentTimeMillis())
|
||||
{
|
||||
itel.remove();
|
||||
entry.getKey().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
_tick++;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<FallingBlock> fallingIterator = _fallingBlocks.iterator();
|
||||
|
||||
while (fallingIterator.hasNext())
|
||||
{
|
||||
FallingBlock cur = fallingIterator.next();
|
||||
|
||||
if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
fallingIterator.remove();
|
||||
|
||||
Block block = cur.getLocation().getBlock();
|
||||
|
||||
if (UtilBlock.airFoliage(block) || block.getType() == Material.WEB)
|
||||
{
|
||||
block.setType(Material.WEB);
|
||||
_expires.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
}
|
||||
|
||||
// Expire
|
||||
if (cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
|
||||
/**
|
||||
* A attack where webs appear all around the spider in a kinda maze formation, making it hard to approach it.
|
||||
*/
|
||||
public class SpiderWebStomp extends BossAbility
|
||||
{
|
||||
private int _tick;
|
||||
|
||||
public SpiderWebStomp(EventCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _tick > 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
}
|
||||
|
||||
public Player getTarget()
|
||||
{
|
||||
if (!UtilEnt.isGrounded(getEntity()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return super.getTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_tick++ == 0)
|
||||
{
|
||||
int amount = UtilMath.r(15) + 15;
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
Block block = getLocation().getBlock().getRelative((int) UtilMath.rr(15, true), 0, (int) UtilMath.rr(15, true));
|
||||
|
||||
if (block.getType() != Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
block.setType(Material.WEB);
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user