Make bosses clean up after themselves and be more error-resistant
This commit is contained in:
parent
14f140143b
commit
1ab5c8229b
@ -1,6 +1,7 @@
|
||||
package mineplex.minecraft.game.core.boss.broodmother;
|
||||
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
@ -21,8 +22,7 @@ public class SpiderBoss extends WorldEvent
|
||||
{
|
||||
public SpiderBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location cornerLocation)
|
||||
{
|
||||
super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation,
|
||||
"schematic/Golem.schematic");
|
||||
super(DisguiseManager.INSTANCE, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -30,7 +30,7 @@ public class SpiderBoss extends WorldEvent
|
||||
{
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (!getEventMap().isInMap(block.getLocation()))
|
||||
if (UtilMath.offset2d(event.getBlock().getLocation(), getCenterLocation()) > 40)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -44,22 +44,6 @@ public class SpiderBoss extends WorldEvent
|
||||
event.getBlock().setType(Material.AIR);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onString(ItemSpawnEvent event)
|
||||
{
|
||||
if (!getEventMap().isInMap(event.getLocation()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEntity().getItemStack().getType() != Material.STRING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart()
|
||||
{
|
||||
|
@ -8,24 +8,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
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.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
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;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderCocoon;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggScatter;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggplosm;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderPoisonBarrage;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebBarrage;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebStomp;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -40,6 +22,24 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
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.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
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;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderCeilingCling;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggScatter;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderEggplosm;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderPoisonBarrage;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebBarrage;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.attacks.SpiderWebStomp;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class SpiderCreature extends EventCreature<Spider>
|
||||
{
|
||||
private ArrayList<BossAbility> _currentAbilities = new ArrayList<BossAbility>();
|
||||
@ -50,7 +50,6 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
private Vector _afkWalk = new Vector();
|
||||
private HashMap<Class, Long> _cooldowns = new HashMap<Class, Long>();
|
||||
private long _lastAttack;
|
||||
public List<Block> Webs = Lists.newArrayList();
|
||||
|
||||
public SpiderCreature(SpiderBoss boss, Location location, double maxHealth)
|
||||
{
|
||||
@ -68,10 +67,10 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
@Override
|
||||
public void dieCustom()
|
||||
{
|
||||
for (Block block : Webs)
|
||||
/*for (Block block : Webs)
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -131,10 +130,10 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
}
|
||||
}
|
||||
|
||||
{ // Cocoon
|
||||
{ // Ceiling Cling
|
||||
if (getEvent().getCreatures().size() < 5)
|
||||
{
|
||||
weight.put(SpiderCocoon.class, 2);
|
||||
weight.put(SpiderCeilingCling.class, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,7 +241,14 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
ability.tick();
|
||||
try
|
||||
{
|
||||
ability.tick();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!ability.canMove())
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ public class SpiderCeilingCling extends SpiderEggAbility
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Location loc = getBoss().getSpawnLocation().clone().add(0, -27, 0).add(UtilMath.rr(5, true), 12, UtilMath.rr(5, true));
|
||||
Location loc = getLocation().add(UtilMath.rr(10, true), 12, UtilMath.rr(10, true));
|
||||
|
||||
if (UtilAlg.HasSight(getLocation(), loc))
|
||||
{
|
||||
@ -215,4 +215,4 @@ public class SpiderCeilingCling extends SpiderEggAbility
|
||||
|
||||
event.SetCancelled("Cancelled");
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
@ -127,8 +128,8 @@ public class SpiderWebBarrage extends BossAbility<SpiderCreature, Spider>
|
||||
|
||||
if (UtilBlock.airFoliage(block) || block.getType() == Material.WEB)
|
||||
{
|
||||
block.setType(Material.WEB);
|
||||
getBoss().Webs.add(block);
|
||||
Bukkit.broadcastMessage("Setting Web");
|
||||
getBoss().getEvent().setBlock(block, Material.WEB);
|
||||
}
|
||||
|
||||
// Expire
|
||||
|
@ -5,6 +5,7 @@ import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -78,10 +79,10 @@ public class SpiderWebStomp extends BossAbility<SpiderCreature, Spider>
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
block.setType(Material.WEB);
|
||||
|
||||
Bukkit.broadcastMessage("Setting Web");
|
||||
getBoss().getEvent().setBlock(block, Material.WEB);
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB);
|
||||
getBoss().Webs.add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +409,14 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
ability.tick();
|
||||
try
|
||||
{
|
||||
ability.tick();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(); //Keeps the boss from getting stuck if one of the moves throws an error in progression
|
||||
}
|
||||
|
||||
if (!ability.canMove())
|
||||
{
|
||||
@ -618,25 +625,4 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
endAbility();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (!(event.GetDamageeEntity() instanceof Player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.GetCause() != DamageCause.FALL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getEvent().getEventMap().isInMap(event.GetDamageeEntity().getLocation()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.AddMod("Fall negation", 0.5);
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,12 @@ package mineplex.minecraft.game.core.boss.ironwizard.abilities;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
public class GroundSpike
|
||||
{
|
||||
@ -29,13 +31,17 @@ public class GroundSpike
|
||||
_finished = false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void raise()
|
||||
{
|
||||
if ((_height + 1) < _max)
|
||||
{
|
||||
_lastTick = System.currentTimeMillis();
|
||||
Block b = _initial.getRelative(0, _height, 0);
|
||||
b.setType(_type);
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
player.sendBlockChange(b.getLocation(), _type, (byte)0);
|
||||
}
|
||||
_blocks.add(b);
|
||||
_height++;
|
||||
}
|
||||
@ -49,13 +55,17 @@ public class GroundSpike
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void lower()
|
||||
{
|
||||
_height = Math.min(_blocks.size() - 1, _height);
|
||||
if ((_height - 1) >= 0)
|
||||
{
|
||||
_lastTick = System.currentTimeMillis();
|
||||
_blocks.get(_height).setType(Material.AIR);
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
player.sendBlockChange(_blocks.get(_height).getLocation(), Material.AIR, (byte)0);
|
||||
}
|
||||
_blocks.remove(_height);
|
||||
_height--;
|
||||
}
|
||||
@ -73,12 +83,16 @@ public class GroundSpike
|
||||
return _finished;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void finish()
|
||||
{
|
||||
_finished = true;
|
||||
for (Block block : _blocks)
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
player.sendBlockChange(block.getLocation(), Material.AIR, (byte)0);
|
||||
}
|
||||
}
|
||||
_blocks.clear();
|
||||
}
|
||||
|
@ -315,7 +315,14 @@ public class SkeletonCreature extends EventCreature<Skeleton>
|
||||
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
ability.tick();
|
||||
try
|
||||
{
|
||||
ability.tick();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
boolean canMove = true;
|
||||
|
Loading…
Reference in New Issue
Block a user