Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.15 KB | None | 0 0
  1. package com.Flenarn;
  2.  
  3. import java.util.concurrent.ThreadLocalRandom;
  4.  
  5.  
  6. /**
  7.  * Holds droptable logic, info stored in XML.
  8.  * @author Flenarn
  9.  */
  10.  
  11. public class Main {
  12.  
  13.     public static void main(String[] args) {
  14.  
  15.         System.out.println("=== Drop Table Rework 0.1 ===");
  16.         System.out.println("Logic created and developed by Flenarn.");
  17.         System.out.println("System split up into several rolls, constants and the like");
  18.         System.out.println("Later revisions will fetch data from XML document.");
  19.         System.out.println("Currently NPC IDs are randomized from 1 - 10.");
  20.         System.out.println("Every other ID (1,3,5,7,9) currently is set to contain a constant drop.");
  21.         System.out.println("Rare/Gem Drop Table effected by Ring of Wealth, reducing max number by 25%.");
  22.         System.out.println("Makes use of \"ThreadLocalRandom\" instead of default Javas default Random util to greatly increase performance.");
  23.         System.out.println(" ");
  24.  
  25.         /**
  26.          * NPC ID Randomization
  27.          */
  28.  
  29.  
  30.         int NPCIDmax = 10;
  31.         int NPCID = ThreadLocalRandom.current().nextInt(1, NPCIDmax + 1);
  32.  
  33.         /**
  34.          * Value organization for later calls
  35.          */
  36.  
  37.         int RareRollmax = 128; //Default to 128, 96 if Ring of Wealth is available.
  38.  
  39.         int GemRollmax = 128; //Default to 128, 96 if Ring of Wealth is available.
  40.  
  41.         int MegaRollmax = 10; //Dynamic based on population of loot table.
  42.  
  43.         /**
  44.          * Ring Of Wealth Randomization
  45.          */
  46.  
  47.         System.out.println(" === Ring of Wealth Configuration ===");
  48.  
  49.         int RingOfWealth = 1; //On/Off, information will be fetched from server later.
  50.  
  51.         if (RingOfWealth <= 1) {
  52.             RareRollmax = (RareRollmax/4)*3;
  53.             GemRollmax = (GemRollmax/4)*3;
  54.             System.out.println("Ring Of Wealth = True");
  55.             System.out.println(" ");
  56.         } else {
  57.             System.out.println("Ring of Wealth = False");
  58.             System.out.println(" ");
  59.         }
  60.  
  61.         System.out.println(" === NPC Configuration ===");
  62.         System.out.println("NPC ID: " + NPCID);
  63.         System.out.println(" ");
  64.  
  65.         /**
  66.          * Always Drop Configuration
  67.          */
  68.  
  69.         int AlwaysDrop;
  70.         int QuestDrop;
  71.         int NPCAlwaysID;
  72.         int NPCQuestID;
  73.  
  74.         //NPCs with constant drops  - will be fetched from XML.
  75.         if (NPCID == 1 | NPCID == 3 | NPCID == 5 | NPCID == 7 | NPCID == 9) {
  76.             AlwaysDrop = 1;
  77.             System.out.println("=== Constant Drop Configuration ===");
  78.             System.out.println("Constant drop: True");
  79.         } else {
  80.             AlwaysDrop = 0;
  81.             System.out.println("=== Constant Drop Configuration ===");
  82.             System.out.println("Constant drop: False");
  83.             System.out.println(" ");
  84.         }
  85.  
  86.         if (NPCID == 1 | NPCID == 9) {
  87.             NPCAlwaysID = 1; //Bones
  88.         } else if (NPCID == 3 | NPCID == 7) {
  89.             NPCAlwaysID = 2; //Dragon Bones
  90.         } else if (NPCID == 5) {
  91.             NPCAlwaysID = 3; //Slime Spores
  92.         } else {
  93.             NPCAlwaysID = 0;
  94.         }
  95.  
  96.         if (AlwaysDrop == 1) {
  97.             if (NPCAlwaysID == 1) {
  98.                 System.out.println("Dropped: Bones");
  99.             } else if (NPCAlwaysID == 2) {
  100.                 System.out.println("Dropped: Dragon Bones");
  101.             } else if (NPCAlwaysID == 3) {
  102.                 System.out.println("Dropped: Slime Spores");
  103.             }
  104.  
  105.             //Randomizing the amount on constant drops, min and max will be fetched from XML later.
  106.             int AlwaysAmountmax = 10;
  107.             int AlwaysAmountmin = 1;
  108.  
  109.             int AlwaysAmount = ThreadLocalRandom.current().nextInt(AlwaysAmountmin, AlwaysAmountmax + 1);
  110.             System.out.println("Amount: " + AlwaysAmount);
  111.             System.out.println(" ");
  112.  
  113.             /**
  114.              *  Quest Drop Configuration
  115.              */
  116.  
  117.             System.out.println("=== Quest Drop Configuration ===");
  118.  
  119.             //NPCs with quest drops - will be fetched from XML.
  120.             if (NPCID == 2 | NPCID == 4 | NPCID == 6) {
  121.                 QuestDrop = 1;
  122.                 System.out.println("Quest Drop: True");
  123.             } else {
  124.                 QuestDrop = 0;
  125.                 System.out.println("Quest Drop: False");
  126.                 System.out.println(" ");
  127.             }
  128.  
  129.             if (NPCID == 2) {
  130.                 NPCQuestID = 1; //Seeds
  131.             } else if (NPCID == 4) {
  132.                 NPCQuestID = 2; //Sacred Book
  133.             } else if (NPCID == 6) {
  134.                 NPCQuestID = 3; //Magic Logs
  135.             } else {
  136.                 NPCQuestID = 0;
  137.             }
  138.  
  139.             if (QuestDrop == 1) {
  140.                 if (NPCQuestID == 1) {
  141.                     System.out.println("");
  142.                 }
  143.             }
  144.  
  145.             /**
  146.              * Main Roll
  147.              */
  148.  
  149.             int MainRollmax = 16; //Default to 128, can be overwritten by XML value.
  150.  
  151.             int MainRoll = ThreadLocalRandom.current().nextInt(1, MainRollmax + 1);
  152.  
  153.             System.out.println(" === Main Roll Configuration ===");
  154.             System.out.println(MainRoll + "/" + MainRollmax);
  155.  
  156.             if (MainRoll == 1) {
  157.                 System.out.println("Rare Drop Table Accessed!");
  158.                 System.out.println(" ");
  159.  
  160.                 /**
  161.                  * Rare Roll Configuration
  162.                  */
  163.  
  164.                 System.out.println(" === Rare Roll Configuration ===");
  165.  
  166.                 int RareRoll = ThreadLocalRandom.current().nextInt(1, RareRollmax + 1);
  167.                 System.out.println(RareRoll + "/" + RareRollmax);
  168.  
  169.                 if (RareRoll <= 20) {
  170.                     System.out.println("Gem Drop Table Accessed!");
  171.                     System.out.println(" ");
  172.  
  173.                     /**
  174.                      * Gem Roll Configuration
  175.                      */
  176.  
  177.                     System.out.println("=== Gem Roll Configuration ===");
  178.  
  179.                     int GemRoll = ThreadLocalRandom.current().nextInt(1, GemRollmax + 1);
  180.                     System.out.println(GemRoll + "/" + GemRollmax);
  181.  
  182.                     if (GemRoll == 1) {
  183.                         System.out.println("Mega Rare Drop Table Accessed!");
  184.                         System.out.println(" ");
  185.  
  186.                         /**
  187.                          * Mega Rare Roll Configuration
  188.                          */
  189.  
  190.                         System.out.println("=== Mega Rare Roll Configuration ===");
  191.  
  192.                         //Clue Scroll Roll
  193.                         int ClueRoll = ThreadLocalRandom.current().nextInt(1, 351 + 1);
  194.                         System.out.println(ClueRoll + "/" + 351);
  195.  
  196.                         if (ClueRoll == 1) {
  197.                             System.out.println("Clue Scroll Drop Table Accessed!");
  198.                             System.out.println(" ");
  199.  
  200.                             /**
  201.                              * Clue Scroll Configuration
  202.                              */
  203.  
  204.                             System.out.println("=== Clue Scroll Drop Configuration ===");
  205.  
  206.                             int ClueNR = ThreadLocalRandom.current().nextInt(1, 10 + 1);
  207.                             if (ClueNR <= 8) {
  208.                                 System.out.println("A normal clue scroll has fallen to the ground!");
  209.                             } else {
  210.                                 System.out.println("A rare clue scroll has fallen to the ground!");
  211.                             }
  212.                         }
  213.                     }
  214.                 }
  215.  
  216.             } else {
  217.                 System.out.println("Standard Drop Table Accessed!");
  218.  
  219.                 //Push to Array
  220.  
  221.                 int[] Mainlist;
  222.  
  223.                 int Weight2 = 565; //565 - Blood Rune
  224.                 int Weight3 = 556; //556 - Air Rune
  225.                 int Weight4 = 440; //440 - Iron Ore
  226.                 int Weight5 = 377; //377 - Raw Lobster
  227.                 int Weight6 = 7936; //7936 - Pure Essence
  228.                 int Weight7 = 1513; //1513 - Magic Logs
  229.  
  230.                 Mainlist = new int[17];
  231.  
  232.                 Mainlist[0] = 0; //Null Array Listing
  233.                 //Mainlist[1] = Rare Drop Table, Null Array Listing
  234.                 Mainlist[2] = Weight2;
  235.                 Mainlist[3] = Weight3;
  236.                 Mainlist[4] = Weight4;
  237.                 Mainlist[5] = Weight5;
  238.                 Mainlist[6] = Weight6;
  239.                 Mainlist[7] = Weight7;
  240.                 /*Mainlist[8] = "385 - Shark";
  241.                 Mainlist[9] = "311 - Harpoon";
  242.                 Mainlist[10] = "995 - Coins";
  243.                 Mainlist[11] = "1089 - Black Plateskirt";
  244.                 Mainlist[12] = "8784 - Gold leaf";
  245.                 Mainlist[13] = "10721 - Frog mask";
  246.                 Mainlist[14] = "1739 - Cowhide";
  247.                 Mainlist[15] = "1617 - Uncut Diamond";
  248.                 Mainlist[16] = "863 - Iron knife"; */
  249.  
  250.                 if (MainRoll > 0) {
  251.                     System.out.println("Item ID & name: " + Mainlist[MainRoll]);
  252.  
  253.                 }
  254.  
  255.                 System.out.println(Mainlist[4]);
  256.  
  257.             }
  258.  
  259.         }
  260.     }
  261. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement