forked from Upstream/mmocore
Little modifications to the chance system. Potential fix of a bug about fishing drop tables.
This commit is contained in:
parent
5cf1505a8d
commit
2adca395c0
@ -17,6 +17,7 @@ public class RandomWeightedRoll<T extends Weighted> {
|
||||
private final T rolled;
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
private static final double CHANCE_COEFFICIENT = 7. / 100;
|
||||
|
||||
public RandomWeightedRoll(PlayerData player, Collection<T> collection, double chanceWeight) {
|
||||
this.collection = collection;
|
||||
@ -26,13 +27,13 @@ public class RandomWeightedRoll<T extends Weighted> {
|
||||
|
||||
for (T item : collection) {
|
||||
partialSum += computeRealWeight(item, chance);
|
||||
if (partialSum > randomCoefficient * sum) {
|
||||
if (partialSum >= randomCoefficient * sum) {
|
||||
rolled = item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("Could not roll item");
|
||||
throw new RuntimeException("Could not roll item, the chance is :"+chance);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +54,6 @@ public class RandomWeightedRoll<T extends Weighted> {
|
||||
return sum;
|
||||
}
|
||||
|
||||
private static final double CHANCE_COEFFICIENT = 7. / 100;
|
||||
|
||||
/**
|
||||
* chance = 0 | tier chances are unchanged
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmocore.loot.droptable.dropitem;
|
||||
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
|
||||
import net.Indyuce.mmocore.loot.LootBuilder;
|
||||
@ -46,7 +47,7 @@ public abstract class DropItem {
|
||||
*/
|
||||
public boolean rollChance(PlayerData player) {
|
||||
double value = random.nextDouble();
|
||||
return value < Math.pow(chance, 1 / Math.pow(1 + CHANCE_COEFFICIENT * player.getStats().getStat("CHANCE"), 1.0 / 3.0));
|
||||
return value < Math.pow(chance, 1 / Math.pow(1 + CHANCE_COEFFICIENT * MMOCore.plugin.configManager.dropItemsChanceWeight* player.getStats().getStat("CHANCE"), 1.0 / 3.0));
|
||||
}
|
||||
|
||||
public abstract void collect(LootBuilder builder);
|
||||
|
@ -26,7 +26,7 @@ public class ConfigManager {
|
||||
public String partyChatPrefix, noSkillBoundPlaceholder;
|
||||
public ChatColor staminaFull, staminaHalf, staminaEmpty;
|
||||
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
|
||||
public double lootChestsChanceWeight, fishingDropsChanceWeight, partyMaxExpSplitRange;
|
||||
public double lootChestsChanceWeight,dropItemsChanceWeight, fishingDropsChanceWeight, partyMaxExpSplitRange;
|
||||
public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills, waypointWarpTime;
|
||||
|
||||
private final FileConfiguration messages;
|
||||
@ -111,6 +111,7 @@ public class ConfigManager {
|
||||
globalSkillCooldown = MMOCore.plugin.getConfig().getLong("global-skill-cooldown") * 50;
|
||||
noSkillBoundPlaceholder = getSimpleMessage("no-skill-placeholder").message();
|
||||
lootChestsChanceWeight = MMOCore.plugin.getConfig().getDouble("chance-stat-weight.loot-chests");
|
||||
dropItemsChanceWeight = MMOCore.plugin.getConfig().getDouble("chance-stat-weight.drop-items");
|
||||
fishingDropsChanceWeight = MMOCore.plugin.getConfig().getDouble("chance-stat-weight.fishing-drops");
|
||||
maxPartyLevelDifference = MMOCore.plugin.getConfig().getInt("party.max-level-difference");
|
||||
partyMaxExpSplitRange = MMOCore.plugin.getConfig().getDouble("party.max-exp-split-range");
|
||||
|
@ -79,6 +79,7 @@ guild-plugin: mmocore
|
||||
chance-stat-weight:
|
||||
loot-chests: 1
|
||||
fishing-drops: 1
|
||||
drop-items: 1
|
||||
|
||||
# Whether blocks generated with a "cobblegenerator" should
|
||||
# provide the player with experience points or not
|
||||
|
Loading…
Reference in New Issue
Block a user