Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Code made by Oysi
- local function f(n) return string.format("%.2f", n) end
- local function ftime(n)
- local min = math.floor(n/60)
- local sec = math.floor(n%60*100 + 0.5)/100
- local secStr = string.format("%.2f", n%60)
- if min < 10 then
- --min = "0" .. min
- end
- if sec < 10 then
- secStr = "0" .. secStr
- end
- return min .. ":" .. secStr
- end
- local function sim(data)
- local timer = 0
- local damage = 0
- local bossMaxHP = data.bossMaxHP
- local bossHP = bossMaxHP
- for i, dude in ipairs(data.dudes) do
- dude.damage = 0
- dude.aaTimer = 0
- dude.cooldownAvailable = true
- dude.cooldownTimer = 0
- end
- local heroAvailable = true
- local heroTimer = 0
- local delta = 0.01
- while bossHP > 0 do
- local haste = 1
- local dmgmul = 1
- -- Dudes
- for i, dude in ipairs(data.dudes) do
- local haste = haste
- local dmgmul = dmgmul
- -- Hero
- heroTimer = math.max(heroTimer - delta, 0)
- if heroAvailable and bossHP/bossMaxHP <= data.heroPercent then
- heroAvailable = false
- heroTimer = 40
- end
- if heroTimer > 0 then
- --haste = haste * 1.3
- dmgmul = dmgmul * 1.3
- end
- -- Cooldown
- dude.cooldownTimer = math.max(dude.cooldownTimer - delta, 0)
- if dude.cooldownAvailable and bossHP/bossMaxHP <= dude.cooldownpercent then
- dude.cooldownAvailable = false
- dude.cooldownTimer = dude.cooldownduration
- end
- if dude.cooldownTimer > 0 then
- dmgmul = dmgmul * dude.cooldownmul
- end
- -- Auto attack
- dude.aaTimer = math.max(dude.aaTimer - delta*haste, 0)
- if dude.aaTimer <= 0 then
- dude.aaTimer = 1
- local aaDamage = dude.autoattack*dmgmul
- if bossHP <= bossMaxHP*data.executeStart then
- aaDamage = aaDamage * data.executeMul
- end
- if bossHP <= 0 then
- aaDamage = 0
- end
- dude.damage = dude.damage + aaDamage
- bossHP = bossHP - aaDamage
- if data.print then
- print(
- ftime(timer) ..
- " - Dude #" .. i ..
- " - Damage: " .. f(aaDamage) ..
- " - Health: " .. f(bossHP) .. " (" .. f(bossHP/bossMaxHP*100) .. "%)" ..
- " - DPS: " .. string.format("%.3f", dude.damage/timer) ..
- (heroTimer > 0 and " - HERO" or "") ..
- (dude.cooldownTimer > 0 and " - COOLDOWN" or "")
- )
- end
- -- on hit: generate new dude
- --[[
- if aaDamage > 0 then
- local newDude = {autoattack = 1, cooldownpercent = 0.5, cooldownmul = 2, cooldownduration = 20};
- newDude.damage = 0
- newDude.aaTimer = 1
- newDude.cooldownAvailable = true
- newDude.cooldownTimer = 0
- table.insert(data.dudes, newDude)
- end
- --]]
- end
- end
- -- Constant external dot
- if data.externalDot and data.externalDot > 0 then
- if bossHP <= bossMaxHP*data.executeStart then
- bossHP = bossHP - delta*data.externalDot*data.executeMul
- else
- bossHP = bossHP - delta*data.externalDot
- end
- end
- timer = timer + delta
- end
- return damage, timer
- end
- sim {
- bossMaxHP = 500;
- heroPercent = 0.5;
- executeStart = 0.5;
- executeMul = 1.5;
- externalDot = 0;
- dudes = {
- {autoattack = 1, cooldownpercent = 0.5, cooldownmul = 2, cooldownduration = 20};
- {autoattack = 1, cooldownpercent = 0.5, cooldownmul = 2, cooldownduration = 20};
- };
- print = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement