This commit is contained in:
nossr50 2013-01-15 14:49:55 -08:00
commit 6c67308a1f
14 changed files with 212 additions and 148 deletions

View File

@ -23,6 +23,7 @@ Version 1.3.13-dev
+ Added wooden button to the list of items that shouldn't trigger abilities
+ Added a new feature to fishing. Players will have +10% chance of finding enchanted items when fishing while it's raining
+ Added displaying bonus perks on skill commands
= Impact now works with mobs wearing armor
= Fixed issue with Tree Feller dropping player-placed blocks
= Fixed issue with missing default cases from several switch/case statements
= Fixed issue with Mining using actual skill level rather than max skill level

View File

@ -17,7 +17,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Database;
public class McremoveCommand implements CommandExecutor {
private Database database = mcMMO.getPlayerDatabase();
private final String location;
private final mcMMO plugin;

View File

@ -6,6 +6,7 @@ import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@ -20,14 +21,6 @@ public class AxesCommand extends SkillCommand {
private String skullSplitterLength;
private String skullSplitterLengthEndurance;
private int bonusDamageAxesBonusMax = advancedConfig.getBonusDamageAxesBonusMax();
private int bonusDamageAxesMaxBonusLevel = advancedConfig.getBonusDamageAxesMaxBonusLevel();
private double critMaxChance = advancedConfig.getAxesCriticalChance();
private int critMaxBonusLevel = advancedConfig.getAxesCriticalMaxBonusLevel();
private int greaterImpactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel();
private double greaterImpactBonusDamage = advancedConfig.getGreaterImpactBonusDamage();
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private boolean canSkullSplitter;
private boolean canCritical;
private boolean canBonusDamage;
@ -43,12 +36,12 @@ public class AxesCommand extends SkillCommand {
@Override
protected void dataCalculations() {
float critChanceF;
int skillCheck = Misc.skillCheck((int)skillValue, critMaxBonusLevel);
int skillCheck = Misc.skillCheck((int) skillValue, Axes.criticalHitMaxBonusLevel);
//Armor Impact
impactDamage = String.valueOf(1 + ((double) skillValue / (double) greaterImpactIncreaseLevel));
impactDamage = String.valueOf(1 + ((double) skillValue / (double) Axes.impactIncreaseLevel));
//Skull Splitter
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
int length = 2 + (int) ((double) skillValue / (double) Misc.abilityLengthIncreaseLevel);
skullSplitterLength = String.valueOf(length);
if (Permissions.activationTwelve(player)) {
@ -67,16 +60,16 @@ public class AxesCommand extends SkillCommand {
skullSplitterLengthEndurance = String.valueOf(length);
//Greater Impact
greaterImpactDamage = String.valueOf(greaterImpactBonusDamage);
greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage);
//Critical Strikes
if (skillValue >= critMaxBonusLevel) critChanceF = (float) critMaxChance;
else critChanceF = (float) ((critMaxChance / critMaxBonusLevel) * skillCheck);
if (skillValue >= Axes.criticalHitMaxBonusLevel) critChanceF = (float) Axes.criticalHitMaxChance;
else critChanceF = (float) ((Axes.criticalHitMaxChance / Axes.criticalHitMaxBonusLevel) * skillCheck);
critChance = percent.format(critChanceF / 100D);
if (critChanceF * 1.3333D >= 100D) critChanceLucky = percent.format(1D);
else critChanceLucky = percent.format(critChanceF * 1.3333D / 100D);
//Axe Mastery
if (skillValue >= bonusDamageAxesMaxBonusLevel) bonusDamage = String.valueOf(bonusDamageAxesBonusMax);
else bonusDamage = String.valueOf(skillValue / ((double) bonusDamageAxesMaxBonusLevel / (double) bonusDamageAxesBonusMax));
if (skillValue >= Axes.bonusDamageMaxBonusLevel) bonusDamage = String.valueOf(Axes.bonusDamageMaxBonus);
else bonusDamage = String.valueOf(skillValue / ((double) Axes.bonusDamageMaxBonusLevel / (double) Axes.bonusDamageMaxBonus));
}
@Override

View File

@ -63,6 +63,8 @@ public class AdvancedConfig extends ConfigLoader {
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); }
public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); }
/* EXCAVATION */
//Nothing to configure, everything is already configurable in config.yml

View File

@ -59,4 +59,41 @@ public class AxeManager extends SkillManager {
}
}
/**
* Check for Impact ability.
*
* @param event The event to modify
*/
public void impact(EntityDamageByEntityEvent event) {
if (Misc.isNPC(player) || !Permissions.impact(player)) {
return;
}
ImpactEventHandler eventHandler = new ImpactEventHandler(this, event);
if (eventHandler.livingDefender == null) {
return;
}
if (!Misc.hasArmor(eventHandler.livingDefender)) {
eventHandler.damageArmor();
}
else {
eventHandler.applyGreaterImpact();
}
}
/**
* Check for Skull Splitter ability.
*
* @param event The event to process
*/
public void skullSplitter(EntityDamageByEntityEvent event) {
if (Misc.isNPC(player) || !Permissions.skullSplitter(player)) {
return;
}
SkullSplitterEventHandler eventHandler = new SkullSplitterEventHandler(this, event);
eventHandler.applyAbilityEffects();
}
}

View File

@ -1,18 +1,6 @@
package com.gmail.nossr50.skills.axes;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Axes {
public static int bonusDamageMaxBonus = AdvancedConfig.getInstance().getBonusDamageAxesBonusMax();
@ -23,110 +11,12 @@ public class Axes {
public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getAxesCriticalPVPModifier();
public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getAxesCriticalPVEModifier();
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public static int impactIncreaseLevel = AdvancedConfig.getInstance().getArmorImpactIncreaseLevel();
public static double impactMaxDurabilityDamageModifier = AdvancedConfig.getInstance().getArmorImpactMaxDurabilityDamage() / 100D;
/**
* Check for Impact ability.
*
* @param attacker The attacking player
* @param target The defending entity
* @param event The event to modify
*/
public static void impact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
if (attacker == null)
return;
public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance();
public static double greaterImpactKnockbackMultiplier = AdvancedConfig.getInstance().getGreaterImpactModifier();
public static int greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage();
/*
* TODO: Finish this skill. The idea is you will greatly damage an opponents armor.
* When they are unarmored, you have a proc that will stun them and deal additional damage.
*/
if (target instanceof Player) {
Player targetPlayer = (Player) target;
short durabilityDamage = 1; //Start with 1 durability damage
/* Every 50 Skill Levels you gain 1 durability damage (default values) */
int impactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel();
double impactMaxDamage = advancedConfig.getArmorImpactMaxDurabilityDamage() / 100F;
short maxDurability;
durabilityDamage += (int) ((double) Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / (double) impactIncreaseLevel);
if (!hasArmor(targetPlayer)) {
applyGreaterImpact(attacker, target, event);
}
else {
for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) {
if (Math.random() * 100 > 75) {
int lowerdamage = 0;
for (int i = 0; i <= durabilityDamage; i ++) {
if (armor.containsEnchantment(Enchantment.DURABILITY)) {
int level = armor.getEnchantmentLevel(Enchantment.DURABILITY);
if (Misc.getRandom().nextInt(level + 1) > 0) {
lowerdamage++;
}
}
}
int newDurabilityDamage = durabilityDamage - lowerdamage;
maxDurability = (short) (armor.getType().getMaxDurability() * impactMaxDamage);
if (newDurabilityDamage > maxDurability) newDurabilityDamage = maxDurability;
armor.setDurability((short) (armor.getDurability() + newDurabilityDamage)); //Damage armor piece
}
}
targetPlayer.updateInventory();
}
}
else {
applyGreaterImpact(attacker, target, event); //Since mobs are technically unarmored, this will always trigger
}
}
/**
* Apply Greater Impact ability.
*
* @param attacker The attacking player
* @param target The defending entity
* @param event The event to modify
*/
private static void applyGreaterImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
if (attacker == null)
return;
final double GREATER_IMPACT_CHANCE = advancedConfig.getGreaterImpactChance();
final double GREATER_IMPACT_MULTIPLIER = advancedConfig.getGreaterImpactModifier();
final int GREATER_IMPACT_DAMAGE = advancedConfig.getGreaterImpactBonusDamage();
if (!Permissions.greaterImpact(attacker)) {
return;
}
int randomChance = 100;
if (Permissions.luckyAxes(attacker)) {
randomChance = (int) (randomChance * 0.75);
}
if (Misc.getRandom().nextInt(randomChance) <= GREATER_IMPACT_CHANCE) {
event.setDamage(event.getDamage() + GREATER_IMPACT_DAMAGE);
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER));
attacker.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
}
}
/**
* Check if a player has armor.
*
* @param player Player whose armor to check
* @return true if the player has armor, false otherwise
*/
private static boolean hasArmor(Player player) {
if (player == null)
return false;
PlayerInventory inventory = player.getInventory();
if (inventory.getBoots() != null || inventory.getChestplate() != null || inventory.getHelmet() != null || inventory.getLeggings() != null) {
return true;
}
return false;
}
public static int skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier();
}

View File

@ -0,0 +1,104 @@
package com.gmail.nossr50.skills.axes;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class ImpactEventHandler {
private AxeManager manager;
private Player player;
private EntityDamageByEntityEvent event;
private short durabilityDamage = 1;
private EntityEquipment equipment;
private ItemStack[] armorContents;
protected Entity defender;
protected LivingEntity livingDefender;
public ImpactEventHandler(AxeManager manager, EntityDamageByEntityEvent event) {
this.manager = manager;
this.player = manager.getPlayer();
this.event = event;
this.defender = event.getEntity();
if (defender instanceof LivingEntity) {
this.livingDefender = (LivingEntity) defender;
this.equipment = livingDefender.getEquipment();
this.armorContents = equipment.getArmorContents();
}
}
protected void damageArmor() {
/* Every 50 Skill Levels you gain 1 durability damage (default values) */
durabilityDamage += (short) (manager.getSkillLevel() / Axes.impactIncreaseLevel);
for (ItemStack armor : armorContents) {
if (Misc.getRandom().nextInt(100) > 75) {
for (int i = 0; i <= durabilityDamage; i++) {
if (armor.containsEnchantment(Enchantment.DURABILITY)) {
handleDurabilityEnchantment(armor);
}
}
damageValidation(armor);
armor.setDurability((short) (armor.getDurability() + durabilityDamage));
}
}
equipment.setArmorContents(armorContents);
}
protected void applyGreaterImpact() {
if (!Permissions.greaterImpact(player)) {
return;
}
int randomChance = 100;
if (Permissions.luckyAxes(player)) {
randomChance = (int) (randomChance * 0.75);
}
if (Misc.getRandom().nextInt(randomChance) <= Axes.greaterImpactChance) {
handleGreaterImpactEffect();
sendAbilityMessge();
}
}
private void handleGreaterImpactEffect() {
event.setDamage(event.getDamage() + Axes.greaterImpactBonusDamage);
livingDefender.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
}
private void sendAbilityMessge() {
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
if (livingDefender instanceof Player) {
((Player) livingDefender).sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
}
}
private void handleDurabilityEnchantment(ItemStack armor) {
int enchantmentLevel = armor.getEnchantmentLevel(Enchantment.DURABILITY);
if (Misc.getRandom().nextInt(enchantmentLevel + 1) > 0) {
durabilityDamage--;
}
}
private void damageValidation(ItemStack armor) {
short maxDurability = (short) (armor.getType().getMaxDurability() * Axes.impactMaxDurabilityDamageModifier);
if (durabilityDamage > maxDurability) {
durabilityDamage = maxDurability;
}
}
}

View File

