Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void sendDropRates_new(int npcId) {
- Drop[] drops = NPCDrops.getDrops(npcId);
- if (drops == null) {
- player.sendMessage("This NPC has no Drops");
- return;
- }
- int NPCID = npcId;
- Drop[] possibleDrops = new Drop[drops.length];
- int possibleDropsCount = 0;
- int[] Rollvars = { 10, 25, 40, 50 };
- int Count_of_100s = 0;
- for (int i = 0; i < drops.length; i++) {
- if (drops[i].getRate() == 100) {
- Count_of_100s++;
- }
- }
- int[] Drops = new int[drops.length - Count_of_100s];
- if (Drops.length >= 1 && Drops.length <= 15) {
- int[] DropsMinAmount = new int[drops.length - Count_of_100s];
- int[] DropsMaxAmount = new int[drops.length - Count_of_100s];
- int[] GuaranteedDrops = new int[Count_of_100s];
- int[] GuaranteedDropsMinAmount = new int[Count_of_100s];
- int[] GuaranteedDropsMaxAmount = new int[Count_of_100s];
- double[] Chances = new double[Drops.length];
- double[] TrueChances = new double[Drops.length];
- double[] RealTrueChances = new double[Drops.length];
- double KillerDropRate = player.getEquipment().getDropRate();
- int I = 0;
- for (int i = 0; i < drops.length; i++) {
- if (drops[i].getRate() != 100) {
- Drops[i - I] = drops[i].getItemId();
- Chances[i - I] = drops[i].getRate();
- DropsMinAmount[i - I] = drops[i].getMinAmount();
- DropsMaxAmount[i - I] = drops[i].getMaxAmount();
- } else {
- GuaranteedDrops[I] = drops[i].getItemId();
- GuaranteedDropsMinAmount[I] = drops[i].getMinAmount();
- GuaranteedDropsMaxAmount[I] = drops[i].getMaxAmount();
- I++;
- }
- }
- for (int i = 0; i < Drops.length; i++) {
- if (Chances[i] > 1.0 && Chances[i] < 100) {
- TrueChances[i] = (Chances[i] + 4 + KillerDropRate) / (99) > 1 ? 1
- : (Chances[i] + 4 + KillerDropRate) / (99);
- } else if (Chances[i] > 0.5 && Chances[i] <= 1.0) {
- TrueChances[i] = (Chances[i] + 4 + KillerDropRate) / (Rollvars[0] * 99);
- } else if (Chances[i] >= 0.3 && Chances[i] <= 0.5) {
- TrueChances[i] = (Chances[i] + 4 + KillerDropRate) / (Rollvars[1] * 99);
- } else if (Chances[i] == 0.2) {
- TrueChances[i] = (Chances[i] + 4 + KillerDropRate) / (Rollvars[2] * 99);
- } else if (Chances[i] == 0.1) {
- TrueChances[i] = (Chances[i] + 4 + KillerDropRate) / (Rollvars[3] * 99);
- }
- }
- double[] Multipliers;
- int n = Drops.length;
- int len = (int) Math.pow(2, n);
- String[][] BinaryNumbers = new String[len][];
- int[] DummyArray = new int[n];
- int[][] BinaryNumbersInt = new int[len][];
- for (int count = 0; count < len; count++) {
- BinaryNumbers[count] = String.format("%" + n + "s", Integer.toBinaryString(count)).replace((" "), ("0"))
- .split("");
- for (int i = 0; i < n; i++) {
- DummyArray[i] = Integer.parseInt(BinaryNumbers[count][i]);
- }
- BinaryNumbersInt[count] = Arrays.copyOf(DummyArray, DummyArray.length);
- }
- int NumberArray[];
- int CountArray[];
- int AmountOfZeros = 0;
- double Product = 1;
- for (int i = 0; i < len; i++) {
- AmountOfZeros = 0;
- Multipliers = Arrays.copyOf(TrueChances, TrueChances.length);
- NumberArray = BinaryNumbersInt[i];
- // System.out.println(NumberArray.length);
- Product = 1;
- for (int IDK = 0; IDK < n; IDK++) {
- // System.out.println(NumberArray[IDK] + " num");
- if (NumberArray[IDK] == 0) {
- AmountOfZeros++;
- }
- }
- if (AmountOfZeros != 0) {
- Product *= 1.0 / AmountOfZeros;
- for (int Integer = 0; Integer < NumberArray.length; Integer++) {
- Product *= Math.abs(NumberArray[Integer] - Multipliers[Integer]);
- // System.out.println(Product);
- }
- for (int JK = 0; JK < NumberArray.length; JK++) {
- RealTrueChances[JK] += (NumberArray[JK] * -1 + 1) * Product;
- // System.out.println(TrueChances[JK] + " Goes to " + RealTrueChances[JK]);
- }
- }
- }
- /*
- *
- *
- * player.getPackets().sendItemOnIComponent(inter, 24 + i, drops[i].getItemId(),
- * 1); player.getPackets().sendIComponentText(inter, 49 + i,
- * itemDefs.getName()); player.getPackets().sendIComponentText(inter, 64 + i, ""
- * + drops[i].getRate() + "%");
- *
- *
- */
- /*
- * for (int j = 0; j < Drops.length; j++) { ItemDefinitions itemDefs =
- * ItemDefinitions.getItemDefinitions(drops[j].getItemId()); double doubleValue
- * = BigDecimal.valueOf((RealTrueChances[j] * 100)).setScale(3,
- * RoundingMode.HALF_UP) .doubleValue(); player.sm(itemDefs.getName() + "-" +
- * doubleValue + "%");
- *
- *
- *
- * }
- */
- player.getInterfaceManager().sendInterface(1265);
- NPCDefinitions defs = NPCDefinitions.getNPCDefinitions(npcId);
- if (drops == null) {
- player.sendMessage("This NPC has no Drops");
- return;
- }
- player.getPackets().sendIComponentText(1265, 48, "Drops from : " + defs.name);
- for (int i = 0; i < Drops.length; i++) {
- ItemDefinitions itemDefs = ItemDefinitions.getItemDefinitions(drops[i].getItemId());
- String amount = "";
- if (itemDefs.isStackable()) {
- amount = drops[i].getMinAmount() + "-" + drops[i].getMaxAmount();
- } else {
- amount = "1";
- }
- player.getPackets().sendItemOnIComponent(1265, 24 + i, drops[i].getItemId(), 1);
- player.getPackets().sendIComponentText(1265, 49 + i, itemDefs.getName());
- player.getPackets().sendIComponentText(1265, 64 + i + Count_of_100s,
- BigDecimal.valueOf((RealTrueChances[i] * 100)).setScale(3, RoundingMode.HALF_UP).doubleValue()
- + "%");
- player.getPackets().sendIComponentText(1265, 79 + i, "" + amount);
- }
- for (int i = Drops.length; i < 15; i++) {
- player.getPackets().sendItemOnIComponent(1265, 24 + i, -2, 1);
- player.getPackets().sendIComponentText(1265, 49 + i, "");
- player.getPackets().sendIComponentText(1265, 64 + i + Count_of_100s, "");
- player.getPackets().sendIComponentText(1265, 79 + i, "");
- }
- }
- else {
- player.sm("Error opening drops,please resport to the Developer");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement