 # Drop rate bonus based on party level

Apr 21st, 2021 (edited)
322
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. # NOTE: All divisions here are integer divisions (ie: 10/3 = 3)
2.
3. def get_party_avg_level():
4.   chars = get_number_chars_unlocked() # caps at 56
5.   avg = 0
6.   for member in frontline:
7.     avg = avg + member.level
8.   if (chars >= 12):
9.     return (avg / 12)
10.   else:
11.     # take the average based on how many chars you can have in party of 12
12.     return (avg / chars)
13.
14. lv = get_enemy_level() # NOT the challenge level, actual enemy level
15. avg = get_party_avg_level()
16. multiplier = 100
17.
18. # This bonus has a hard cap
19. cap_bonus = 100 - ((avg * 100) / lv)
20. cap_bonus = (cap_bonus / 3) * 10
21.
22. # This bonus has no cap
23. lv_bonus = (lv - avg) * 12
24.
25. # If either result was less than 0, make it zero
26. cap_bonus = max(cap_prob, 0)
27. lv_bonus = max(lv_prob, 0)
28.
29. # Add the lesser bonus to the multiplier
30. final_bonus = min(cap_bonus, lv_bonus)
31. multiplier = multiplier + final_bonus
32.
33. for drop_item_slot in get_enemy_drop_item_slots():
34.   drop_chance = drop_item_slot.chance # Chance of dropping this item
35.   final_prob = drop_chance * multiplier / 100
36.   r = random(10000) # random number 0-9999
37.   if (r < final_prob):
38.     drop_item_for_player()
39.
40. """
41. EXAMPLES
42.
43. Kraken (Lv25) dropping a Toadstoolshed (3333 chance), party average Lv19:
44. cap_bonus = 100 - ((19 * 100) / 25) = 24
45. cap_bonus = (24 / 3) * 10 = 80
46. lv_bonus = (25 - 19) * 12 = 72
47. final_bonus = min(80, 72) = 72
48. final_prob = 3333 * (100 + 72) / 100 = 5732
49. You increased the drop rate from 33.33% to 57.32%
50.
51. Kraken (Lv25) dropping a Toadstoolshed (3333 chance), party average Lv1:
52. cap_bonus = 100 - ((1 * 100) / 25) = 96
53. cap_bonus = (96 / 3) * 10 = 320
54. lv_bonus = (25 - 1) * 12 = 288
55. final_bonus = min(320, 288) = 288
56. final_prob = 3333 * (100 + 288) / 100 = 12932
57. You increased the drop rate from 33.33% to 100%
58.
59. Kraken (Lv25) dropping a Toadstoolshed (3333 chance), party average Lv40:
60. cap_bonus = 100 - ((40 * 100) / 25) = -60
61. cap_bonus = (96 / 3) * 10 = -200 (gets set to 0)
62. lv_bonus = (25 - 40) * 12 = -180 (gets set to 0)
63. final_bonus = min(0, 0) = 0
64. final_prob = 3333 * (100 + 0) / 100 = 3333
65. Drop rate not altered
66.
67. > Because of how the functions are defined, you can rewrite the formulas for cap_bonus and lv_bonus as follows:
68. cap_bonus = (1 - x) * 1000 / 3
69. lv_bonus = (1 - x) * 12 * lv
70. Where x is the fraction (avg / lv)
71. Therefore, if x is 1 or higher, the drop rate will not be altered
72. If it is less than 1, then which formula takes priority depends only on the enemy level
73. Since 12 * lv > 1000 / 3 for lv >= 28, we use lv_bonus for enemies up to Lv27, and cap_bonus for Lv28 onwards
74. It follows that the highest bonus you can receive is when the fraction is rounded to 0 for cap_bonus: 1000 / 3 = 333
75.
76. > Other factors change the multiplier value before this part of the code execute. You can see a list of them below:
77.
78. # of Items Discovery Weekly held: +2 for each, up to +100
79. # of Explorer King's Legend held: +2 for each, up to +100
80. # of consecutive battles in dungeon: +2 for each battle, caps at:
81.  +100 before pillar of light
82.  +250 after pillar of light in regular dungeon
83.  +1000 after pillar of light in infinity corridor
84.
85. If any character in frontline has Gensokyo's Shopkeeper learned: +4 for each Skill Level
86. Otherwise, if any character in backlines has Gensokyo's Shopkeeper learned: +1 for each Skill Level
87.
88. If any character in frontline has Dowsing learned: +20 for each Skill Level
89. Otherwise, if any character in backlines has Dowsing learned: +5 for each Skill Level
90.
91. If any character in frontline has Ability to Gather Treasures learned: +10 for each Skill Level (+5 for each Skill Level of More and More Treasures if also learned)
92. Otherwise, if any character in backlines has Ability to Gather Treasures learned: +3 for each Skill Level (+2 for each Skill Level if More and More Treasures if also learned)
93.
94. If any character in frontline has Kappa's Material Aesthetica learned: +20 for each Skill Level
95.
96. For each frontliner with Aesthetic Sense learned: +2 for each Skill Level
97. For each backliner with Aesthetic Sense learned: +2
98.
99. > Some spells and skills also change the drop rate upon ko, but act directly on the enemy's dropped item slot's drop chance. These spells and effects are listed below:
100.
101. If the character has Kill Bonus: Drops learned, increase drop chances by 1/6 of its value
102. If the character has Kappa's Material Aesthetica learned, increase drop chances by 40%
103. If the spell used was Rare Metal Detector, double drop chances
104. If the character has a Luck and Pluck equipped, increase drop chances by 20%
105. If the character has Kill Bonus: Drops learned, increase drop chances by 1/5 of its value [Bug? Why does it do this again?]
106. If the spell used was Radiant Treasure Gun, increase drop chances by 25% [40% if More and More Treasures learned]
107.
108. EXAMPLE
109.
110. Kraken dropping a Toadstoolshed (3333 chance), killed by Appraiser Nazrin's Rare Metal Detector:
111. Base chance = 3333
112. After Kill bonus: Drops 1/6 bonus: (3333 * 1.16) = 3888
113. After Rare Metal Detector bonus: (3888 * 2) = 7776
114. After Kill Bonus: Drops 1/5 bonus: (7776 * 1.2) = 9331
115. You increased the drop rate from 33.33% to 93.31%
116. """
RAW Paste Data