converting more SubSkills to be JSON friendly

AxeMaster & SkillShot
This commit is contained in:
nossr50
2019-01-03 04:32:46 -08:00
parent 4669e3e54d
commit 54cf356b71
10 changed files with 73 additions and 59 deletions

View File

@ -32,7 +32,7 @@ public class ArcheryCommand extends SkillCommand {
// SKILL SHOT
if (canSkillShot) {
double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
skillShotBonus = percent.format(Math.min(bonus, Archery.skillShotMaxBonusPercentage));
skillShotBonus = percent.format(Archery.getSkillShotBonusDamage(player, 0));
}
// ARCHERY_DAZE

View File

@ -3,8 +3,10 @@ package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkill;
import com.gmail.nossr50.datatypes.skills.SubSkill;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -53,7 +55,7 @@ public class AxesCommand extends SkillCommand {
// AXE MASTERY
if (canAxeMastery) {
axeMasteryDamage = Math.min(skillValue / (Axes.axeMasteryMaxBonusLevel / Axes.axeMasteryMaxBonus), Axes.axeMasteryMaxBonus);
axeMasteryDamage = Axes.getAxeMasteryBonusDamage(player);
}
}

View File

@ -119,12 +119,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* ARCHERY */
if (getSkillShotIncreasePercentage() <= 0) {
reason.add("Skills.Archery.SkillShot.IncreaseDamage should be greater than 0!");
}
if (getSkillShotBonusMax() < 0) {
reason.add("Skills.Archery.SkillShot.IncreaseDamageMaxBonus should be at least 0!");
if (getSkillShotRankDamageMultiplier() <= 0) {
reason.add("Skills.Archery.SkillShot.RankDamageMultiplier should be greater than 0!");
}
if (getMaxChance(SubSkill.ARCHERY_DAZE) < 1) {
@ -152,12 +148,9 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
}
/* AXES */
if (getAxeMasteryBonusMax() < 1) {
reason.add("Skills.Axes.AxeMastery.MaxBonus should be at least 1!");
}
if (getAxeMasteryMaxBonusLevel() < 1) {
reason.add("Skills.Axes.AxeMastery.MaxBonusLevel should be at least 1!");
if(getAxeMasteryRankDamageMultiplier() < 0)
{
reason.add("Skills.Axes.AxeMastery.RankDamageMultiplier should be at least 0!");
}
if (getMaxChance(SubSkill.AXES_CRITICAL_HIT) < 1) {
@ -736,8 +729,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* ARCHERY */
public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot.IncreaseLevel", 50); }
public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot.IncreaseDamage", 10.0D); }
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot.IncreaseDamageMaxBonus", 200.0D); }
public double getSkillShotRankDamageMultiplier() { return config.getDouble("Skills.Archery.SkillShot.RankDamageMultiplier", 10.0D); }
public double getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D); }
public double getDazeBonusDamage() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }
@ -745,8 +737,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getForceMultiplier() { return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D); }
/* AXES */
public double getAxeMasteryBonusMax() { return config.getDouble("Skills.Axes.AxeMastery.MaxBonus", 4.0D); }
public int getAxeMasteryMaxBonusLevel() { return config.getInt("Skills.Axes.AxeMastery.MaxBonusLevel", 200); }
public double getAxeMasteryRankDamageMultiplier() { return config.getDouble("Skills.Axes.AxeMastery.RankDamageMultiplier", 1.0D); }
public double getCriticalHitPVPModifier() { return config.getDouble("Skills.Axes.CriticalHit.PVP_Modifier", 1.5D); }
public double getCriticalHitPVEModifier() { return config.getDouble("Skills.Axes.CriticalHit.PVE_Modifier", 2.0D); }

View File

@ -26,9 +26,10 @@ public enum SubSkill {
/* Axes */
AXES_ARMOR_IMPACT,
AXES_AXE_MASTERY,
AXES_AXE_MASTERY(4),
AXES_CRITICAL_HIT,
AXES_GREATER_IMPACT,
AXES_SKULL_SPLITTER(0, ACTIVE | SUPERABILITY),
/* Excavation */
EXCAVATION_TREASURE_HUNTER,
@ -97,6 +98,7 @@ public enum SubSkill {
WOODCUTTING_HARVEST_LUMBER(3, RNG);
private final int numRanks;
//TODO: SuperAbility should also contain flags for active by default? Not sure if it should work that way.
private final int flags;
/**

View File

@ -4,8 +4,11 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.gmail.nossr50.datatypes.skills.SubSkill;
import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
@ -16,8 +19,7 @@ public class Archery {
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
public static int skillShotIncreaseLevel = AdvancedConfig.getInstance().getSkillShotIncreaseLevel();
public static double skillShotIncreasePercentage = AdvancedConfig.getInstance().getSkillShotIncreasePercentage();
public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax();
public static double skillShotIncreasePercentage = AdvancedConfig.getInstance().getSkillShotRankDamageMultiplier();
public static double skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax();
public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage();
@ -62,4 +64,19 @@ public class Archery {
}
}
}
/**
* Every rank we increase Skill Shot's bonus damage % by the IncreaseDamage percentage value from advanced.yml
* Divide end result by 100.0D to get proper scale
* Damage is capped in advanced.yml by Archery.SkillShot.MaxDamage
*
* @param player The target player
* @param oldDamage The raw damage of the arrow before we add bonus damage
* @return The damage that the arrow will deal after we've added bonus damage, damage is capped by Archery.SkillShot.MaxDamage
*/
public static double getSkillShotBonusDamage(Player player, double oldDamage)
{
double damageBonusPercent = ((RankUtils.getRank(player, SubSkill.ARCHERY_SKILL_SHOT)) * Archery.skillShotIncreasePercentage) / 100.0D;
return Math.min(oldDamage * damageBonusPercent, Archery.skillShotMaxBonusDamage);
}
}

View File

@ -93,23 +93,15 @@ public class ArcheryManager extends SkillManager {
}
/**
* Handle the effects of the Skill Shot ability
* Calculates the damage to deal after Skill Shot has been applied
*
* @param damage The amount of damage initially dealt by the event
* @param oldDamage The raw damage value of this arrow before we modify it
*/
public double skillShot(double damage) {
public double skillShot(double oldDamage) {
if (!SkillUtils.isActivationSuccessful(SubSkillActivationType.ALWAYS_FIRES, SubSkill.ARCHERY_SKILL_SHOT, getPlayer(), null, 0, 0)) {
return damage;
return oldDamage;
}
/*
* Archery
* Skill Shot
*
* Every rank we increase Skill Shot's bonus damage % by the IncreaseDamage percentage value from advanced.yml
* Divide end result by 100.0D to get proper scale
*/
double damageBonusPercent = (Math.min(((RankUtils.getRank(getPlayer(), SubSkill.ARCHERY_SKILL_SHOT)) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage) / 100.0D);
return Math.min(damage * damageBonusPercent, Archery.skillShotMaxBonusDamage);
return Archery.getSkillShotBonusDamage(getPlayer(), oldDamage);
}
}

View File

@ -1,14 +1,17 @@
package com.gmail.nossr50.skills.axes;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SubSkill;
import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.ItemUtils;
public class Axes {
public static double axeMasteryMaxBonus = AdvancedConfig.getInstance().getAxeMasteryBonusMax();
public static int axeMasteryMaxBonusLevel = AdvancedConfig.getInstance().getAxeMasteryMaxBonusLevel();
public static double axeMasteryRankDamageMultiplier = AdvancedConfig.getInstance().getAxeMasteryRankDamageMultiplier();
public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getCriticalHitPVPModifier();
public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getCriticalHitPVEModifier();
@ -32,4 +35,14 @@ public class Axes {
return false;
}
/**
* For every rank in Axe Mastery we add RankDamageMultiplier to get the total bonus damage from Axe Mastery
* @param player The target player
* @return The axe mastery bonus damage which will be added to their attack
*/
public static double getAxeMasteryBonusDamage(Player player)
{
return RankUtils.getRank(player, SubSkill.AXES_AXE_MASTERY) * Axes.axeMasteryRankDamageMultiplier;
}
}

View File

@ -3,7 +3,7 @@ package com.gmail.nossr50.skills.axes;
import java.util.Map;
import com.gmail.nossr50.datatypes.skills.SubSkill;
import com.gmail.nossr50.util.skills.SubSkillActivationType;
import com.gmail.nossr50.util.skills.*;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
@ -18,9 +18,6 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AxesManager extends SkillManager {
public AxesManager(McMMOPlayer mcMMOPlayer) {
@ -59,7 +56,7 @@ public class AxesManager extends SkillManager {
return 0;
}
return Math.min(getSkillLevel() / (Axes.axeMasteryMaxBonusLevel / Axes.axeMasteryMaxBonus), Axes.axeMasteryMaxBonus);
return Axes.getAxeMasteryBonusDamage(getPlayer());
}
/**