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

This commit is contained in:
nossr50 2018-12-26 23:59:43 -08:00
parent 24e4c28355
commit 93d10c0739
12 changed files with 82 additions and 23 deletions

View File

@ -7,7 +7,11 @@ Key:
! Change ! Change
- Removal - 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 = Fixed an interaction between Tree Feller and Stripped Wood
! Fireworks no longer fire by default for ability activation/deactivation ! Fireworks no longer fire by default for ability activation/deactivation
! Website has been changed and the MOTD string relating to it reflects this ! Website has been changed and the MOTD string relating to it reflects this

View File

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

View File

@ -438,6 +438,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getAbilityMessagesEnabled() { return config.getBoolean("Abilities.Messages", true); } public boolean getAbilityMessagesEnabled() { return config.getBoolean("Abilities.Messages", true); }
public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", 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 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 getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + 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; return disabled;
} }
/* Axes */
public int getAxesGate() { return config.getInt("Skills.Axes.Ability_Activation_Level_Gate", 10); }
/* Acrobatics */ /* Acrobatics */
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); } 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); } public int getXPAfterTeleportCooldown() { return config.getInt("Skills.Acrobatics.XP_After_Teleport_Cooldown", 5); }
@ -488,6 +492,10 @@ public class Config extends AutoUpdateConfigLoader {
/* Mining */ /* Mining */
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); } 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 */ /* Repair */
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); } 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 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 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 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 */ /* Taming */
public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); } 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 */ /* Woodcutting */
public boolean getWoodcuttingDoubleDropsEnabled(BlockData material) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getFriendlyConfigBlockDataString(material)); } 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 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 */ /* AFK Leveling */
public boolean getAcrobaticsPreventAFK() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); } 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; 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); } public boolean getTruncateSkills() { return config.getBoolean("General.TruncateSkills", false); }
/* PVP & PVE Settings */ /* PVP & PVE Settings */

View File

@ -726,6 +726,19 @@ public class McMMOPlayer {
return; 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); int timeRemaining = calculateTimeRemaining(ability);
if (timeRemaining > 0) { if (timeRemaining > 0) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -208,6 +208,18 @@ public class SkillUtils {
public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player, int skillLevel, int activationChance, double maxChance, int maxLevel) { 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; 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); SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, skillAbility, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event); mcMMO.p.getServer().getPluginManager().callEvent(event);
return (event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance) && !event.isCancelled(); 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) { public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player, double staticChance, int activationChance) {
double chance = staticChance / activationChance; double chance = staticChance / activationChance;
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, skillAbility, chance); return propagateSecondaryAbilityEvent(skillAbility, player, activationChance, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
return (event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance) && !event.isCancelled();
} }
public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player) { public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player) {

View File

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

View File

@ -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.TooTired=[[RED]]You are too tired to use that ability again. [[YELLOW]]({0}s)
Skills.Cancelled=[[RED]]{0} cancelled! Skills.Cancelled=[[RED]]{0} cancelled!
Skills.ConfirmOrCancel=[[GREEN]]Right-click again to confirm [[GOLD]]{0}[[GREEN]]. Left-click to cancel. 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 #STATISTICS
Stats.Header.Combat=[[GOLD]]-=COMBAT SKILLS=- Stats.Header.Combat=[[GOLD]]-=COMBAT SKILLS=-