Advertisement
The_Belch

Bomb Timer

Jul 2nd, 2019
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. ----- bomb timer lua for aimware by solo -----
  2.  
  3. local ref = gui.Reference("MISC", "GENERAL", "Main");
  4. local mouseX, mouseY, x, y, dx, dy, w, h = 0, 0, 650, 10, 0, 0, 400, 50;
  5. local shouldDrag = false;
  6. local fonticon = draw.CreateFont("icomoon", 25, 25);
  7. local fontinfo = draw.CreateFont("Verdana", 15, 15);
  8. local fonttext = draw.CreateFont("Verdana", 15, 15);
  9. local fontbombtext = draw.CreateFont("skeet Smallest Pixel-7 Modified", 10, 15);
  10.  
  11. local defusing = false;
  12.  
  13. function EventHook(Event)
  14. if Event:GetName() == "bomb_begindefuse" then
  15. defusing = true;
  16. elseif Event:GetName() == "bomb_abortdefuse" then
  17. defusing = false;
  18. elseif Event:GetName() == "round_officially_ended"
  19. or Event:GetName() == "bomb_defused" or Event:GetName() == "bomb_exploded" then
  20. defusing = false;
  21. end
  22. end
  23.  
  24. local function dragFeature()
  25. if input.IsButtonDown(1) then
  26. mouseX, mouseY = input.GetMousePos();
  27. if shouldDrag then
  28. x = mouseX - dx;
  29. y = mouseY - dy;
  30. end
  31. if mouseX >= x and mouseX <= x + w and mouseY >= y and mouseY <= y + 40 then
  32. shouldDrag = true;
  33. dx = mouseX - x;
  34. dy = mouseY - y;
  35. end
  36. else
  37. shouldDrag = false;
  38. end
  39. end
  40.  
  41. local function drawTimer()
  42.  
  43. if entities.FindByClass("CPlantedC4")[1] ~= nil then
  44. local Bomb = entities.FindByClass("CPlantedC4")[1];
  45.  
  46. if Bomb:GetProp("m_bBombTicking") and Bomb:GetProp("m_bBombDefused") == 0 and globals.CurTime() < Bomb:GetProp("m_flC4Blow") then
  47. local Player = entities.GetLocalPlayer();
  48. if defusing == true then
  49. local BombMath = ((globals.CurTime() - Bomb:GetProp("m_flDefuseCountDown")) * 0.5) / ((Bomb:GetProp("m_flDefuseCountDown") - Bomb:GetProp("m_flDefuseLength")) - Bomb:GetProp("m_flDefuseCountDown")) + 1;
  50.  
  51. draw.Color(8, 8, 8, 30)
  52. draw.FilledRect(x, y, x + w, y + h)
  53. draw.FilledRect(x - 65, y, x + (w - 405), y + h )
  54.  
  55. draw.Color(8, 8, 8, 90)
  56. draw.FilledRect(x + 20, y + 20, x + (w - 20), y + h - 20)
  57.  
  58. draw.Color(0, 150, 255, 240)
  59. draw.FilledRect(x + 20, y + 20, (x + 20) * BombMath, y + h - 20)
  60.  
  61. draw.Color(180, 180, 180, 120)
  62. draw.OutlinedRect(x, y, x + w, y + h)
  63. draw.OutlinedRect(x - 65,y , x + (w - 405), y + h)
  64.  
  65. draw.Color(255, 255, 255, 255)
  66. draw.SetFont(fontbombtext)
  67. draw.Text(x - 48, y + 30, "BOMB")
  68. draw.SetFont(fonticon)
  69. draw.Text(x - 50, y + 10, "y")
  70.  
  71. else
  72.  
  73. local BombMath = ((globals.CurTime() - Bomb:GetProp("m_flC4Blow")) * 0.5) / ((Bomb:GetProp("m_flC4Blow") - Bomb:GetProp("m_flTimerLength")) - Bomb:GetProp("m_flC4Blow")) + 1;
  74.  
  75. draw.Color(8, 8, 8, 30)
  76. draw.FilledRect(x, y, x + w, y + h)
  77. draw.FilledRect(x - 65, y, x + (w - 405), y + h )
  78.  
  79. draw.Color(8, 8, 8, 90)
  80. draw.FilledRect(x + 20, y + 20, x + (w - 20), y + h - 20)
  81.  
  82. draw.Color(130, 255, 0, 240)
  83. draw.FilledRect(x + 20, y + 20, (x + 20) * BombMath, y + h - 20)
  84.  
  85. draw.Color(180, 180, 180, 120)
  86. draw.OutlinedRect(x, y, x + w, y + h)
  87. draw.OutlinedRect(x - 65,y , x + (w - 405), y + h)
  88.  
  89. draw.Color(255, 255, 255, 255)
  90. draw.SetFont(fontbombtext)
  91. draw.Text(x - 48, y + 30, "BOMB")
  92. draw.SetFont(fonticon)
  93. draw.Text(x - 50, y + 10, "y")
  94. end
  95.  
  96. if Player:IsAlive() and globals.CurTime() < Bomb:GetProp("m_flC4Blow") then
  97. if math.floor(0.5 + BombDamage(Bomb, Player)) >= Player:GetHealth() then
  98. draw.Color(255, 0, 0, 255)
  99. draw.SetFont(fontinfo)
  100. draw.Text(5, 0, "LETHAL");
  101. draw.TextShadow(5, 0, "LETHAL");
  102. else
  103. draw.Color(255, 255, 255, 255)
  104. draw.SetFont(fontinfo)
  105. draw.Text(5, 0, math.floor(0.5 + BombDamage(Bomb, Player)) .. " HP");
  106. draw.TextShadow(5, 0, math.floor(0.5 + BombDamage(Bomb, Player)) .. " HP");
  107. end
  108. end
  109. end
  110. end
  111. end
  112.  
  113. function BombDamage(Bomb, Player)
  114. local C4Distance = math.sqrt((select(1,Bomb:GetAbsOrigin()) - select(1,Player:GetAbsOrigin())) ^ 2 +
  115. (select(2,Bomb:GetAbsOrigin()) - select(2,Player:GetAbsOrigin())) ^ 2 +
  116. (select(3,Bomb:GetAbsOrigin()) - select(3,Player:GetAbsOrigin())) ^ 2);
  117.  
  118. local Gauss = (C4Distance - 75.68) / 789.2
  119. local flDamage = 450.7 * math.exp(-Gauss * Gauss);
  120.  
  121. if Player:GetProp("m_ArmorValue") > 0 then
  122.  
  123. local flArmorRatio = 0.5;
  124. local flArmorBonus = 0.5;
  125.  
  126. if Player:GetProp("m_ArmorValue") > 0 then
  127. local flNew = flDamage * flArmorRatio;
  128. local flArmor = (flDamage - flNew) * flArmorBonus;
  129.  
  130. if flArmor > Player:GetProp("m_ArmorValue") then
  131. flArmor = Player:GetProp("m_ArmorValue") * (1 / flArmorBonus);
  132. flNew = flDamage - flArmor;
  133. end
  134.  
  135. flDamage = flNew;
  136.  
  137. end
  138.  
  139. end
  140. return math.max(flDamage, 0);
  141. end
  142.  
  143. callbacks.Register( "Draw", "drag", dragFeature)
  144. callbacks.Register("FireGameEvent", "EventHookB", EventHook);
  145. callbacks.Register( "Draw", "drawTimer", drawTimer );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement