Advertisement
Guest User

TAMods v0.4 static damage numbers

a guest
Jul 7th, 2015
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. local damageNumbersColorMin = rgb(255, 255, 255)
  2. local damageNumbersShieldColorMin = rgb(255, 255, 255)
  3.  
  4. function dist(v1, v2)
  5.    local x = v2.x - v1.x
  6.    local y = v2.y - v1.y
  7.    local z = v2.z - v1.z
  8.    return math.sqrt(x*x + y*y + z*z)
  9. end
  10.  
  11. function onDamageNumberCreate(dam_nums, number, loc, is_shield)
  12.    local num = DamageNumber(number, 1.70, loc, is_shield)
  13.    num.color = rgb(255, 255, 255)
  14.    dam_nums:add(num)
  15. end
  16.  
  17. function onDamageNumberUpdate(dam_nums, hud, delta)
  18.    local i = 0
  19.    local player = getPlayerPos(hud)
  20.    while i < dam_nums:size() do
  21.       local curr = dam_nums:get(i)
  22.       -- curr.time = curr.time - delta
  23.       if curr.time <= 0 then
  24.          dam_nums:remove(i)
  25.          i = i - 1
  26.       else
  27.          local loc = Vector(curr.location.x, curr.location.y, curr.location.z)
  28.          if isOnScreen(hud, loc) then
  29.             local d = dist(loc, player)
  30.             local maxd = 10000.0
  31.             if d > maxd then
  32.                curr.scale = 0
  33.             else
  34.                curr.scale = ((maxd - d) / maxd)
  35.             end
  36.             loc = project(hud, loc)
  37.             loc.z = curr.location.w
  38.             drawDamageNumber(hud, tostring(curr.number), curr.color, loc, curr.scale, curr.scale)
  39.          end
  40.       end
  41.       i = i + 1
  42.    end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement