Advertisement
Guest User

reloadbar

a guest
Oct 25th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. -- v1, v2 or v3 | Only use one, uncomment/comment related lines in this file & in _main.lua
  2. -- v1 | Timer under crosshair
  3. -- v2 | Timer bottom of the screen
  4. -- v3 | Timer right side of the screen
  5.  
  6. local RldTime = 0 -- Reload duration in sec (tested @ 15ms)
  7. local RldEndTime = 0
  8. local CclTime = 0 -- Percentage of the reload animation before it can be cancelled (tested @ 15ms)
  9. local MarkerPos = 0 -- Cancel marker position based on CclTime
  10.  
  11. --local TestRldStart = 0 -- Reload time testing | Time at the start of the reload
  12. --local TestRldTime = 0 -- Reload time testing | Reload duration (s)
  13. --local TestPrinted = true -- Reload time testing | Last reload duration printed to console
  14.  
  15. function RldSetTimer()
  16. -- TestRldStart = os.clock() -- Reload time testing | Time at the start of the reload
  17. if string.match(currentWeapon.name(), "Rifle") or currentWeapon.name() == "NJ4 SMG" or currentWeapon.name() == "Nova Blaster" or currentWeapon.name() == "NJ5-B SMG" or currentWeapon.name() == "Falcon" or currentWeapon.name() == "X1 LMG" then
  18. if currentWeapon.ammo() > 0 then
  19. RldTime = 1.74
  20. CclTime = 59
  21. else
  22. RldTime = 1.78
  23. CclTime = 59
  24. end
  25. elseif string.match(currentWeapon.name(), "Spinfusor") or currentWeapon.name() == "Twinfusor" then
  26. RldTime = 1.21
  27. CclTime = 40
  28. elseif string.match(currentWeapon.name(), "Bolt") or currentWeapon.name() == "Thumper" or currentWeapon.name() == "Shocklance" then
  29. RldTime = 1.43
  30. CclTime = 60
  31. elseif currentWeapon.name() == "Honorfusor" then
  32. RldTime = 1.37
  33. CclTime = 40
  34. elseif currentWeapon.name() == "Fusion Mortar" or currentWeapon.name() == "MIRV Launcher" then
  35. RldTime = 2.65
  36. CclTime = 58
  37. elseif currentWeapon.name() == "Saber Launcher" then
  38. RldTime = 2.65
  39. CclTime = 63
  40. elseif currentWeapon.name() == "Nova Colt" or currentWeapon.name() == "Sparrow" or currentWeapon.name() == "Eagle Pistol" then
  41. RldTime = 1.74
  42. CclTime = 58
  43. elseif currentWeapon.name() == "Sawed-Off Shotgun" then
  44. RldTime = 1.43
  45. CclTime = 62
  46. elseif currentWeapon.name() == "Gladiator" then
  47.  
  48. elseif currentWeapon.name() == "Arx Buster" or currentWeapon.name() == "Plasma Gun" or currentWeapon.name() == "Sawed-Off Shotgun" or currentWeapon.name() == "Grenade Launcher" or currentWeapon.name() == "Plasma Cannon" or currentWeapon.name() == "Light Grenade Launcher" or currentWeapon.name() == "Jackal" then
  49. RldTime = 1.71
  50. CclTime = 59
  51. else
  52.  
  53. RldTime = 0
  54. end
  55. MarkerPos = (CclTime/100)*201 -- v1
  56. -- MarkerPos = (CclTime/100)*292 -- v2 / v3
  57. RldEndTime = os.clock() + RldTime
  58. end
  59.  
  60. function reloadTimer(x, y)
  61. local ammo_rt = currentWeapon.ammo() / currentWeapon.ammoMax()
  62. local ammo_adj = ammo_rt * 1.7
  63. local ammo_pct = ammo_rt * 100
  64. local ammo_color = lerpColor(ammo_color_low, ammo_color_full, ammo_adj)
  65. local reload_pct
  66. local RldTimerOn = false
  67. drawUTText(weapon.ammoTotal(7), rgba(210, 210, 210, 200), x + 440, y + 487, 2, 2, 2) -- v1
  68. -- drawUTText(weapon.ammoTotal(7), rgba(255, 255, 255, 160), x + 24, y - 25, 2, 2, 2) -- v2
  69. -- drawUTText(weapon.ammoTotal(7), rgba(255, 255, 255, 160), x - 300, y + 400, 2, 2, 2) -- v3
  70.  
  71. -- drawRect(x - 4, y - 4, x + 296, y + 21, bg_color2) -- v2
  72. -- drawBox(x - 4, y - 4, x + 296, y + 21, rgba(255, 255, 255, 120)) -- v2
  73. -- drawRect(x - 4, y - 293, x + 21, y + 7, bg_color2) -- v3
  74. -- drawBox(x - 4, y - 293, x + 21, y + 7, rgba(255, 255, 255, 120)) -- v3
  75.  
  76. if not currentWeapon.isReloading() then
  77. -- TestRldTime = os.clock() - TestRldStart -- Reload time testing
  78. -- if TestPrinted == false then -- Reload time testing
  79. -- console(currentWeapon.name() .. " " .. TestRldTime) -- Reload time testing
  80. -- TestPrinted = true -- Reload time testing
  81. -- end -- Reload time testing
  82.  
  83. -- drawProgressBar(x, y, x + 2.92, y + 17, ammo_color, 1, ammo_pct) -- v2
  84. -- drawProgressBar(x, y, x + 17, y + 2.92, ammo_color, 0, ammo_pct) -- v3
  85. RldTimerOn = false
  86. RldSetTimer()
  87. else
  88. -- TestPrinted = false -- Reload time testing
  89. RldTimerOn = true
  90. end
  91.  
  92. if RldTime ~= 0 then -- Don't show the cancel timer if weapon was not tested
  93. if RldTimerOn == true then
  94. reload_pct = 100 - (((RldEndTime - os.clock())/RldTime)*100)
  95. if reload_pct > 100 then
  96. RldTimerOn = false
  97. else
  98. if reload_pct >= CclTime then
  99. BarColor = rgba(180, 255, 150, 255) -- v1
  100. -- BarColor = rgba(195, 248, 212, 255) -- v2
  101. else
  102. BarColor = rgba(255, 255, 255, 120) -- v1
  103. -- BarColor = rgba(255, 255, 255, 114) -- v2
  104. end
  105. drawProgressBar(x, y, x + 2.01, y + 4, BarColor, 1, reload_pct) -- v1
  106. drawRect(x - 1, y - 1, x + 202, y + 5, rgba(0, 0, 0, 40)) -- v1
  107. drawRect(x+MarkerPos, y, x + MarkerPos + 2, y + 4, rgba(255, 0, 0, 255)) -- v1
  108.  
  109. -- drawProgressBar(x, y, x + 2.92, y + 17, BarColor, 1, reload_pct) -- v2
  110. -- drawRect(x + MarkerPos, y - 1, x + MarkerPos + 2, y + 18, rgba(255, 0, 0, 255)) -- v2
  111.  
  112. -- drawProgressBar(x, y, x + 17, y + 2.92, BarColor, 0, reload_pct) -- v3
  113. -- drawRect(x , y - MarkerPos - 1, x + 18, y - MarkerPos, rgba(255, 0, 0, 255)) -- v3
  114. end
  115. end
  116. end
  117. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement