Starting to convert existing subskills to be JSON friendly

So far only a few have been converted
This commit is contained in:
nossr50
2019-01-03 03:42:11 -08:00
parent f4ead570d4
commit 4669e3e54d
7 changed files with 90 additions and 31 deletions

View File

@ -118,16 +118,13 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
}
/* ARCHERY */
if (getSkillShotIncreaseLevel() < 1) {
reason.add("Skills.Archery.SkillShot.IncreaseLevel should be at least 1!");
}
if (getSkillShotIncreasePercentage() <= 0) {
reason.add("Skills.Archery.SkillShot.IncreasePercentage should be greater than 0!");
reason.add("Skills.Archery.SkillShot.IncreaseDamage should be greater than 0!");
}
if (getSkillShotBonusMax() < 0) {
reason.add("Skills.Archery.SkillShot.MaxBonus should be at least 0!");
reason.add("Skills.Archery.SkillShot.IncreaseDamageMaxBonus should be at least 0!");
}
if (getMaxChance(SubSkill.ARCHERY_DAZE) < 1) {
@ -739,8 +736,8 @@ 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.IncreasePercentage", 0.1D); }
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot.MaxBonus", 2.0D); }
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 getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D); }
public double getDazeBonusDamage() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }

View File

@ -2,23 +2,27 @@ package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
import static com.gmail.nossr50.datatypes.skills.SubSkillFlags.ACTIVE;
import static com.gmail.nossr50.datatypes.skills.SubSkillFlags.SUPERABILITY;
import static com.gmail.nossr50.datatypes.skills.SubSkillFlags.RNG;
public enum SubSkill {
/* !! Warning -- Do not let subskills share a name with any existing PrimarySkill as it will clash with the static import !! */
/* ACROBATICS */
ACROBATICS_DODGE,
ACROBATICS_GRACEFUL_ROLL,
ACROBATICS_ROLL,
ACROBATICS_DODGE(0, RNG),
ACROBATICS_GRACEFUL_ROLL(0, ACTIVE | RNG),
ACROBATICS_ROLL(0, RNG),
/* ALCHEMY */
ALCHEMY_CATALYSIS,
ALCHEMY_CONCOCTIONS,
ALCHEMY_CONCOCTIONS(8),
/* ARCHERY */
ARCHERY_DAZE,
ARCHERY_RETRIEVE,
ARCHERY_SKILL_SHOT,
ARCHERY_SKILL_SHOT(20),
/* Axes */
AXES_ARMOR_IMPACT,
@ -85,33 +89,43 @@ public enum SubSkill {
UNARMED_IRON_GRIP,
/* Woodcutting */
WOODCUTTING_TREE_FELLER(5),
WOODCUTTING_TREE_FELLER(5, ACTIVE | SUPERABILITY),
WOODCUTTING_LEAF_BLOWER(3),
WOODCUTTING_BARK_SURGEON(3),
WOODCUTTING_BARK_SURGEON(3, ACTIVE),
WOODCUTTING_NATURES_BOUNTY(3),
WOODCUTTING_SPLINTER(3),
WOODCUTTING_HARVEST_LUMBER(3);
WOODCUTTING_HARVEST_LUMBER(3, RNG);
private final int numRanks;
private final int flags;
/**
* If our SubSkill has more than 1 rank define it
* @param numRanks The number of ranks our SubSkill has
*/
SubSkill(int numRanks, int flags)
{
this.numRanks = numRanks;
this.flags = flags;
}
SubSkill(int numRanks)
{
this.numRanks = numRanks;
this.flags = 0x00;
}
/**
* SubSkills will default to having 0 ranks if not defined
*/
SubSkill()
{
this.numRanks = 0;
this.flags = 0x00;
}
/**
* Get the bit flags for this subskill
* @return The bit flags for this subskill
*/
public final int getFlags() { return flags; }
public int getNumRanks()
{

View File

@ -0,0 +1,11 @@
package com.gmail.nossr50.datatypes.skills;
public class SubSkillFlags {
/*
* Bitwise Flags
* These are so I can establish properties of each subskill quite easily
*/
public static final byte ACTIVE = 0x01; //Active subskills are ones that aren't passive
public static final byte SUPERABILITY = 0x02; //If the subskill is a super ability
public static final byte RNG = 0x04; //If the subskill makes use of RNG
}

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.skills.archery;
import com.gmail.nossr50.datatypes.skills.SubSkill;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SubSkillActivationType;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
@ -101,8 +102,14 @@ public class ArcheryManager extends SkillManager {
return damage;
}
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
/*
* 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);
}
}

View File

@ -81,4 +81,6 @@ public class SkillTextComponentFactory {
subSkillHoverComponents.put(subSkill, newComponents);
return subSkillHoverComponents.get(subSkill);
}
}