Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ENT:DetermineCapture(ent)
- if not ent then return end
- local shakes, maxhp, curhp, size, maxsize, pctrate, rate, a, b
- shakes = 1
- maxhp = ent:GetMaxHealth()
- curhp = ent:Health()
- size = ent:GetPhysicsObject():GetVolume() / 1000
- maxsize = 650
- pctrate = (maxsize - math.Clamp(size, 0, maxsize)) / maxsize
- if pctrate == 0 then pctrate = .0005 end --To make it not impossible to catch really big shit
- rate = 255 * pctrate
- if ent:IsOnFire() then bonus = 1.5 else bonus = 1 end
- a = (((3 * maxhp - 2 * curhp) * rate) / (3 * maxhp)) * bonus
- if a > 255 then return 5 end --Instant catch
- b = 1048560 / math.sqrt(math.sqrt(16711680/a))
- for i = 1, 4 do
- local rand = math.random(0, 65535)
- if rand < b then
- shakes = shakes + 1
- elseif rand >= b then
- break
- end
- end
- return shakes
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement