Advertisement
g_heinz

Sapphire Damage Calc v4

Oct 29th, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. import math
  2.  
  3. #first gather information about the attacking and defending pokemon
  4.  
  5. L = input("Attacking Pokemon's level: ")
  6. A = input("Attacking Pokemon's offensive stat value: ")
  7. P = input("Attacking move's base power: ")
  8. D = input("Defending Pokemon's defensive stat value: ")
  9. HP = input("Defending Pokemon's HP value: ")
  10. xitem = input("Attack stage after boosts/drops: ")
  11. defstage = input("Defense stage after boosts/drops: ")
  12.  
  13. badgeboost = raw_input("Does a badge boost apply? y or n: ")
  14. softwater = raw_input("Does a mystic water or soft sand boost apply? y or n: ")
  15. torrentcheck = raw_input("Does Torrent apply? y or n: ")
  16. doublecheck = raw_input("Does the attack target both defending Pokemon? y or n: ")
  17. stabcheck = raw_input("Is the move STAB? y or n: ")
  18. weathercheck = raw_input("Is the move boosted by weather? y or n: ")
  19. typeeffect = input("What is the type-effectiveness? 0.25, 0.5, 1, 2, or 4: ")
  20. critcheck = raw_input("Is the move a critical hit? y or n: ")
  21. lsrefcheck = raw_input("Is light screen or reflect active? y or n: ")
  22.  
  23. #next modify the attack stat based on the answers to the above
  24.  
  25. #but adjust stat stage if critical hit
  26. if critcheck == "y" and xitem < 0:
  27. xitem = 0
  28. elif critcheck == "n":
  29. xitem = xitem
  30. if critcheck == "y" and defstage > 0:
  31. defstage = 0
  32. elif critcheck == "n":
  33. defstage = defstage
  34.  
  35. if badgeboost == "y":
  36. A = int(A*1.1)
  37. elif badgeboost == "n":
  38. A = A
  39.  
  40. if softwater == "y":
  41. A = int(A*1.1)
  42. elif softwater == "n":
  43. A = A
  44. if xitem == 0:
  45. A = A
  46. elif xitem == -1:
  47. A = int(A*10/15)
  48. elif xitem == -2:
  49. A = int(A*10/20)
  50. elif xitem == -3:
  51. A = int(A*10/25)
  52. elif xitem == -4:
  53. A = int(A*10/30)
  54. elif xitem == -5:
  55. A = int(A*10/35)
  56. elif xitem == -6:
  57. A = int(A*10/40)
  58. elif xitem == 1:
  59. A = int(A*15/10)
  60. elif xitem == 2:
  61. A = int(A*20/10)
  62. elif xitem == 3:
  63. A = int(A*25/10)
  64. elif xitem == 4:
  65. A = int(A*30/10)
  66. elif xitem == 5:
  67. A = int(A*35/10)
  68. elif xitem == 6:
  69. A = int(A*40/10)
  70.  
  71. if defstage == 0:
  72. D = D
  73. elif defstage == -1:
  74. D = int(D*10/15)
  75. elif defstage == -2:
  76. D = int(D*10/20)
  77. elif defstage == -3:
  78. D = int(D*10/25)
  79. elif defstage == -4:
  80. D = int(D*10/30)
  81. elif defstage == -5:
  82. D = int(D*10/35)
  83. elif defstage == -6:
  84. D = int(D*10/40)
  85. elif defstage == 1:
  86. D = int(D*15/10)
  87. elif defstage == 2:
  88. D = int(D*20/10)
  89. elif defstage == 3:
  90. D = int(D*25/10)
  91. elif defstage == 4:
  92. D = int(D*30/10)
  93. elif defstage == 5:
  94. D = int(D*35/10)
  95. elif defstage == 6:
  96. D = int(D*40/10)
  97.  
  98. if torrentcheck == "y":
  99. P = int(P*1.5)
  100. elif torrentcheck == "n":
  101. P = P
  102.  
  103. #third calculate the base damage of the attack before a few additional modifiers
  104.  
  105. basedamage = int(int(int(2*L/5+2)*A*P/D)/50)
  106.  
  107. #then include the relevant modifiers
  108.  
  109. if lsrefcheck == "y" and doublecheck == "n":
  110. basedamage = int(basedamage/2)
  111. elif lsrefcheck == "y" and doublecheck == "y":
  112. basedamage = int((basedamage*2)/3)
  113. elif lsrefcheck == "n" and doublecheck == "n":
  114. basedamage = basedamage
  115.  
  116. if doublecheck == "y":
  117. basedamage = int(basedamage/2)
  118. elif doublecheck == "n":
  119. basedamage = basedamage
  120.  
  121. if weathercheck == "y":
  122. basedamage = int(basedamage*1.5)
  123. elif weathercheck == "n":
  124. basedamage = basedamage
  125.  
  126. basedamage += 2
  127.  
  128. #multiply by 2 for critical
  129.  
  130. if critcheck == "y":
  131. basedamage *= 2
  132. elif critcheck == "n":
  133. basedamage = basedamage
  134.  
  135. #factor in STAB
  136.  
  137. if stabcheck == "y":
  138. basedamage = int(basedamage*1.5)
  139. elif stabcheck == "n":
  140. basedamage = basedamage
  141.  
  142. #then type-effectiveness
  143.  
  144. damage = int(basedamage * typeeffect)
  145.  
  146. #finally factor in damage variance and print
  147.  
  148. R = range(85,101)
  149. missedrange = 0
  150. for i in R:
  151. roll = int((damage*i)/100)
  152. if HP - roll > 0:
  153. missedrange += 1
  154.  
  155. OHKO = 100 * ((16 - missedrange)/float(16))
  156. minroll = int((damage*85)/100)
  157.  
  158. print("{}-{} damage".format(minroll, damage))
  159. print("{}% chance to OHKO".format(OHKO))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement