Advertisement
Guest User

Untitled

a guest
Mar 15th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. -- Crit simulator to estimate killing time based on attack damage, speed and crit rates.
  2.  
  3. critSim = {}
  4. critSim.Simulate = function(attack, critRate)
  5. if not attack then
  6. attack = critSim.A
  7. end
  8. if not critRate then
  9. critRate = critSim.critRates.Penwize
  10. end
  11. if attack.Damage <= 0 then
  12. cecho("<tomato>Can't simulate non-positive damage!")
  13. end
  14.  
  15. local critTable = {}
  16. local critTotal = 0
  17. for k,v in pairs(critRate) do
  18. critTotal = critTotal+v
  19. end
  20. critTable[2] = critTotal
  21. critTable[4] = critTable[2]+critRate[4]
  22. critTable[8] = critTable[4]+critRate[8]
  23. critTable[16] = critTable[8]+critRate[16]
  24. critTable[32] = critTable[16]+critRate[32]
  25.  
  26. local time = 0
  27. local kills = 0
  28. local damage = 0
  29. local multiplier
  30. local roll
  31. local hits = 0
  32. math.randomseed(critSim.seed)
  33. while(kills < critSim.killCount) do
  34. roll = math.random()*100
  35. if roll < critTable[32] then
  36. multiplier = 32
  37. elseif roll < critTable[16] then
  38. multiplier = 16
  39. elseif roll < critTable[8] then
  40. multiplier = 8
  41. elseif roll < critTable[4] then
  42. multiplier = 4
  43. elseif roll < critTable[2] then
  44. multiplier = 2
  45. else
  46. multiplier = 1
  47. end
  48. damage = damage + (attack.Damage*multiplier)
  49. hits = hits + 1
  50. time = time + attack.Speed
  51. if damage > critSim.mobHealth then
  52. kills = kills + 1
  53. damage = 0
  54. end
  55. end
  56. cecho(string.format("<white><green>%3dd<white> / <green>%0.1fs<white> = <green>%0.1f dps",attack.Damage,attack.Speed,(attack.Damage/attack.Speed)))
  57. cecho(string.format("<white> needed <tomato>%5d<white> hits to kill <cyan>%4d<white> mobs in <yellow>%6d<white>s =",hits,kills,time))
  58. cecho(string.format("<gold> %1.2f <white>kills / min.\n",kills/(time/60)));
  59. end
  60. critSim.SimulateMultiple = function(critRate)
  61. if not critRate then
  62. critRate = critSim.critRates.Penwize
  63. end
  64. local topDamage = 200
  65. local targetDPS = 50
  66. local damage
  67. for i=1,(topDamage-50+1),5 do
  68. damage = (topDamage+1)-i
  69. critSim.Simulate({
  70. ["Damage"] = damage,
  71. ["Speed"] = (damage/targetDPS)},
  72. critRate)
  73. end
  74. end
  75. critSim.SimAll = function()
  76. cecho("<white>Simulating with Penwize-level crits:\n")
  77. critSim.SimulateMultiple(critSim.critRates.Penwize)
  78. cecho("<white>=======================================\n")
  79. cecho("<white>Simulating with artied level 104 dragon crits:\n")
  80. critSim.SimulateMultiple(critSim.critRates.ArtieDragon104)
  81. cecho("<white>=======================================\n")
  82. cecho("<white>Simulating with low estimated crit rate:\n")
  83. critSim.SimulateMultiple(critSim.critRates.LowEstimate)
  84. cecho("<white>=======================================\n")
  85. cecho("<white>Simulating with zero crits:\n")
  86. critSim.SimulateMultiple(critSim.critRates.Zero)
  87. cecho("<white>=======================================\n")
  88. end
  89.  
  90. critSim.seed = 1234
  91. critSim.mobHealth = 2000
  92. critSim.killCount = 1000
  93.  
  94.  
  95.  
  96. critSim.A = {
  97. Damage = 100,
  98. Speed = 2
  99. }
  100. critSim.critRates = {}
  101. critSim.critRates.Penwize = {
  102. [2] = 24.6,
  103. [4] = 13.6,
  104. [8] = 7.6,
  105. [16] = 4.2,
  106. [32] = 5.2
  107. }
  108. critSim.critRates.ArtieDragon104 = {
  109. [2] = 24.3,
  110. [4] = 11.4,
  111. [8] = 5.8,
  112. [16] = 2.69,
  113. [32] = 2.65
  114. }
  115. critSim.critRates.LowEstimate = {
  116. [2] = 10,
  117. [4] = 5,
  118. [8] = 2.5,
  119. [16] = 1.2,
  120. [32] = 0.6
  121. }
  122. critSim.critRates.Zero = {
  123. [2] = 0,
  124. [4] = 0,
  125. [8] = 0,
  126. [16] = 0,
  127. [32] = 0
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement