• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# My edited version of G_heinz' damage calc Mitsunee   Oct 29th, 2016 (edited) 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import math
2. import os
3. #import os and therefore the last command I added are windows-only ~M
4.
5. #first gather information about the attacking and defending pokemon
6.
7. L = input("Attacking Pokemon's level: ")
8. A = input("Attacking Pokemon's offensive stat value: ")
9. P = input("Attacking move's base power: ")
10. D = input("Defending Pokemon's defensive stat value: ")
11. HP = input("Defending Pokemon's HP value: ")
12. xitem = input("Attack stage after boosts/drops: ")
13. defstage = input("Defense stage after boosts/drops: ")
14.
15. badgeboost = raw_input("Does a badge boost apply? y or n: ")
16. softwater = raw_input("Does a mystic water or soft sand boost apply? y or n: ")
17. torrentcheck = raw_input("Does Torrent apply? y or n: ")
18. doublecheck = raw_input("Does the attack target both defending Pokemon? y or n: ")
19. stabcheck = raw_input("Is the move STAB? y or n: ")
20. raincheck = raw_input("Is the move boosted by weather? y or n: ")
21. suncheck = raw_input("Is the move negatively affected by weather? y or n: ")
22. typeeffect = input("What is the type-effectiveness? 0.25, 0.5, 1, 2, or 4: ")
23. lsrefcheck = raw_input("Is light screen or reflect active? y or n: ")
24.
25. #next modify the attack stat based on the answers to the above
26.
27. if badgeboost == "y":
28.     A = int(A*1.1)
29. elif badgeboost == "n":
30.     A = A
31.
32. if softwater == "y":
33.     A = int(A*1.1)
34. elif softwater == "n":
35.     A = A
36. if xitem == -1:
37.     A = int(A*10/15)
38. elif xitem == 0:
39.     A = A
40. elif xitem == 1:
41.     A = int(A*15/10)
42. elif xitem == 2:
43.     A = int(A*20/10)
44. elif xitem == 3:
45.     A = int(A*25/10)
46. elif xitem == 4:
47.     A = int(A*30/10)
48. elif xitem == 5:
49.     A = int(A*35/10)
50. elif xitem == 6:
51.     A = int(A*40/10)
52.
53. if defstage == -1:
54.     D = int(D*10/15)
55. elif defstage == 0:
56.     D = D
57. elif defstage == 1:
58.     D = int(D*15/10)
59. elif defstage == 2:
60.     D = int(D*20/10)
61. elif defstage == 3:
62.     D = int(D*25/10)
63. elif defstage == 4:
64.     D = int(D*30/10)
65. elif defstage == 5:
66.     D = int(D*35/10)
67. elif defstage == 6:
68.     D = int(D*40/10)
69.
70. if torrentcheck == "y":
71.     P = int(P*1.5)
72. elif torrentcheck == "n":
73.     P = P
74.
75. #third calculate the base damage of the attack before a few additional modifiers
76.
77. basedamage = int(int(int(2*L/5+2)*A*P/D)/50)
78.
79. #then include the relevant modifiers
80.
81. if lsrefcheck == "y" and doublecheck == "n":
82.     basedamage = int(basedamage/2)
83. elif lsrefcheck == "y" and doublecheck == "y":
84.     basedamage = int((basedamage*2)/3)
85. elif lsrefcheck == "n" and doublecheck == "n":
86.     basedamage = basedamage
87.
88. #I renamed weathercheck to raincheck ~M
89. if raincheck == "y":
90.     basedamage = int(basedamage*1.5)
91. elif raincheck == "n":
92.     basedamage = basedamage
93.
94. #and added suncheck ~M
95. if suncheck == "y":
96.     basedamage = int(basedamage*0.5)
97. elif suncheck == "n":
98.     basedamage = basedamage
99.
100. if doublecheck == "y":
101.     basedamage = int(basedamage/2)
102. elif doublecheck == "n":
103.     basedamage = basedamage
104.
105. basedamage += 2
106.
107. #factor in STAB
108.
109. if stabcheck == "y":
110.     basedamage = int(basedamage*1.5)
111. elif stabcheck == "n":
112.     basedamage = basedamage
113.
114. #then type-effectiveness
115.
116. damage = basedamage * typeeffect
117.
118. #finally factor in damage variance and print
119.
120. R = range(85,101)
121. missedrange = 0
122. for i in R:
123.     roll = int((damage*i)/100)
124.     if HP - roll > 0:
125.         missedrange += 1
126.
127. OHKO = 100 * ((16 - missedrange)/float(16))
128. minroll = int((damage*85)/100)
129. #Calculating damage in % ~M
130. percminroll = float(float(minroll) / float(HP) * 100)
131. percdamage = float(float(damage) / float(HP) * 100)
132.
133. print("{}-{} damage".format(str(minroll), str(damage)))
134. print("{}%-{}% damage".format(str(percminroll), str(percdamage)))
135. print("{}% chance to OHKO".format(OHKO))
136.
137. #I added a Pause here, because the script would autoexit for me ~M
138. os.system("pause")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top