Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Crit simulator to estimate killing time based on attack damage, speed and crit rates.
- critSim = {}
- critSim.Simulate = function(attack, critRate)
- if not attack then
- attack = critSim.A
- end
- if not critRate then
- critRate = critSim.critRates.Penwize
- end
- if attack.Damage <= 0 then
- cecho("<tomato>Can't simulate non-positive damage!")
- end
- local critTable = {}
- local critTotal = 0
- for k,v in pairs(critRate) do
- critTotal = critTotal+v
- end
- critTable[2] = critTotal
- critTable[4] = critTable[2]+critRate[4]
- critTable[8] = critTable[4]+critRate[8]
- critTable[16] = critTable[8]+critRate[16]
- critTable[32] = critTable[16]+critRate[32]
- local time = 0
- local kills = 0
- local damage = 0
- local multiplier
- local roll
- local hits = 0
- math.randomseed(critSim.seed)
- while(kills < critSim.killCount) do
- roll = math.random()*100
- if roll < critTable[32] then
- multiplier = 32
- elseif roll < critTable[16] then
- multiplier = 16
- elseif roll < critTable[8] then
- multiplier = 8
- elseif roll < critTable[4] then
- multiplier = 4
- elseif roll < critTable[2] then
- multiplier = 2
- else
- multiplier = 1
- end
- damage = damage + (attack.Damage*multiplier)
- hits = hits + 1
- time = time + attack.Speed
- if damage > critSim.mobHealth then
- kills = kills + 1
- damage = 0
- end
- end
- cecho(string.format("<white><green>%3dd<white> / <green>%0.1fs<white> = <green>%0.1f dps",attack.Damage,attack.Speed,(attack.Damage/attack.Speed)))
- cecho(string.format("<white> needed <tomato>%5d<white> hits to kill <cyan>%4d<white> mobs in <yellow>%6d<white>s =",hits,kills,time))
- cecho(string.format("<gold> %1.2f <white>kills / min.\n",kills/(time/60)));
- end
- critSim.SimulateMultiple = function(critRate)
- if not critRate then
- critRate = critSim.critRates.Penwize
- end
- local topDamage = 200
- local targetDPS = 50
- local damage
- for i=1,(topDamage-50+1),5 do
- damage = (topDamage+1)-i
- critSim.Simulate({
- ["Damage"] = damage,
- ["Speed"] = (damage/targetDPS)},
- critRate)
- end
- end
- critSim.SimAll = function()
- cecho("<white>Simulating with Penwize-level crits:\n")
- critSim.SimulateMultiple(critSim.critRates.Penwize)
- cecho("<white>=======================================\n")
- cecho("<white>Simulating with artied level 104 dragon crits:\n")
- critSim.SimulateMultiple(critSim.critRates.ArtieDragon104)
- cecho("<white>=======================================\n")
- cecho("<white>Simulating with low estimated crit rate:\n")
- critSim.SimulateMultiple(critSim.critRates.LowEstimate)
- cecho("<white>=======================================\n")
- cecho("<white>Simulating with zero crits:\n")
- critSim.SimulateMultiple(critSim.critRates.Zero)
- cecho("<white>=======================================\n")
- end
- critSim.seed = 1234
- critSim.mobHealth = 2000
- critSim.killCount = 1000
- critSim.A = {
- Damage = 100,
- Speed = 2
- }
- critSim.critRates = {}
- critSim.critRates.Penwize = {
- [2] = 24.6,
- [4] = 13.6,
- [8] = 7.6,
- [16] = 4.2,
- [32] = 5.2
- }
- critSim.critRates.ArtieDragon104 = {
- [2] = 24.3,
- [4] = 11.4,
- [8] = 5.8,
- [16] = 2.69,
- [32] = 2.65
- }
- critSim.critRates.LowEstimate = {
- [2] = 10,
- [4] = 5,
- [8] = 2.5,
- [16] = 1.2,
- [32] = 0.6
- }
- critSim.critRates.Zero = {
- [2] = 0,
- [4] = 0,
- [8] = 0,
- [16] = 0,
- [32] = 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement