浏览代码

Starting work on converting skills to use the new 100-scale system

nossr50 6 年之前
父节点
当前提交
93d10c0739

+ 5 - 1
Changelog.txt

@@ -7,7 +7,11 @@ Key:
   ! Change
   - Removal
 
-Version 2.0.00
+Version 2.0.1
+    ! mcMMO skills will now be on a scale from 1-100 instead of 0-1000 (I'll be explaining this in a write-up)
+
+
+Version 2.0.0
     = Fixed an interaction between Tree Feller and Stripped Wood
     ! Fireworks no longer fire by default for ability activation/deactivation
     ! Website has been changed and the MOTD string relating to it reflects this

+ 1 - 1
pom.xml

@@ -2,7 +2,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.gmail.nossr50.mcMMO</groupId>
     <artifactId>mcMMO</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>2.0.1-SNAPSHOT</version>
     <name>mcMMO</name>
     <url>https://github.com/mcMMO-Dev/mcMMO</url>
     <issueManagement>

+ 17 - 0
src/main/java/com/gmail/nossr50/config/Config.java

@@ -438,6 +438,7 @@ public class Config extends AutoUpdateConfigLoader {
     public boolean getAbilityMessagesEnabled() { return config.getBoolean("Abilities.Messages", true); }
     public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); }
     public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
+    public boolean getAbilitiesGateEnabled() { return config.getBoolean("Abilities.Activation.Level_Gate_Abilities"); }
 
     public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
     public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
@@ -471,6 +472,9 @@ public class Config extends AutoUpdateConfigLoader {
         return disabled;
     }
 
+    /* Axes */
+    public int getAxesGate() { return config.getInt("Skills.Axes.Ability_Activation_Level_Gate", 10); }
+
     /* Acrobatics */
     public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
     public int getXPAfterTeleportCooldown() { return config.getInt("Skills.Acrobatics.XP_After_Teleport_Cooldown", 5); }
@@ -488,6 +492,10 @@ public class Config extends AutoUpdateConfigLoader {
 
     /* Mining */
     public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
+    public int getMiningGate() { return config.getInt("Skills.Mining.Ability_Activation_Level_Gate", 10); }
+
+    /* Excavation */
+    public int getExcavationGate() { return config.getInt("Skills.Excavation.Ability_Activation_Level_Gate", 10); }
 
     /* Repair */
     public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
@@ -507,6 +515,10 @@ public class Config extends AutoUpdateConfigLoader {
     public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
     public boolean getUnarmedItemPickupDisabled() { return config.getBoolean("Skills.Unarmed.Item_Pickup_Disabled_Full_Inventory", true); }
     public boolean getUnarmedItemsAsUnarmed() { return config.getBoolean("Skills.Unarmed.Items_As_Unarmed", false); }
+    public int getUnarmedGate() { return config.getInt("Skills.Unarmed.Ability_Activation_Level_Gate", 10); }
+
+    /* Swords */
+    public int getSwordsGate() { return config.getInt("Skills.Swords.Ability_Activation_Level_Gate", 10); }
 
     /* Taming */
     public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); }
@@ -519,6 +531,7 @@ public class Config extends AutoUpdateConfigLoader {
     /* Woodcutting */
     public boolean getWoodcuttingDoubleDropsEnabled(BlockData material) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getFriendlyConfigBlockDataString(material)); }
     public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
+    public int getWoodcuttingGate() { return config.getInt("Skills.Woodcutting.Ability_Activation_Level_Gate", 10); }
 
     /* AFK Leveling */
     public boolean getAcrobaticsPreventAFK() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
@@ -536,6 +549,10 @@ public class Config extends AutoUpdateConfigLoader {
         return (cap <= 0) ? Integer.MAX_VALUE : cap;
     }
 
+    public int getSkillAbilityGate(SkillType skill) {
+        return config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Ability_Activation_Level_Gate");
+    }
+
     public boolean getTruncateSkills() { return config.getBoolean("General.TruncateSkills", false); }
 
     /* PVP & PVE Settings */

+ 13 - 0
src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java

@@ -726,6 +726,19 @@ public class McMMOPlayer {
             return;
         }
 
+        /*
+         * Check if the player has passed the gate requirement
+         */
+        if(Config.getInstance().getAbilitiesGateEnabled())
+        {
+            if(getSkillLevel(skill) < skill.getSkillAbilityGate())
+            {
+                //Inform the player they are not yet skilled enough
+                player.sendMessage(LocaleLoader.getString("Skills.AbilityGateRequirementFail"));
+                return;
+            }
+        }
+
         int timeRemaining = calculateTimeRemaining(ability);
 
         if (timeRemaining > 0) {

+ 2 - 0
src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java

@@ -119,6 +119,8 @@ public enum SkillType {
         return Config.getInstance().getLevelCap(this);
     }
 
+    public int getSkillAbilityGate() { return Config.getInstance().getSkillAbilityGate(this); }
+
     public boolean getPVPEnabled() {
         return Config.getInstance().getPVPEnabled(this);
     }

+ 1 - 0
src/main/java/com/gmail/nossr50/skills/SkillManager.java

@@ -1,5 +1,6 @@
 package com.gmail.nossr50.skills;
 
+import com.gmail.nossr50.config.Config;
 import org.bukkit.entity.Entity;
 import org.bukkit.entity.LivingEntity;
 import org.bukkit.entity.Player;

+ 1 - 0
src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java

@@ -21,6 +21,7 @@ public final class Woodcutting {
     public static int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
     public static int treeFellerThreshold = Config.getInstance().getTreeFellerThreshold();
 
+
     protected static boolean treeFellerReachedThreshold = false;
 
     protected enum ExperienceGainMethod {

+ 2 - 0
src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java

@@ -1,5 +1,6 @@
 package com.gmail.nossr50.skills.woodcutting;
 
+import com.gmail.nossr50.config.Config;
 import com.gmail.nossr50.datatypes.mods.CustomBlock;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.skills.AbilityType;
@@ -23,6 +24,7 @@ import java.util.HashSet;
 import java.util.Set;
 
 public class WoodcuttingManager extends SkillManager {
+
     public WoodcuttingManager(McMMOPlayer mcMMOPlayer) {
         super(mcMMOPlayer, SkillType.WOODCUTTING);
     }

+ 2 - 2
src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java

@@ -116,7 +116,7 @@ public class FormulaManager {
         switch (formulaType) {
             case LINEAR:
                 if (!experienceNeededLinear.containsKey(level)) {
-                    experience = (int) Math.floor(base + level * multiplier);
+                    experience = (int) Math.floor( 10 * (base + level * multiplier));
                     experienceNeededLinear.put(level, experience);
                 }
 
@@ -124,7 +124,7 @@ public class FormulaManager {
 
             case EXPONENTIAL:
                 if (!experienceNeededExponential.containsKey(level)) {
-                    experience = (int) Math.floor(multiplier * Math.pow(level, exponent) + base);
+                    experience = (int) Math.floor( 10 * multiplier * Math.pow(level, exponent) + base);
                     experienceNeededExponential.put(level, experience);
                 }
 

+ 13 - 3
src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java

@@ -208,6 +208,18 @@ public class SkillUtils {
 
     public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player, int skillLevel, int activationChance, double maxChance, int maxLevel) {
         double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel) / activationChance;
+        return propagateSecondaryAbilityEvent(skillAbility, player, activationChance, chance);
+    }
+
+    /**
+     * Sends an event out regarding activation of RNG based sub-skills
+     * @param skillAbility The random-chance ability
+     * @param player The player that the skill belong to
+     * @param activationChance parameter used in activation calculations
+     * @param chance parameter used in activation calculations
+     * @return returns true if successful
+     */
+    private static boolean propagateSecondaryAbilityEvent(SecondaryAbility skillAbility, Player player, int activationChance, double chance) {
         SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, skillAbility, chance);
         mcMMO.p.getServer().getPluginManager().callEvent(event);
         return (event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance) && !event.isCancelled();
@@ -215,9 +227,7 @@ public class SkillUtils {
 
     public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player, double staticChance, int activationChance) {
         double chance = staticChance / activationChance;
-        SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, skillAbility, chance);
-        mcMMO.p.getServer().getPluginManager().callEvent(event);
-        return (event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance) && !event.isCancelled();
+        return propagateSecondaryAbilityEvent(skillAbility, player, activationChance, chance);
     }
 
     public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player) {

+ 24 - 16
src/main/resources/config.yml

@@ -21,7 +21,7 @@ General:
     Prefer_Beta: false
     Power_Level_Cap: 0
     # Should mcMMO truncate levels if you lower your max level cap for a skillname
-    TruncateSkills: false
+    TruncateSkills: true
     # Should mcMMO print out debug messages?
     Verbose_Logging: false
     # Should mcMMO over-write configs to update, or make new ones ending in .new?
@@ -267,6 +267,8 @@ Abilities:
     Enabled: true
     Messages: true
     Activation:
+        # If set to true, abilities will not be available until they meet specific level requirements to use
+        Level_Gate_Abilities: true
         Only_Activate_When_Sneaking: false
     Cooldowns:
         Berserk: 240
@@ -305,7 +307,7 @@ Skills:
         Prevent_Dodge_Lightning: false
         # Prevent earning Acrobatics XP a few seconds after teleporting
         XP_After_Teleport_Cooldown: 5
-        Level_Cap: 0
+        Level_Cap: 100
     Alchemy:
         # Allow Hoppers to transfer ingredients and brew Rank 1 Alchemy potions
         Enabled_for_Hoppers: true
@@ -313,32 +315,35 @@ Skills:
         Prevent_Hopper_Transfer_Ingredients: false
         # Prevent Hoppers from transferring bottles into Brewing Stands
         Prevent_Hopper_Transfer_Bottles: false
-        Level_Cap: 0
+        Level_Cap: 100
     Archery:
         Enabled_For_PVP: true
         Enabled_For_PVE: true
-        Level_Cap: 0
+        Level_Cap: 100
     Axes:
         Enabled_For_PVP: true
         Enabled_For_PVE: true
-        Level_Cap: 0
+        Level_Cap: 100
+        Ability_Activation_Level_Gate: 10
     Excavation:
-        Level_Cap: 0
+        Level_Cap: 100
+        Ability_Activation_Level_Gate: 10
     Fishing:
-        Level_Cap: 0
+        Level_Cap: 100
         Drops_Enabled: true
         Override_Vanilla_Treasures: true
         # Always catch fish, even when treasure is found
         Extra_Fish: false
         Lure_Modifier: 4.0
     Herbalism:
-        Level_Cap: 0
+        Level_Cap: 100
         Prevent_AFK_Leveling: true
     Mining:
-        Level_Cap: 0
+        Level_Cap: 100
         Detonator_Name: FLINT_AND_STEEL
+        Ability_Activation_Level_Gate: 10
     Repair:
-        Level_Cap: 0
+        Level_Cap: 100
         Anvil_Messages: true
         Anvil_Placed_Sounds: true
         Anvil_Use_Sounds: true
@@ -346,7 +351,7 @@ Skills:
         # Ask for a confirmation when a player tries to repair an enchanted item
         Confirm_Required: true
     Salvage:
-        Level_Cap: 0
+        Level_Cap: 100
         Anvil_Messages: true
         Anvil_Placed_Sounds: true
         Anvil_Use_Sounds: true
@@ -354,15 +359,16 @@ Skills:
         # Ask for a confirmation when a player tries to salvage an enchanted item
         Confirm_Required: true
     Smelting:
-        Level_Cap: 0
+        Level_Cap: 100
     Swords:
         Enabled_For_PVP: true
         Enabled_For_PVE: true
-        Level_Cap: 0
+        Level_Cap: 100
+        Ability_Activation_Level_Gate: 10
     Taming:
         Enabled_For_PVP: true
         Enabled_For_PVE: true
-        Level_Cap: 0
+        Level_Cap: 100
         Call_Of_The_Wild:
             # Item_Material: Material of the item needed to summon the pet
             # Item_Amount: Amount of items required to summon the pet
@@ -394,7 +400,8 @@ Skills:
     Unarmed:
         Enabled_For_PVP: true
         Enabled_For_PVE: true
-        Level_Cap: 0
+        Level_Cap: 100
+        Ability_Activation_Level_Gate: 10
         Block_Cracker:
             SmoothBrick_To_CrackedBrick: true
         # When using Unarmed, picked up items will automatically get moved to a free slot instead of going in the slot
@@ -404,7 +411,8 @@ Skills:
         Items_As_Unarmed: false
     Woodcutting:
         Tree_Feller_Sounds: true
-        Level_Cap: 0
+        Level_Cap: 100
+        Ability_Activation_Level_Gate: 10
 
 #
 #  Settings for Double Drops

+ 1 - 0
src/main/resources/locale/locale_en_US.properties

@@ -858,6 +858,7 @@ Skills.ChildStats=[[YELLOW]]{0}[[GREEN]]{1}
 Skills.TooTired=[[RED]]You are too tired to use that ability again. [[YELLOW]]({0}s)
 Skills.Cancelled=[[RED]]{0} cancelled!
 Skills.ConfirmOrCancel=[[GREEN]]Right-click again to confirm [[GOLD]]{0}[[GREEN]]. Left-click to cancel.
+Skills.AbilityGateRequirementFail=[[YELLOW]]You are not yet skilled enough to perform this task.
 
 #STATISTICS
 Stats.Header.Combat=[[GOLD]]-=COMBAT SKILLS=-