mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
RandomChanceUtil refactor part 4
This commit is contained in:
parent
e30c7110eb
commit
6a3671a190
@ -6,7 +6,7 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.listeners.InteractionManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -29,7 +29,7 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// ACROBATICS_DODGE
|
||||
if (canDodge) {
|
||||
String[] dodgeStrings = getAbilityDisplayValues(player, SubSkillType.ACROBATICS_DODGE);
|
||||
String[] dodgeStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.ACROBATICS_DODGE);
|
||||
dodgeChance = dodgeStrings[0];
|
||||
dodgeChanceLucky = dodgeStrings[1];
|
||||
}
|
||||
@ -56,25 +56,7 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
|
||||
if(abstractSubSkill != null)
|
||||
{
|
||||
double rollChance, graceChance;
|
||||
|
||||
//Chance to roll at half
|
||||
SkillProbabilityWrapper roll_rcs = new SkillProbabilityWrapper(player, SubSkillType.ACROBATICS_ROLL);
|
||||
|
||||
//Chance to graceful roll
|
||||
SkillProbabilityWrapper grace_rcs = new SkillProbabilityWrapper(player, SubSkillType.ACROBATICS_ROLL);
|
||||
grace_rcs.setxPos(grace_rcs.getxPos() * 2); //Double Odds
|
||||
|
||||
//Chance Stat Calculations
|
||||
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs);
|
||||
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
|
||||
//damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
|
||||
|
||||
String[] rollStrings = getAbilityDisplayValues(player, SubSkillType.ACROBATICS_ROLL);
|
||||
|
||||
//Format
|
||||
double rollChanceLucky = rollChance * 1.333D;
|
||||
double graceChanceLucky = graceChance * 1.333D;
|
||||
String[] rollStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.ACROBATICS_ROLL);
|
||||
|
||||
messages.add(getStatMessage(SubSkillType.ACROBATICS_ROLL, rollStrings[0])
|
||||
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollStrings[1]) : ""));
|
||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -32,14 +33,14 @@ public class ArcheryCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// ARCHERY_ARROW_RETRIEVAL
|
||||
if (canRetrieve) {
|
||||
String[] retrieveStrings = getAbilityDisplayValues(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
|
||||
String[] retrieveStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
|
||||
retrieveChance = retrieveStrings[0];
|
||||
retrieveChanceLucky = retrieveStrings[1];
|
||||
}
|
||||
|
||||
// ARCHERY_DAZE
|
||||
if (canDaze) {
|
||||
String[] dazeStrings = getAbilityDisplayValues(player, SubSkillType.ARCHERY_DAZE);
|
||||
String[] dazeStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.ARCHERY_DAZE);
|
||||
dazeChance = dazeStrings[0];
|
||||
dazeChanceLucky = dazeStrings[1];
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ 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.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -47,7 +48,7 @@ public class AxesCommand extends SkillCommand {
|
||||
|
||||
// CRITICAL HIT
|
||||
if (canCritical) {
|
||||
String[] criticalHitStrings = getAbilityDisplayValues(player, SubSkillType.AXES_CRITICAL_STRIKES);
|
||||
String[] criticalHitStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.AXES_CRITICAL_STRIKES);
|
||||
critChance = criticalHitStrings[0];
|
||||
critChanceLucky = criticalHitStrings[1];
|
||||
}
|
||||
|
@ -9,8 +9,10 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.random.Probability;
|
||||
import com.gmail.nossr50.util.random.ProbabilityFactory;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -80,7 +82,8 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
// FISHING_SHAKE
|
||||
if (canShake) {
|
||||
String[] shakeStrings = RandomChanceUtil.calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance());
|
||||
Probability shakeProbability = ProbabilityFactory.ofPercentageValue(fishingManager.getShakeChance());
|
||||
String[] shakeStrings = SkillUtils.getRNGDisplayValues(shakeProbability);
|
||||
shakeChance = shakeStrings[0];
|
||||
shakeChanceLucky = shakeStrings[1];
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
@ -44,7 +45,7 @@ public class HerbalismCommand extends SkillCommand {
|
||||
|
||||
// DOUBLE DROPS
|
||||
if (canDoubleDrop) {
|
||||
String[] doubleDropStrings = getAbilityDisplayValues(player, SubSkillType.HERBALISM_DOUBLE_DROPS);
|
||||
String[] doubleDropStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.HERBALISM_DOUBLE_DROPS);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
@ -65,21 +66,21 @@ public class HerbalismCommand extends SkillCommand {
|
||||
if (canGreenThumbBlocks || canGreenThumbPlants) {
|
||||
greenThumbStage = RankUtils.getRank(player, SubSkillType.HERBALISM_GREEN_THUMB);
|
||||
|
||||
String[] greenThumbStrings = getAbilityDisplayValues(player, SubSkillType.HERBALISM_GREEN_THUMB);
|
||||
String[] greenThumbStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.HERBALISM_GREEN_THUMB);
|
||||
greenThumbChance = greenThumbStrings[0];
|
||||
greenThumbChanceLucky = greenThumbStrings[1];
|
||||
}
|
||||
|
||||
// HYLIAN LUCK
|
||||
if (hasHylianLuck) {
|
||||
String[] hylianLuckStrings = getAbilityDisplayValues(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
|
||||
String[] hylianLuckStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
|
||||
hylianLuckChance = hylianLuckStrings[0];
|
||||
hylianLuckChanceLucky = hylianLuckStrings[1];
|
||||
}
|
||||
|
||||
// SHROOM THUMB
|
||||
if (canShroomThumb) {
|
||||
String[] shroomThumbStrings = getAbilityDisplayValues(player, SubSkillType.HERBALISM_SHROOM_THUMB);
|
||||
String[] shroomThumbStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.HERBALISM_SHROOM_THUMB);
|
||||
shroomThumbChance = shroomThumbStrings[0];
|
||||
shroomThumbChanceLucky = shroomThumbStrings[1];
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -56,14 +57,14 @@ public class MiningCommand extends SkillCommand {
|
||||
|
||||
// Mastery TRIPLE DROPS
|
||||
if (canMotherLode) {
|
||||
String[] masteryTripleDropStrings = getAbilityDisplayValues(player, SubSkillType.MINING_MOTHER_LODE);
|
||||
String[] masteryTripleDropStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.MINING_MOTHER_LODE);
|
||||
tripleDropChance = masteryTripleDropStrings[0];
|
||||
tripleDropChanceLucky = masteryTripleDropStrings[1];
|
||||
}
|
||||
|
||||
// DOUBLE DROPS
|
||||
if (canDoubleDrop) {
|
||||
String[] doubleDropStrings = getAbilityDisplayValues(player, SubSkillType.MINING_DOUBLE_DROPS);
|
||||
String[] doubleDropStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.MINING_DOUBLE_DROPS);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
@ -67,7 +68,7 @@ public class RepairCommand extends SkillCommand {
|
||||
|
||||
// SUPER REPAIR
|
||||
if (canSuperRepair) {
|
||||
String[] superRepairStrings = getAbilityDisplayValues(player, SubSkillType.REPAIR_SUPER_REPAIR);
|
||||
String[] superRepairStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.REPAIR_SUPER_REPAIR);
|
||||
superRepairChance = superRepairStrings[0];
|
||||
superRepairChanceLucky = superRepairStrings[1];
|
||||
}
|
||||
|
@ -11,10 +11,8 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -219,10 +217,6 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
|
||||
}
|
||||
|
||||
protected static String[] getAbilityDisplayValues(SkillActivationType skillActivationType, Player player, SubSkillType subSkill) {
|
||||
return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, player, subSkill);
|
||||
}
|
||||
|
||||
protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
|
||||
int maxLength = skill.getAbility().getMaxLength();
|
||||
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
|
||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -38,14 +39,14 @@ public class SmeltingCommand extends SkillCommand {
|
||||
|
||||
// FLUX MINING
|
||||
/*if (canFluxMine) {
|
||||
String[] fluxMiningStrings = getAbilityDisplayValues(player, SubSkillType.SMELTING_FLUX_MINING);
|
||||
String[] fluxMiningStrings = getRNGDisplayValues(player, SubSkillType.SMELTING_FLUX_MINING);
|
||||
str_fluxMiningChance = fluxMiningStrings[0];
|
||||
str_fluxMiningChanceLucky = fluxMiningStrings[1];
|
||||
}*/
|
||||
|
||||
// SECOND SMELT
|
||||
if (canSecondSmelt) {
|
||||
String[] secondSmeltStrings = getAbilityDisplayValues(player, SubSkillType.SMELTING_SECOND_SMELT);
|
||||
String[] secondSmeltStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.SMELTING_SECOND_SMELT);
|
||||
str_secondSmeltChance = secondSmeltStrings[0];
|
||||
str_secondSmeltChanceLucky = secondSmeltStrings[1];
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ 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.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -36,7 +37,7 @@ public class SwordsCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// SWORDS_COUNTER_ATTACK
|
||||
if (canCounter) {
|
||||
String[] counterStrings = getAbilityDisplayValues(player, SubSkillType.SWORDS_COUNTER_ATTACK);
|
||||
String[] counterStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.SWORDS_COUNTER_ATTACK);
|
||||
counterChance = counterStrings[0];
|
||||
counterChanceLucky = counterStrings[1];
|
||||
}
|
||||
@ -45,7 +46,7 @@ public class SwordsCommand extends SkillCommand {
|
||||
if (canBleed) {
|
||||
bleedLength = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();
|
||||
|
||||
String[] bleedStrings = getAbilityDisplayValues(player, SubSkillType.SWORDS_RUPTURE);
|
||||
String[] bleedStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.SWORDS_RUPTURE);
|
||||
bleedChance = bleedStrings[0];
|
||||
bleedChanceLucky = bleedStrings[1];
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -34,7 +35,7 @@ public class TamingCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
if (canGore) {
|
||||
String[] goreStrings = getAbilityDisplayValues(player, SubSkillType.TAMING_GORE);
|
||||
String[] goreStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.TAMING_GORE);
|
||||
goreChance = goreStrings[0];
|
||||
goreChanceLucky = goreStrings[1];
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ 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.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -39,7 +40,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// UNARMED_ARROW_DEFLECT
|
||||
if (canDeflect) {
|
||||
String[] deflectStrings = getAbilityDisplayValues(player, SubSkillType.UNARMED_ARROW_DEFLECT);
|
||||
String[] deflectStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.UNARMED_ARROW_DEFLECT);
|
||||
deflectChance = deflectStrings[0];
|
||||
deflectChanceLucky = deflectStrings[1];
|
||||
}
|
||||
@ -53,7 +54,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
|
||||
// UNARMED_DISARM
|
||||
if (canDisarm) {
|
||||
String[] disarmStrings = getAbilityDisplayValues(player, SubSkillType.UNARMED_DISARM);
|
||||
String[] disarmStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.UNARMED_DISARM);
|
||||
disarmChance = disarmStrings[0];
|
||||
disarmChanceLucky = disarmStrings[1];
|
||||
}
|
||||
@ -65,7 +66,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
|
||||
// IRON GRIP
|
||||
if (canIronGrip) {
|
||||
String[] ironGripStrings = getAbilityDisplayValues(player, SubSkillType.UNARMED_IRON_GRIP);
|
||||
String[] ironGripStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.UNARMED_IRON_GRIP);
|
||||
ironGripChance = ironGripStrings[0];
|
||||
ironGripChanceLucky = ironGripStrings[1];
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -42,7 +43,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
|
||||
//Clean Cuts
|
||||
if(canTripleDrop) {
|
||||
String[] tripleDropStrings = getAbilityDisplayValues(player, SubSkillType.WOODCUTTING_CLEAN_CUTS);
|
||||
String[] tripleDropStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.WOODCUTTING_CLEAN_CUTS);
|
||||
tripleDropChance = tripleDropStrings[0];
|
||||
tripleDropChanceLucky = tripleDropStrings[1];
|
||||
}
|
||||
@ -56,7 +57,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
private void setDoubleDropClassicChanceStrings(Player player) {
|
||||
String[] doubleDropStrings = getAbilityDisplayValues(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
|
||||
String[] doubleDropStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -14,8 +15,8 @@ import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.random.SkillProbabilityType;
|
||||
import com.gmail.nossr50.util.random.Probability;
|
||||
import com.gmail.nossr50.util.random.ProbabilityImpl;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@ -32,6 +33,7 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@ -124,14 +126,17 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
float skillValue = playerProfile.getSkillLevel(getPrimarySkill());
|
||||
boolean isLucky = Permissions.lucky(player, getPrimarySkill());
|
||||
|
||||
String[] rollStrings = RandomChanceUtil.calculateAbilityDisplayValues(player, SubSkillType.ACROBATICS_ROLL);
|
||||
String[] rollStrings = SkillUtils.getRNGDisplayValues(player, SubSkillType.ACROBATICS_ROLL);
|
||||
rollChance = rollStrings[0];
|
||||
rollChanceLucky = rollStrings[1];
|
||||
|
||||
/*
|
||||
* Graceful is double the odds of a normal roll
|
||||
*/
|
||||
String[] gracefulRollStrings = RandomChanceUtil.calculateAbilityDisplayValuesCustom(player, SubSkillType.ACROBATICS_ROLL, 2.0D);
|
||||
//TODO: Yeah I know, ...I'm tired I'll clean it up later
|
||||
Probability probability = getRollProbability(player);
|
||||
Probability gracefulProbability = new ProbabilityImpl(probability.getValue() * 2);
|
||||
String[] gracefulRollStrings = SkillUtils.getRNGDisplayValues(gracefulProbability);
|
||||
gracefulRollChance = gracefulRollStrings[0];
|
||||
gracefulRollChanceLucky = gracefulRollStrings[1];
|
||||
|
||||
@ -162,6 +167,11 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Probability getRollProbability(Player player) {
|
||||
return SkillUtils.getSubSkillProbability(SubSkillType.ACROBATICS_ROLL, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuperAbility() {
|
||||
return false;
|
||||
@ -235,11 +245,12 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
private double gracefulRollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage, int skillLevel) {
|
||||
double modifiedDamage = calculateModifiedRollDamage(damage, AdvancedConfig.getInstance().getRollDamageThreshold() * 2);
|
||||
|
||||
SkillProbabilityWrapper rcs = new SkillProbabilityWrapper(player, subSkillType);
|
||||
rcs.setxPos(rcs.getxPos() * 2); //Double the effective odds
|
||||
double gracefulOdds = SkillUtils.getSubSkillProbability(subSkillType, player).getValue() * 2;
|
||||
Probability gracefulProbability = new ProbabilityImpl(gracefulOdds);
|
||||
|
||||
if (!isFatal(player, modifiedDamage)
|
||||
&& RandomChanceUtil.processProbabilityResults(rcs))
|
||||
//TODO: Graceful isn't sending out an event
|
||||
&& SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.ACROBATICS, player, gracefulProbability))
|
||||
{
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc");
|
||||
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS,0.5F);
|
||||
@ -352,48 +363,49 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
*/
|
||||
@Override
|
||||
public String getMechanics() {
|
||||
//Vars passed to locale
|
||||
//0 = chance to roll at half max level
|
||||
//1 = chance to roll with grace at half max level
|
||||
//2 = level where maximum bonus is reached
|
||||
//3 = additive chance to succeed per level
|
||||
//4 = damage threshold when rolling
|
||||
//5 = damage threshold when rolling with grace
|
||||
//6 = half of level where maximum bonus is reached
|
||||
/*
|
||||
Roll:
|
||||
# ChanceMax: Maximum chance of rolling when on <MaxBonusLevel> or higher
|
||||
# MaxBonusLevel: On this level or higher, the roll chance will not go higher than <ChanceMax>
|
||||
# DamageThreshold: The max damage a player can negate with a roll
|
||||
ChanceMax: 100.0
|
||||
MaxBonusLevel: 100
|
||||
DamageThreshold: 7.0
|
||||
*/
|
||||
double rollChanceHalfMax, graceChanceHalfMax, damageThreshold, chancePerLevel;
|
||||
|
||||
//Chance to roll at half max skill
|
||||
SkillProbabilityWrapper rollHalfMaxSkill = new SkillProbabilityWrapper(null, subSkillType);
|
||||
int halfMaxSkillValue = AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL)/2;
|
||||
rollHalfMaxSkill.setxPos(halfMaxSkillValue);
|
||||
|
||||
//Chance to graceful roll at full skill
|
||||
SkillProbabilityWrapper rollGraceHalfMaxSkill = new SkillProbabilityWrapper(null, subSkillType);
|
||||
rollGraceHalfMaxSkill.setxPos(halfMaxSkillValue * 2); //Double the effective odds
|
||||
|
||||
//Chance to roll per level
|
||||
SkillProbabilityWrapper rollOneSkillLevel = new SkillProbabilityWrapper(null, subSkillType);
|
||||
rollGraceHalfMaxSkill.setxPos(1); //Level 1 skill
|
||||
|
||||
//Chance Stat Calculations
|
||||
rollChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollHalfMaxSkill);
|
||||
graceChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollGraceHalfMaxSkill);
|
||||
damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
|
||||
|
||||
chancePerLevel = RandomChanceUtil.getRandomChanceExecutionChance(rollOneSkillLevel);
|
||||
|
||||
double maxLevel = AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL);
|
||||
|
||||
return LocaleLoader.getString("Acrobatics.SubSkill.Roll.Mechanics", rollChanceHalfMax, graceChanceHalfMax, maxLevel, chancePerLevel, damageThreshold, damageThreshold * 2,halfMaxSkillValue);
|
||||
return "This feature is currently not implemented but will be in the future! -mcMMO Devs";
|
||||
// //Vars passed to locale
|
||||
// //0 = chance to roll at half max level
|
||||
// //1 = chance to roll with grace at half max level
|
||||
// //2 = level where maximum bonus is reached
|
||||
// //3 = additive chance to succeed per level
|
||||
// //4 = damage threshold when rolling
|
||||
// //5 = damage threshold when rolling with grace
|
||||
// //6 = half of level where maximum bonus is reached
|
||||
// /*
|
||||
// Roll:
|
||||
// # ChanceMax: Maximum chance of rolling when on <MaxBonusLevel> or higher
|
||||
// # MaxBonusLevel: On this level or higher, the roll chance will not go higher than <ChanceMax>
|
||||
// # DamageThreshold: The max damage a player can negate with a roll
|
||||
// ChanceMax: 100.0
|
||||
// MaxBonusLevel: 100
|
||||
// DamageThreshold: 7.0
|
||||
// */
|
||||
// double rollChanceHalfMax, graceChanceHalfMax, damageThreshold, chancePerLevel;
|
||||
//
|
||||
// //Chance to roll at half max skill
|
||||
// SkillProbabilityWrapper rollHalfMaxSkill = new SkillProbabilityWrapper(null, subSkillType);
|
||||
// int halfMaxSkillValue = AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL)/2;
|
||||
// rollHalfMaxSkill.setxPos(halfMaxSkillValue);
|
||||
//
|
||||
// //Chance to graceful roll at full skill
|
||||
// SkillProbabilityWrapper rollGraceHalfMaxSkill = new SkillProbabilityWrapper(null, subSkillType);
|
||||
// rollGraceHalfMaxSkill.setxPos(halfMaxSkillValue * 2); //Double the effective odds
|
||||
//
|
||||
// //Chance to roll per level
|
||||
// SkillProbabilityWrapper rollOneSkillLevel = new SkillProbabilityWrapper(null, subSkillType);
|
||||
// rollGraceHalfMaxSkill.setxPos(1); //Level 1 skill
|
||||
//
|
||||
// //Chance Stat Calculations
|
||||
// rollChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollHalfMaxSkill);
|
||||
// graceChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollGraceHalfMaxSkill);
|
||||
// damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
|
||||
//
|
||||
// chancePerLevel = RandomChanceUtil.getRandomChanceExecutionChance(rollOneSkillLevel);
|
||||
//
|
||||
// double maxLevel = AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL);
|
||||
//
|
||||
// return LocaleLoader.getString("Acrobatics.SubSkill.Roll.Mechanics", rollChanceHalfMax, graceChanceHalfMax, maxLevel, chancePerLevel, damageThreshold, damageThreshold * 2,halfMaxSkillValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -405,26 +417,27 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
@Override
|
||||
public Double[] getStats(Player player)
|
||||
{
|
||||
double playerChanceRoll, playerChanceGrace;
|
||||
|
||||
SkillProbabilityWrapper roll = new SkillProbabilityWrapper(player, getSubSkillType());
|
||||
SkillProbabilityWrapper graceful = new SkillProbabilityWrapper(player, getSubSkillType());
|
||||
|
||||
graceful.setxPos(graceful.getxPos() * 2); //Double odds
|
||||
|
||||
//Calculate
|
||||
playerChanceRoll = RandomChanceUtil.getRandomChanceExecutionChance(roll);
|
||||
playerChanceGrace = RandomChanceUtil.getRandomChanceExecutionChance(graceful);
|
||||
|
||||
return new Double[]{ playerChanceRoll, playerChanceGrace };
|
||||
// double playerChanceRoll, playerChanceGrace;
|
||||
//
|
||||
// SkillProbabilityWrapper roll = new SkillProbabilityWrapper(player, getSubSkillType());
|
||||
// SkillProbabilityWrapper graceful = new SkillProbabilityWrapper(player, getSubSkillType());
|
||||
//
|
||||
// graceful.setxPos(graceful.getxPos() * 2); //Double odds
|
||||
//
|
||||
// //Calculate
|
||||
// playerChanceRoll = RandomChanceUtil.getRandomChanceExecutionChance(roll);
|
||||
// playerChanceGrace = RandomChanceUtil.getRandomChanceExecutionChance(graceful);
|
||||
//
|
||||
// return new Double[]{ playerChanceRoll, playerChanceGrace };
|
||||
return new Double[] {0.0, 0.0};
|
||||
}
|
||||
|
||||
public void addFallLocation(Player player)
|
||||
public void addFallLocation(@NotNull Player player)
|
||||
{
|
||||
UserManager.getPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player));
|
||||
}
|
||||
|
||||
public Location getBlockLocation(Player player)
|
||||
public @NotNull Location getBlockLocation(@NotNull Player player)
|
||||
{
|
||||
return player.getLocation().getBlock().getLocation();
|
||||
}
|
||||
|
@ -1,47 +1,41 @@
|
||||
package com.gmail.nossr50.events.skills.secondaryabilities;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SubSkillRandomCheckEvent extends SubSkillEvent {
|
||||
private double chance;
|
||||
|
||||
public SubSkillRandomCheckEvent(Player player, SubSkillType ability, double chance) {
|
||||
super(player, ability);
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
public SubSkillRandomCheckEvent(Player player, AbstractSubSkill abstractSubSkill, double chance)
|
||||
{
|
||||
super(player, abstractSubSkill);
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the activation chance of the ability 0D being no chance, 100.0D being 100% chance
|
||||
*
|
||||
* @return The activation chance of the ability
|
||||
*/
|
||||
public double getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the activation chance of the ability [0D-100.0D]
|
||||
*
|
||||
* @param chance The activation chance of the ability
|
||||
*/
|
||||
public void setChance(double chance) {
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the activation chance of the ability to 100% or 0%
|
||||
*
|
||||
* @param success whether it should be successful or not
|
||||
*/
|
||||
public void setSuccessful(boolean success) {
|
||||
this.chance = success ? 100.0D : 0D;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.skills.secondaryabilities;
|
||||
//
|
||||
//import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
//import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
//import org.bukkit.entity.Player;
|
||||
//
|
||||
//public class SubSkillRandomCheckEvent extends SubSkillEvent {
|
||||
// private double chance;
|
||||
//
|
||||
// public SubSkillRandomCheckEvent(Player player, SubSkillType ability, double chance) {
|
||||
// super(player, ability);
|
||||
// this.chance = chance;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets the activation chance of the ability 0D being no chance, 100.0D being 100% chance
|
||||
// *
|
||||
// * @return The activation chance of the ability
|
||||
// */
|
||||
// public double getChance() {
|
||||
// return chance;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Sets the activation chance of the ability [0D-100.0D]
|
||||
// *
|
||||
// * @param chance The activation chance of the ability
|
||||
// */
|
||||
// public void setChance(double chance) {
|
||||
// this.chance = chance;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Sets the activation chance of the ability to 100% or 0%
|
||||
// *
|
||||
// * @param success whether it should be successful or not
|
||||
// */
|
||||
// public void setSuccessful(boolean success) {
|
||||
// this.chance = success ? 100.0D : 0D;
|
||||
// }
|
||||
//}
|
||||
|
@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Location;
|
||||
@ -44,7 +43,7 @@ public class ExcavationManager extends SkillManager {
|
||||
&& SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.EXCAVATION, getPlayer(), treasure.getDropProbability())) {
|
||||
|
||||
//Spawn Vanilla XP orbs if a dice roll succeeds
|
||||
if(RandomChanceUtil.rollDice(getArchaelogyExperienceOrbChance(), 100)) {
|
||||
if(SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.EXCAVATION, getPlayer(), getArchaelogyExperienceOrbChance())) {
|
||||
Misc.spawnExperienceOrb(location, getExperienceOrbsReward());
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ import com.gmail.nossr50.runnables.skills.DelayedHerbalismXPCheckTask;
|
||||
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.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
@ -621,7 +620,7 @@ public class HerbalismManager extends SkillManager {
|
||||
|
||||
for (HylianTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel()
|
||||
&& RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(treasure.getDropChance(), getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))) {
|
||||
&& SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.HERBALISM, player, treasure.getDropChance())) {
|
||||
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
|
||||
return false;
|
||||
}
|
||||
@ -740,7 +739,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!greenTerra && !RandomChanceUtil.checkRandomChanceExecutionSuccess(player, SubSkillType.HERBALISM_GREEN_THUMB, true)) {
|
||||
if (!greenTerra && !SkillUtils.isSkillRNGSuccessful(SubSkillType.HERBALISM_GREEN_THUMB, player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
||||
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.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
@ -114,7 +113,7 @@ public class MiningManager extends SkillManager {
|
||||
|
||||
private boolean processTripleDrops(@NotNull BlockState blockState) {
|
||||
//TODO: Make this readable
|
||||
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_MOTHER_LODE, true)) {
|
||||
if (SkillUtils.isSkillRNGSuccessful(SubSkillType.MINING_MOTHER_LODE, getPlayer())) {
|
||||
BlockUtils.markDropsAsBonus(blockState, 2);
|
||||
return true;
|
||||
} else {
|
||||
@ -124,7 +123,7 @@ public class MiningManager extends SkillManager {
|
||||
|
||||
private void processDoubleDrops(@NotNull BlockState blockState) {
|
||||
//TODO: Make this readable
|
||||
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS, true)) {
|
||||
if (SkillUtils.isSkillRNGSuccessful(SubSkillType.MINING_DOUBLE_DROPS, getPlayer())) {
|
||||
boolean useTriple = mmoPlayer.getAbilityMode(skill.getAbility()) && AdvancedConfig.getInstance().getAllowMiningTripleDrops();
|
||||
BlockUtils.markDropsAsBonus(blockState, useTriple);
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
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;
|
||||
@ -340,10 +339,10 @@ public class RepairManager extends SkillManager {
|
||||
|
||||
Enchantment enchantment = enchant.getKey();
|
||||
|
||||
if (RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(getKeepEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING))) {
|
||||
if (SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.REPAIR, getPlayer(), getKeepEnchantChance())) {
|
||||
|
||||
if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1
|
||||
&& (!RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(100 - getDowngradeEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING)))) {
|
||||
&& (!SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.REPAIR, getPlayer(), 100 - getDowngradeEnchantChance()))) {
|
||||
item.addUnsafeEnchantment(enchantment, enchantLevel - 1);
|
||||
downgraded = true;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
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;
|
||||
@ -122,7 +121,7 @@ public class SalvageManager extends SkillManager {
|
||||
|
||||
for(int x = 0; x < potentialSalvageYield-1; x++) {
|
||||
|
||||
if(RandomChanceUtil.rollDiceSimple(chanceOfSuccess, 100)) {
|
||||
if(SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.SALVAGE, player, chanceOfSuccess)) {
|
||||
chanceOfSuccess-=3;
|
||||
chanceOfSuccess = Math.max(chanceOfSuccess, 90);
|
||||
|
||||
@ -252,12 +251,12 @@ public class SalvageManager extends SkillManager {
|
||||
|
||||
if (!Salvage.arcaneSalvageEnchantLoss
|
||||
|| Permissions.hasSalvageEnchantBypassPerk(player)
|
||||
|| RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
|
||||
|| SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.SALVAGE, player, getExtractFullEnchantChance())) {
|
||||
enchantMeta.addStoredEnchant(enchant.getKey(), enchantLevel, true);
|
||||
}
|
||||
else if (enchantLevel > 1
|
||||
&& Salvage.arcaneSalvageDowngrades
|
||||
&& RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(getExtractPartialEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
|
||||
&& SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.SALVAGE, player, getExtractPartialEnchantChance())) {
|
||||
enchantMeta.addStoredEnchant(enchant.getKey(), enchantLevel - 1, true);
|
||||
downgraded = true;
|
||||
} else {
|
||||
|
@ -18,7 +18,6 @@ import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@ -275,7 +274,7 @@ public class TamingManager extends SkillManager {
|
||||
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL))
|
||||
return;
|
||||
|
||||
if(!RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL)))
|
||||
if(!SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.TAMING, getPlayer(), AdvancedConfig.getInstance().getPummelChance()))
|
||||
return;
|
||||
|
||||
ParticleEffectUtils.playGreaterImpactEffect(target);
|
||||
|
@ -14,7 +14,6 @@ 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;
|
||||
|
@ -8,7 +8,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -52,9 +52,9 @@ public final class BlockUtils {
|
||||
* @param blockState the blockstate
|
||||
* @return true if the player succeeded in the check
|
||||
*/
|
||||
public static boolean checkDoubleDrops(Player player, BlockState blockState, PrimarySkillType skillType, SubSkillType subSkillType) {
|
||||
public static boolean checkDoubleDrops(@NotNull Player player, @NotNull BlockState blockState, @NotNull PrimarySkillType skillType, @NotNull SubSkillType subSkillType) {
|
||||
if (Config.getInstance().getDoubleDropsEnabled(skillType, blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) {
|
||||
return RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapper(player, subSkillType, true));
|
||||
return SkillUtils.isSkillRNGSuccessful(subSkillType, player);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -16,7 +16,7 @@ public class ProbabilityFactory {
|
||||
|
||||
public static @NotNull Probability ofSubSkill(@Nullable Player player,
|
||||
@NotNull SubSkillType subSkillType,
|
||||
@NotNull SkillProbabilityType skillProbabilityType) throws InvalidStaticChance, RuntimeException {
|
||||
@NotNull SkillProbabilityType skillProbabilityType) {
|
||||
|
||||
switch (skillProbabilityType) {
|
||||
case DYNAMIC_CONFIGURABLE:
|
||||
@ -40,7 +40,11 @@ public class ProbabilityFactory {
|
||||
xCeiling = AdvancedConfig.getInstance().getMaxBonusLevel(subSkillType);
|
||||
return new ProbabilityImpl(xPos, xCeiling, probabilityCeiling);
|
||||
case STATIC_CONFIGURABLE:
|
||||
try {
|
||||
return ofPercentageValue(getStaticRandomChance(subSkillType));
|
||||
} catch (InvalidStaticChance invalidStaticChance) {
|
||||
invalidStaticChance.printStackTrace();
|
||||
}
|
||||
default:
|
||||
throw new RuntimeException("No case in switch statement for Skill Probability Type!");
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import java.text.DecimalFormat;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
//TODO: Normalize chance values
|
||||
//TODO: Test the 2 types of SkillProbabilityTypes
|
||||
//TODO: Update calls to this class and its members
|
||||
public class RandomChanceUtil {
|
||||
public static final @NotNull DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
@ -57,8 +56,7 @@ public class RandomChanceUtil {
|
||||
*
|
||||
* @return "percentage" representation of success
|
||||
*/
|
||||
private static double chanceOfSuccessPercentage(@NotNull Player player, @NotNull SubSkillType subSkillType, boolean isLucky) {
|
||||
try {
|
||||
public static double chanceOfSuccessPercentage(@NotNull Player player, @NotNull SubSkillType subSkillType, boolean isLucky) {
|
||||
Probability probability = SkillUtils.getSubSkillProbability(subSkillType, player);
|
||||
//Probability values are on a 0-1 scale and need to be "transformed" into a 1-100 scale
|
||||
double percentageValue = probability.getValue() * 100;
|
||||
@ -69,10 +67,18 @@ public class RandomChanceUtil {
|
||||
}
|
||||
|
||||
return percentageValue;
|
||||
} catch (InvalidStaticChance invalidStaticChance) {
|
||||
invalidStaticChance.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double chanceOfSuccessPercentage(@NotNull Probability probability, boolean isLucky) {
|
||||
//Probability values are on a 0-1 scale and need to be "transformed" into a 1-100 scale
|
||||
double percentageValue = probability.getValue() * 100;
|
||||
|
||||
//Apply lucky modifier
|
||||
if(isLucky) {
|
||||
percentageValue *= LUCKY_MODIFIER;
|
||||
}
|
||||
|
||||
return percentageValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -358,7 +358,6 @@ public final class SkillUtils {
|
||||
* @return true if the Skill RNG succeeds, false if it fails
|
||||
*/
|
||||
public static boolean isSkillRNGSuccessful(@NotNull SubSkillType subSkillType, @NotNull Player player) {
|
||||
try {
|
||||
//Process probability
|
||||
Probability probability = getSubSkillProbability(subSkillType, player);
|
||||
|
||||
@ -384,12 +383,6 @@ public final class SkillUtils {
|
||||
} else {
|
||||
return RandomChanceUtil.processProbability(probability);
|
||||
}
|
||||
|
||||
} catch (RuntimeException | InvalidStaticChance e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -446,7 +439,7 @@ public final class SkillUtils {
|
||||
* @throws InvalidStaticChance when a skill that does not have a hard coded static chance and it is asked for
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static @NotNull Probability getSubSkillProbability(@NotNull SubSkillType subSkillType, @Nullable Player player) throws InvalidStaticChance, RuntimeException {
|
||||
public static @NotNull Probability getSubSkillProbability(@NotNull SubSkillType subSkillType, @Nullable Player player) {
|
||||
SkillProbabilityType skillProbabilityType = SkillProbabilityType.DYNAMIC_CONFIGURABLE;
|
||||
|
||||
if(subSkillType == SubSkillType.TAMING_FAST_FOOD_SERVICE || subSkillType == SubSkillType.AXES_ARMOR_IMPACT || subSkillType == SubSkillType.AXES_GREATER_IMPACT)
|
||||
@ -454,4 +447,18 @@ public final class SkillUtils {
|
||||
|
||||
return ProbabilityFactory.ofSubSkill(player, subSkillType, skillProbabilityType);
|
||||
}
|
||||
|
||||
public static @NotNull String[] getRNGDisplayValues(@NotNull Player player, @NotNull SubSkillType subSkill) {
|
||||
double firstValue = RandomChanceUtil.chanceOfSuccessPercentage(player, subSkill, false);
|
||||
double secondValue = RandomChanceUtil.chanceOfSuccessPercentage(player, subSkill, true);
|
||||
|
||||
return new String[]{RandomChanceUtil.percent.format(firstValue), RandomChanceUtil.percent.format(secondValue)};
|
||||
}
|
||||
|
||||
public static @NotNull String[] getRNGDisplayValues(@NotNull Probability probability) {
|
||||
double firstValue = RandomChanceUtil.chanceOfSuccessPercentage(probability, false);
|
||||
double secondValue = RandomChanceUtil.chanceOfSuccessPercentage(probability, true);
|
||||
|
||||
return new String[]{RandomChanceUtil.percent.format(firstValue), RandomChanceUtil.percent.format(secondValue)};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user