Elite Zombies break blocks if trapped.

This commit is contained in:
sigonasr2 2016-08-25 05:55:30 -05:00
parent 4df89c8cdb
commit 66cddc98a8
5 changed files with 125 additions and 35 deletions

Binary file not shown.

View File

@ -1,5 +1,6 @@
package sig.plugin.TwosideKeeper; package sig.plugin.TwosideKeeper;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -78,7 +79,53 @@ public class ChargeZombie {
} }
} }
public boolean ChanceToBreak(Block b) { public static void BreakBlocksAroundArea(int radius, Location l) {
int outerradius = radius+1;
for (int x=-radius-1;x<radius+2;x++) {
for (int y=-radius;y<radius+3;y++) {
for (int z=-radius-1;z<radius+2;z++) {
if (Math.abs(x)<outerradius &&
Math.abs(y)<outerradius+1 &&
Math.abs(z)<outerradius &&
aPlugin.API.isDestroyable(l.add(x,y,z).getBlock()) ||
l.add(x,y,z).getBlock().getType()==Material.OBSIDIAN) {
boolean brokeliquid = false;
//Break it.
if (ChanceToBreak(l.add(x,y,z).getBlock())) {
if (l.add(x,y,z).getBlock().getType()==Material.WATER ||
l.add(x,y,z).getBlock().getType()==Material.STATIONARY_WATER ||
l.add(x,y,z).getBlock().getType()==Material.LAVA ||
l.add(x,y,z).getBlock().getType()==Material.STATIONARY_LAVA) {
brokeliquid=true;
if (l.add(x,y,z).getBlock().getType()==Material.STATIONARY_LAVA) {
l.add(x,y,z).getBlock().setType(Material.OBSIDIAN);
l.getWorld().playSound(l.add(x,y,z),Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f);
}
}
if (!brokeliquid) {
l.getWorld().playSound(l.add(x,y,z),Sound.BLOCK_STONE_BREAK, 1.0f, 1.0f);
}
l.add(x,y,z).getBlock().breakNaturally();
aPlugin.API.sendBlockBreakPacket(l.add(x,y,z).getBlock(), -1);
} else {
aPlugin.API.sendBlockBreakPacket(l.add(x,y,z).getBlock(), (int)(Math.random()*6)+3);
}
} else
if (Math.abs(x)>=outerradius ||
Math.abs(y)>=outerradius+1 ||
Math.abs(z)>=outerradius) {
//This block can be destroyed if it is a liquid.
if (l.add(x,y,z).getBlock().isLiquid()) {
l.add(x,y,z).getBlock().breakNaturally();
aPlugin.API.sendBlockBreakPacket(l.add(x,y,z).getBlock(), -1);
}
}
}
}
}
}
public static boolean ChanceToBreak(Block b) {
int blocktoughness = 0; int blocktoughness = 0;
switch (b.getType()) { switch (b.getType()) {
case OBSIDIAN:{ case OBSIDIAN:{

View File

@ -417,9 +417,33 @@ public class CustomDamage {
subtractWeaponDurability(p,weapon); subtractWeaponDurability(p,weapon);
aPlugin.API.showDamage(target, GetHeartAmount(damage)); aPlugin.API.showDamage(target, GetHeartAmount(damage));
} }
if (target instanceof Monster) {
if (reason.equalsIgnoreCase("SUFFOCATION")) {
triggerEliteBreakEvent(target);
}
}
return damage; return damage;
} }
private static void triggerEliteBreakEvent(LivingEntity target) {
if (target instanceof Monster &&
TwosideKeeper.monsterdata.containsKey(target.getUniqueId())) {
MonsterStructure ms = MonsterStructure.getMonsterStructure((Monster)target);
if (ms.getElite()) {
boolean exists=false;
for (int i=0;i<TwosideKeeper.elitemonsters.size();i++) {
if (TwosideKeeper.elitemonsters.get(i).m.equals(target)) {
exists=true;
TwosideKeeper.elitemonsters.get(i).BreakBlocksAroundArea();
}
}
if (!exists) {
TwosideKeeper.elitemonsters.add(new EliteMonster((Monster)target));
}
}
}
}
private static int GetHeartAmount(double dmg) { private static int GetHeartAmount(double dmg) {
int heartcount = 1; int heartcount = 1;
double dmgamountcopy = dmg; double dmgamountcopy = dmg;

View File

@ -284,6 +284,10 @@ public class EliteMonster {
m.setRemainingAir(m.getMaximumAir()); m.setRemainingAir(m.getMaximumAir());
} }
public void BreakBlocksAroundArea() {
ChargeZombie.BreakBlocksAroundArea(2, m.getLocation());
}
private void reapplyGlow() { private void reapplyGlow() {
if (last_applyglow_time+GLOW_TIME<=TwosideKeeper.getServerTickTime()) { if (last_applyglow_time+GLOW_TIME<=TwosideKeeper.getServerTickTime()) {
GlowAPI.Color col = GlowAPI.Color.DARK_PURPLE; GlowAPI.Color col = GlowAPI.Color.DARK_PURPLE;

View File

@ -2119,6 +2119,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
},1); },1);
} }
if ((ev.getRightClicked() instanceof Monster) && (ev.getHand()==EquipmentSlot.OFF_HAND) &&
GenericFunctions.isArtifactEquip(ev.getPlayer().getEquipment().getItemInMainHand())) {
boolean bursted=false;
bursted = performDeathMark(ev.getPlayer(), bursted);
if (bursted) {
//Cancel this then, because we decided to burst our stacks instead.
ev.setCancelled(true);
}
}
/*if (ev.getRightClicked() instanceof Monster) { /*if (ev.getRightClicked() instanceof Monster) {
TwosideKeeperAPI.DealDamageToEntity(TwosideKeeperAPI.getFinalDamage(500.0, ev.getPlayer(), (Monster)ev.getRightClicked(), true, "ROFL"), (Monster)ev.getRightClicked(), ev.getPlayer()); TwosideKeeperAPI.DealDamageToEntity(TwosideKeeperAPI.getFinalDamage(500.0, ev.getPlayer(), (Monster)ev.getRightClicked(), true, "ROFL"), (Monster)ev.getRightClicked(), ev.getPlayer());
}*/ }*/
@ -2129,7 +2139,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public void onPlayerInteract(PlayerInteractEvent ev) { public void onPlayerInteract(PlayerInteractEvent ev) {
if (ev.isCancelled() && ev.getAction() == Action.RIGHT_CLICK_BLOCK) { if (ev.isCancelled() && ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
return; return;
} else { } else {
Block b = ev.getClickedBlock(); Block b = ev.getClickedBlock();
log("Interaction type: "+ev.getAction().toString(),5); log("Interaction type: "+ev.getAction().toString(),5);
@ -2283,38 +2293,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//Check for a Scythe right click here. //Check for a Scythe right click here.
if ((ev.getAction()==Action.RIGHT_CLICK_AIR || ev.getAction()==Action.RIGHT_CLICK_BLOCK) && if ((ev.getAction()==Action.RIGHT_CLICK_AIR || ev.getAction()==Action.RIGHT_CLICK_BLOCK) &&
GenericFunctions.isArtifactEquip(player.getEquipment().getItemInMainHand())) { GenericFunctions.isArtifactEquip(player.getEquipment().getItemInMainHand())) {
PlayerStructure pd = (PlayerStructure)playerdata.get(player.getUniqueId()); //Make sure it's off cooldown. boolean bursted=false;
if (pd.last_deathmark+DEATHMARK_COOLDOWN<getServerTickTime()) { bursted = performDeathMark(player, bursted);
boolean bursted=false; if (bursted) {
if (ArtifactAbility.getEnchantmentLevel(ArtifactAbility.DEATHMARK, player.getEquipment().getItemInMainHand())>0) { //Cancel this then, because we decided to burst our stacks instead.
double dmg = GenericFunctions.getAbilityValue(ArtifactAbility.DEATHMARK, player.getEquipment().getItemInMainHand()); ev.setCancelled(true);
//Look for nearby mobs up to 10 blocks away.
List<Entity> nearby = player.getNearbyEntities(10, 10, 10);
for (int i=0;i<nearby.size();i++) {
if (nearby.get(i) instanceof Monster) {
Monster m = (Monster)nearby.get(i);
if (m.hasPotionEffect(PotionEffectType.UNLUCK) && !m.isDead()) {
//This has stacks, burst!
bursted=true;
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), 240);
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), 240);
pd.last_deathmark = getServerTickTime();
int stackamt = GenericFunctions.GetDeathMarkAmt(m);
m.setLastDamage(0);
m.setNoDamageTicks(0);
m.setMaximumNoDamageTicks(0);
//GenericFunctions.DealDamageToMob(stackamt*dmg, m, player, null, "Death Mark");
CustomDamage.ApplyDamage(stackamt*dmg, player, m, null, "Death Mark", CustomDamage.TRUEDMG);
m.removePotionEffect(PotionEffectType.UNLUCK);
player.playSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f);
}
}
}
}
if (bursted) {
//Cancel this then, because we decided to burst our stacks instead.
ev.setCancelled(true);
}
} }
} }
@ -2866,6 +2849,38 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
public boolean performDeathMark(final Player player, boolean bursted) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(player); //Make sure it's off cooldown.
if (pd.last_deathmark+DEATHMARK_COOLDOWN<getServerTickTime()) {
if (ArtifactAbility.getEnchantmentLevel(ArtifactAbility.DEATHMARK, player.getEquipment().getItemInMainHand())>0) {
double dmg = GenericFunctions.getAbilityValue(ArtifactAbility.DEATHMARK, player.getEquipment().getItemInMainHand());
//Look for nearby mobs up to 10 blocks away.
List<Entity> nearby = player.getNearbyEntities(10, 10, 10);
for (int i=0;i<nearby.size();i++) {
if (nearby.get(i) instanceof Monster) {
Monster m = (Monster)nearby.get(i);
if (m.hasPotionEffect(PotionEffectType.UNLUCK) && !m.isDead()) {
//This has stacks, burst!
bursted=true;
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), 240);
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), 240);
pd.last_deathmark = getServerTickTime();
int stackamt = GenericFunctions.GetDeathMarkAmt(m);
m.setLastDamage(0);
m.setNoDamageTicks(0);
m.setMaximumNoDamageTicks(0);
//GenericFunctions.DealDamageToMob(stackamt*dmg, m, player, null, "Death Mark");
CustomDamage.ApplyDamage(stackamt*dmg, player, m, null, "Death Mark", CustomDamage.TRUEDMG);
m.removePotionEffect(PotionEffectType.UNLUCK);
player.playSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f);
}
}
}
}
}
return bursted;
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent ev) { public void onBlockPlace(BlockPlaceEvent ev) {