@ -0,0 +1,24 @@
package com.gmail.nossr50.skills.axes;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Combat;
public class SkullSplitterEventHandler {
private Player player;
private LivingEntity target;
private int damage;
protected SkullSplitterEventHandler(AxeManager manager, EntityDamageByEntityEvent event) {
this.player = manager.getPlayer();
this.target = (LivingEntity) event.getEntity();
this.damage = event.getDamage();
}
protected void applyAbilityEffects() {
Combat.applyAbilityAoE(player, target, damage / Axes.skullSplitterModifier, SkillType.AXES);
}
}

View File

@ -115,7 +115,7 @@ public class SuperBreakerEventHandler {
}
private void calculateDurabilityLoss() {
this.durabilityLoss = Misc.TOOL_DURABILITY_LOSS;
this.durabilityLoss = Misc.toolDurabilityLoss;
if (blockType.equals(Material.OBSIDIAN)) {
durabilityLoss = durabilityLoss * 5;

View File

@ -19,9 +19,6 @@ public class SerratedStrikesEventHandler {
}
protected void applyAbilityEffects() {
if (player == null)
return;
Combat.applyAbilityAoE(player, target, damage / Swords.SERRATED_STRIKES_MODIFIER, SkillType.SWORDS);
BleedTimer.add(target, Swords.SERRATED_STRIKES_BLEED_TICKS);
}

View File

@ -76,10 +76,7 @@ public class SwordsManager extends SkillManager {
}
public void serratedStrikes(LivingEntity target, int damage) {
if (player == null)
return;
if (!Permissions.serratedStrikes(player)) {
if (Misc.isNPC(player) || !Permissions.serratedStrikes(player)) {
return;
}

View File

@ -33,7 +33,6 @@ import com.gmail.nossr50.runnables.GainXp;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.archery.ArcheryManager;
import com.gmail.nossr50.skills.axes.AxeManager;
import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.skills.swords.Swords;
import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager;
@ -101,12 +100,10 @@ public class Combat {
axeManager.bonusDamage(event);
axeManager.criticalHitCheck(event);
axeManager.impact(event);
if (Permissions.impact(attacker)) {
Axes.impact(attacker, target, event);
}
if (attackerProfile.getAbilityMode(AbilityType.SKULL_SPLIITER) && Permissions.skullSplitter(attacker)) {
if (attackerProfile.getAbilityMode(AbilityType.SKULL_SPLIITER)) {
axeManager.skullSplitter(event);
applyAbilityAoE(attacker, target, event.getDamage() / 2, SkillType.AXES);
}

View File

@ -11,10 +11,12 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
@ -25,11 +27,29 @@ import com.gmail.nossr50.party.PartyManager;
public class Misc {
private static Random random = new Random();
public static final int TOOL_DURABILITY_LOSS = Config.getInstance().getAbilityToolDamage();
public static int toolDurabilityLoss = Config.getInstance().getAbilityToolDamage();
public static int abilityLengthIncreaseLevel = AdvancedConfig.getInstance().getAbilityLength();
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
public static final int TIME_CONVERSION_FACTOR = 1000;
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
/**
* Check if a player has armor.
*
* @param player Player whose armor to check
* @return true if the player has armor, false otherwise
*/
public static boolean hasArmor(LivingEntity entity) {
EntityEquipment equipment = entity.getEquipment();
if (equipment.getBoots() != null || equipment.getChestplate() != null || equipment.getHelmet() != null || equipment.getLeggings() != null) {
return true;
}
return false;
}
public static boolean isFriendlyPet(Player attacker, Tameable pet) {
if (pet.isTamed()) {
AnimalTamer tamer = pet.getOwner();

View File

@ -90,6 +90,9 @@ Skills:
# ArmorImpact_MaxPercentageDurabilityDamage: Durability damage cap for ArmorImpact, 20% means that you can never destroy a piece of armor in less than 5 hits
ArmorImpact_IncreaseLevel: 50
ArmorImpact_MaxPercentageDurabilityDamage: 20.0
# SkullSplitter_DamageModifier: Damage will get divided by this modifier
SkullSplitter_DamageModifier: 2
#
# Settings for Fishing
###