forked from Upstream/mmocore
Debug profession & chance stat
This commit is contained in:
parent
9454302f4a
commit
cb84d26735
@ -6,6 +6,7 @@ import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.loot.LootBuilder;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public abstract class DropItem {
|
||||
protected static final Random random = new Random();
|
||||
@ -13,6 +14,8 @@ public abstract class DropItem {
|
||||
private final double chance, weight;
|
||||
private final RandomAmount amount;
|
||||
|
||||
private static final double CHANCE_COEFFICIENT = 7. / 100;
|
||||
|
||||
public DropItem(MMOLineConfig config) {
|
||||
chance = config.args().length > 0 ? Double.parseDouble(config.args()[0]) : 1;
|
||||
amount = config.args().length > 1 ? new RandomAmount(config.args()[1]) : new RandomAmount(1, 1);
|
||||
@ -35,11 +38,21 @@ public abstract class DropItem {
|
||||
return amount.calculateInt();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* CHANCE stat = 0 | tier chances are unchanged
|
||||
* CHANCE stat = +inf | uniform law for any drop item
|
||||
* CHANCE stat = 100 | all tier chances are taken their square root
|
||||
*
|
||||
* @return The real weight of an item considering the player's CHANCE stat.
|
||||
*/
|
||||
/**
|
||||
* If the player chance is 0 the random value will remain the same. When he get lucks the chance gets closer to one.
|
||||
*/
|
||||
public boolean rollChance(PlayerData player) {
|
||||
return Math.pow(random.nextDouble(), 1 / Math.log(1 + player.getStats().getStat("CHANCE"))) < chance;
|
||||
double value=random.nextDouble();
|
||||
return value< Math.pow(chance, 1 / Math.pow(1 + CHANCE_COEFFICIENT * player.getStats().getStat("CHANCE"), 1.0 / 3.0));
|
||||
}
|
||||
|
||||
public abstract void collect(LootBuilder builder);
|
||||
|
@ -138,6 +138,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user