Advertisement
mnchngrngs

randomizer stat spread

Aug 7th, 2022
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. public void randomizeStatsWithinBST(Random random) {
  2. if (number == Species.shedinja) {
  3. // Shedinja is horribly broken unless we restrict him to 1HP.
  4. int bst = bst() - 51;
  5.  
  6. // Make weightings
  7. double atkW = random.nextDouble(), defW = random.nextDouble();
  8. double spaW = random.nextDouble(), spdW = random.nextDouble(), speW = random.nextDouble();
  9.  
  10. double totW = atkW + defW + spaW + spdW + speW;
  11.  
  12. hp = 1;
  13. attack = (int) Math.max(1, Math.round(atkW / totW * bst)) + 10;
  14. defense = (int) Math.max(1, Math.round(defW / totW * bst)) + 10;
  15. spatk = (int) Math.max(1, Math.round(spaW / totW * bst)) + 10;
  16. spdef = (int) Math.max(1, Math.round(spdW / totW * bst)) + 10;
  17. speed = (int) Math.max(1, Math.round(speW / totW * bst)) + 10;
  18. } else {
  19. // Minimum 20 HP, 10 everything else
  20. int bst = bst() - 70;
  21.  
  22. // Make weightings
  23. double hpW = random.nextDouble(), atkW = random.nextDouble(), defW = random.nextDouble();
  24. double spaW = random.nextDouble(), spdW = random.nextDouble(), speW = random.nextDouble();
  25.  
  26. double totW = hpW + atkW + defW + spaW + spdW + speW;
  27.  
  28. hp = (int) Math.max(1, Math.round(hpW / totW * bst)) + 20;
  29. attack = (int) Math.max(1, Math.round(atkW / totW * bst)) + 10;
  30. defense = (int) Math.max(1, Math.round(defW / totW * bst)) + 10;
  31. spatk = (int) Math.max(1, Math.round(spaW / totW * bst)) + 10;
  32. spdef = (int) Math.max(1, Math.round(spdW / totW * bst)) + 10;
  33. speed = (int) Math.max(1, Math.round(speW / totW * bst)) + 10;
  34. }
  35.  
  36. // Check for something we can't store
  37. if (hp > 255 || attack > 255 || defense > 255 || spatk > 255 || spdef > 255 || speed > 255) {
  38. // re roll
  39. randomizeStatsWithinBST(random);
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement