Fixing a lot of bugs involving calculating the success of skills

This commit is contained in:
nossr50 2019-01-27 19:36:16 -08:00
parent be9aeacd70
commit e969598f58
9 changed files with 24 additions and 22 deletions

View File

@ -9,6 +9,10 @@ Key:
Version 2.1.2
(Perks) Fixed a bug where the Lucky perk wasn't adding to success
(Skills) Fixing a bug where Shake didn't calculate success correctly
(Skills) Fixed a bug where Arcane Forging didn't calculate success and failure correctly
(Skills) Fixed a bug where Salvage didn't calculate success and failure correctly
(Skills) Fixed a bug where Flux Mining didn't calculate success correctly
(Skills) Tree Feller now works on Mushroom Stems
(Experience) Wood blocks now give XP and are affected by Tree Feller (6 sided bark blocks)
(API) Moved XPGainReason from skills to experience package
@ -17,6 +21,7 @@ Version 2.1.2
(Config) The Extra Stats option for XP bars now overrides the setting for updating XP bars every time XP is gained
(Config) Added an option for Party XP gains to not update XP bars
(Config) Added an option for Passive XP gains to not update XP bars (smelting/brewing)
(Config) Added warnings if mcMMO finds a MaxBonusLevel of 0 for any skill that incorporates RNG
Version 2.1.1
= Fixed an issue where excavation wasn't using the correct permission node

View File

@ -705,6 +705,9 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
if(mcMMO.isRetroModeEnabled())
maxBonusLevel *= 10;
if(maxBonusLevel == 0)
mcMMO.p.getLogger().severe("Warning Max Bonus Level for "+subSkillType.getAdvConfigAddress() + ".MaxBonusLevel"+" is set to 0! Typically this value should be 100.");
return maxBonusLevel;
}

View File

@ -4,19 +4,16 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.skills.PerksUtils;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public abstract class SkillManager {
protected McMMOPlayer mcMMOPlayer;
protected int activationChance;
protected PrimarySkillType skill;
public SkillManager(McMMOPlayer mcMMOPlayer, PrimarySkillType skill) {
this.mcMMOPlayer = mcMMOPlayer;
this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
this.skill = skill;
}

View File

@ -15,11 +15,10 @@ import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillRandomCheckEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
@ -261,9 +260,7 @@ public class FishingManager extends SkillManager {
public void shakeCheck(LivingEntity target) {
fishingTries--; // Because autoclicking to shake is OK.
SubSkillRandomCheckEvent activationEvent = new SubSkillRandomCheckEvent(getPlayer(), SubSkillType.FISHING_SHAKE, getShakeProbability() / activationChance);
mcMMO.p.getServer().getPluginManager().callEvent(activationEvent);
if ((activationEvent.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance)) {
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.FISHING_SHAKE, true)) {
List<ShakeTreasure> possibleDrops = Fishing.findPossibleDrops(target);
if (possibleDrops == null || possibleDrops.isEmpty()) {

View File

@ -17,6 +17,7 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
@ -324,10 +325,11 @@ public class RepairManager extends SkillManager {
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
Enchantment enchantment = enchant.getKey();
if (getKeepEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getKeepEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING))) {
int enchantLevel = enchant.getValue();
if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1 && (100 - getDowngradeEnchantChance()) <= Misc.getRandom().nextInt(activationChance)) {
if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1
&& (!RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(100 - getDowngradeEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING)))) {
item.addUnsafeEnchantment(enchantment, enchantLevel - 1);
downgraded = true;
}

View File

@ -15,6 +15,8 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
@ -196,12 +198,14 @@ public class SalvageManager extends SkillManager {
boolean downgraded = false;
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
int successChance = Misc.getRandom().nextInt(activationChance);
if (!Salvage.arcaneSalvageEnchantLoss || getExtractFullEnchantChance() > successChance) {
if (!Salvage.arcaneSalvageEnchantLoss
|| RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue(), true);
}
else if (enchant.getValue() > 1 && Salvage.arcaneSalvageDowngrades && getExtractPartialEnchantChance() > successChance) {
else if (enchant.getValue() > 1
&& Salvage.arcaneSalvageDowngrades
&& !RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getExtractPartialEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
enchantMeta.addStoredEnchant(enchant.getKey(), enchant.getValue() - 1, true);
downgraded = true;
}

View File

@ -60,9 +60,7 @@ public class SmeltingManager extends SkillManager {
public boolean processFluxMining(BlockState blockState) {
Player player = getPlayer();
SubSkillRandomCheckEvent event = new SubSkillRandomCheckEvent(getPlayer(), SubSkillType.SMELTING_FLUX_MINING, Smelting.fluxMiningChance / activationChance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if ((event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance)) {
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.SMELTING_FLUX_MINING, true)) {
ItemStack item = null;
switch (blockState.getType()) {

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillRandomCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
@ -210,12 +209,8 @@ public class TamingManager extends SkillManager {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL))
return;
double chance = 10 / activationChance;
SubSkillRandomCheckEvent event = new SubSkillRandomCheckEvent(getPlayer(), SubSkillType.TAMING_PUMMEL, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if ((event.getChance() * activationChance) <= Misc.getRandom().nextInt(activationChance)) {
if(!RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.TAMING_PUMMEL, true))
return;
}
ParticleEffectUtils.playGreaterImpactEffect(target);
target.setVelocity(wolf.getLocation().getDirection().normalize().multiply(1.5D));

View File

@ -420,6 +420,7 @@ Skills:
# Chance: Chance for Flux Mining to activate
UnlockLevel: 25
Chance: 33.0
MaxBonusLevel: 100
# VanillaXPMultiplier: Vanilla XP gained from smelting ores is multiplied by these values.
VanillaXPMultiplier: