Starting work on Impact subskill for Axes

This commit is contained in:
nossr50 2012-02-29 11:56:15 -08:00
parent d56fe82bfd
commit 652a27eb38
2 changed files with 53 additions and 0 deletions

View File

@ -82,6 +82,10 @@ public class Combat
Axes.axeCriticalCheck(attacker, event, pluginx); //Critical hit
//Impact
if(event.getEntity() instanceof LivingEntity)
Axes.impact(attacker, (LivingEntity)event.getEntity());
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode())
Axes.applyAoeDamage(attacker, event, pluginx);

View File

@ -17,11 +17,13 @@
package com.gmail.nossr50.skills;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.Combat;
@ -80,6 +82,53 @@ public class Axes {
}
}
public static void impact(Player attacker, LivingEntity target)
{
boolean didImpact = false;
if(target instanceof Player)
{
Player targetPlayer = (Player) target;
int emptySlots = 0;
for(ItemStack x : targetPlayer.getInventory().getArmorContents())
{
System.out.println("[mcMMO] DEBUG: "+x.getType().toString());
if(x.getType() == Material.AIR)
{
emptySlots++;
} else {
x.setDurability((short) (x.getDurability()+30)); //Damage armor piece
}
}
if(emptySlots == 4)
{
targetPlayer.sendMessage("**HIT BY IMPACT**");
didImpact = applyImpact(target);
}
} else {
//Since mobs are technically unarmored this will always trigger
didImpact = applyImpact(target);
}
if(didImpact)
{
attacker.sendMessage("STRUCK WITH GREAT FORCE!");
}
}
public static boolean applyImpact(LivingEntity target)
{
if(Math.random() * 100 > 75)
{
target.teleport(target.getLocation());
target.damage(2);
return true;
}
return false;
}
public static void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx)
{
int targets = 0;