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