Elite Zombies break blocks if trapped.
This commit is contained in:
parent
4df89c8cdb
commit
66cddc98a8
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
package sig.plugin.TwosideKeeper;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
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;
|
||||
switch (b.getType()) {
|
||||
case OBSIDIAN:{
|
||||
|
@ -417,9 +417,33 @@ public class CustomDamage {
|
||||
subtractWeaponDurability(p,weapon);
|
||||
aPlugin.API.showDamage(target, GetHeartAmount(damage));
|
||||
}
|
||||
if (target instanceof Monster) {
|
||||
if (reason.equalsIgnoreCase("SUFFOCATION")) {
|
||||
triggerEliteBreakEvent(target);
|
||||
}
|
||||
}
|
||||
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) {
|
||||
int heartcount = 1;
|
||||
double dmgamountcopy = dmg;
|
||||
|
@ -284,6 +284,10 @@ public class EliteMonster {
|
||||
m.setRemainingAir(m.getMaximumAir());
|
||||
}
|
||||
|
||||
public void BreakBlocksAroundArea() {
|
||||
ChargeZombie.BreakBlocksAroundArea(2, m.getLocation());
|
||||
}
|
||||
|
||||
private void reapplyGlow() {
|
||||
if (last_applyglow_time+GLOW_TIME<=TwosideKeeper.getServerTickTime()) {
|
||||
GlowAPI.Color col = GlowAPI.Color.DARK_PURPLE;
|
||||
|
@ -2119,6 +2119,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
}
|
||||
},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) {
|
||||
TwosideKeeperAPI.DealDamageToEntity(TwosideKeeperAPI.getFinalDamage(500.0, ev.getPlayer(), (Monster)ev.getRightClicked(), true, "ROFL"), (Monster)ev.getRightClicked(), ev.getPlayer());
|
||||
}*/
|
||||
@ -2283,40 +2293,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
//Check for a Scythe right click here.
|
||||
if ((ev.getAction()==Action.RIGHT_CLICK_AIR || ev.getAction()==Action.RIGHT_CLICK_BLOCK) &&
|
||||
GenericFunctions.isArtifactEquip(player.getEquipment().getItemInMainHand())) {
|
||||
PlayerStructure pd = (PlayerStructure)playerdata.get(player.getUniqueId()); //Make sure it's off cooldown.
|
||||
if (pd.last_deathmark+DEATHMARK_COOLDOWN<getServerTickTime()) {
|
||||
boolean bursted=false;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bursted = performDeathMark(player, bursted);
|
||||
if (bursted) {
|
||||
//Cancel this then, because we decided to burst our stacks instead.
|
||||
ev.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check stuff here.
|
||||
if (ev.getAction()==Action.RIGHT_CLICK_AIR ||
|
||||
@ -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)
|
||||
public void onBlockPlace(BlockPlaceEvent ev) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user