*CLEANUP* - Unarmed.java

This commit is contained in:
GJ 2012-03-17 12:52:48 -04:00
parent 3bb7b05d80
commit 92cc494087
2 changed files with 48 additions and 45 deletions

View File

@ -81,14 +81,14 @@ public class Combat {
startGainXp(attacker, PPa, target, SkillType.AXES, plugin); startGainXp(attacker, PPa, target, SkillType.AXES, plugin);
} }
else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker)) { else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker)) {
Unarmed.unarmedBonus(attacker, event); Unarmed.unarmedBonus(PPa, event);
if (PPa.getBerserkMode()) { if (PPa.getBerserkMode()) {
event.setDamage(damage + (damage / 2)); event.setDamage(damage + (damage / 2));
} }
if (targetType.equals(EntityType.PLAYER)) { if (targetType.equals(EntityType.PLAYER)) {
Unarmed.disarmProcCheck(attacker, (Player) target); Unarmed.disarmProcCheck(PPa, (Player) target);
} }
startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin); startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin);

View File

@ -4,50 +4,53 @@ import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
public class Unarmed { public class Unarmed {
public static void unarmedBonus(Player attacker, EntityDamageByEntityEvent event) /**
{ * Apply bonus to Unarmed damage.
*
* @param PPa Profile of the attacking player
* @param event The event to modify
*/
public static void unarmedBonus(PlayerProfile PPa, EntityDamageByEntityEvent event) {
final int MAX_BONUS = 8;
int bonus = 3; int bonus = 3;
//Add 1 DMG for every 50 skill levels bonus += PPa.getSkillLevel(SkillType.UNARMED) / 50; //Add 1 DMG for every 50 skill levels
bonus += Users.getProfile(attacker).getSkillLevel(SkillType.UNARMED)/50;
if(bonus > 8) if (bonus > MAX_BONUS) {
bonus = 8; bonus = MAX_BONUS;
}
event.setDamage(event.getDamage() + bonus); event.setDamage(event.getDamage() + bonus);
} }
public static void disarmProcCheck(Player attacker, Player defender) /**
{ * Check for disarm.
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.UNARMED); *
if(defender.getItemInHand() != null && defender.getItemInHand().getType() != Material.AIR) * @param PPa Profile of the attacking player
{ * @param defender The defending player
if(skillLevel >= 1000) */
{ public static void disarmProcCheck(PlayerProfile PPa, Player defender) {
if(Math.random() * 3000 <= 1000) final int MAX_BONUS_LEVEL = 1000;
{
int skillLevel = PPa.getSkillLevel(SkillType.UNARMED);
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (defender.getItemInHand().getType().equals(Material.AIR)) {
if (Math.random() * 3000 <= skillCheck) {
ItemStack item = defender.getItemInHand(); ItemStack item = defender.getItemInHand();
defender.sendMessage(mcLocale.getString("Skills.Disarmed")); defender.sendMessage(mcLocale.getString("Skills.Disarmed"));
m.mcDropItem(defender.getLocation(), item); m.mcDropItem(defender.getLocation(), item);
defender.setItemInHand(null); defender.setItemInHand(new ItemStack(Material.AIR));
}
}
else
{
if(Math.random() * 3000 <= skillLevel)
{
ItemStack item = defender.getItemInHand();
defender.sendMessage(mcLocale.getString("Skills.Disarmed"));
m.mcDropItem(defender.getLocation(), item);
defender.setItemInHand(null);
}
} }
} }
} }