Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. local Gauss
  2. local C4Distance = 0
  3. local box = gui.Groupbox(gui.Reference('VISUALS', "OTHER", "Options"), "Lethal C4 Radius", 0, 280, 213, 290); --change "280" to a higher number if its overlaps with some other groupbox
  4. local check = gui.Checkbox(box, "check", "Active", 1)
  5. local health_wanted = gui.Slider(box, "health_wanted", "Health Left in % from Current Health", 1, 0, 100);
  6. local slider_r = gui.Slider(box, "slider_r", "Red", 221, 0, 255);
  7. local slider_g = gui.Slider(box, "slider_g", "Green", 33, 0, 255);
  8. local slider_b = gui.Slider(box, "slider_b", "Blue", 33, 0, 255);
  9. local slider_a = gui.Slider(box, "slider_a", "Alpha", 80, 0, 255);
  10.  
  11. function calc_dmg(Bomb, Player,BombZ,PlayerZ)
  12.  
  13. local bro_idk = 1
  14. if(engine.GetMapName() == "de_nuke") then
  15. bro_idk = 2.135
  16. else
  17. bro_idk = 1
  18. end
  19.  
  20. Gauss = (math.sqrt((C4Distance^2)+((BombZ-PlayerZ)^2)) - 75.68) / 789.2
  21. local flDamage = 450.7/bro_idk * math.exp(-Gauss * Gauss);
  22.  
  23. if Player:GetProp("m_ArmorValue") > 0 then
  24. local flArmorRatio = 0.5;
  25. local flArmorBonus = 0.5;
  26.  
  27. if Player:GetProp("m_ArmorValue") > 0 then
  28. local flNew = flDamage * flArmorRatio;
  29. local flArmor = (flDamage - flNew) * flArmorBonus;
  30.  
  31. if flArmor > Player:GetProp("m_ArmorValue") then
  32. flArmor = Player:GetProp("m_ArmorValue") * (1 / flArmorBonus);
  33. flNew = flDamage - flArmor;
  34. end
  35.  
  36. flDamage = flNew;
  37. end
  38. end
  39.  
  40. return math.max(flDamage, 0);
  41. end
  42.  
  43. local function drawCircle(x, y, z, radius, thickness, quality)
  44. local quality = quality or 20
  45. local thickness = thickness or 8
  46. local Screen_X_Line_Old, Screen_Y_Line_Old
  47. for rot = 0, 360, quality do
  48. local rot_temp = math.rad(rot)
  49. local LineX, LineY, LineZ = radius * math.cos(rot_temp) + x, radius * math.sin(rot_temp) + y, z
  50. local Screen_X_Line, Screen_Y_Line = client.WorldToScreen(LineX, LineY, LineZ)
  51. if Screen_X_Line ~= nil and Screen_X_Line_Old ~= nil then
  52. draw.SetFont(draw.CreateFont("Tahoma", 12));
  53. draw.Line(Screen_X_Line, Screen_Y_Line, Screen_X_Line_Old, Screen_Y_Line_Old)
  54. for i = 0, thickness do
  55. draw.Line(Screen_X_Line, Screen_Y_Line + i, Screen_X_Line_Old, Screen_Y_Line_Old + i)
  56. end
  57. end
  58. Screen_X_Line_Old, Screen_Y_Line_Old = Screen_X_Line, Screen_Y_Line
  59. end
  60. end
  61.  
  62. callbacks.Register("Draw", function()
  63.  
  64. if check:GetValue() then
  65. local healthW = math.floor(health_wanted:GetValue())/100
  66. local local_player = entities.GetLocalPlayer();
  67. local bomb = entities.FindByClass("CPlantedC4")[1];
  68.  
  69. if (bomb == nil or local_player == nil or not local_player:IsAlive()) then return end
  70.  
  71. if not (bomb:GetProp("m_bBombTicking") and bomb:GetProp("m_bBombDefused") == 0 and globals.CurTime() < bomb:GetProp("m_flC4Blow")) then
  72. return
  73. end
  74. local bomb_origin_x, bomb_origin_y, bomb_origin_z = bomb:GetAbsOrigin()
  75. local player_origin_x, player_origin_y, player_origin_z = local_player:GetAbsOrigin()
  76. local damage
  77. local radius = 0
  78.  
  79.  
  80. repeat
  81. damage = calc_dmg(bomb, local_player,bomb_origin_z,player_origin_z)
  82. health_left = local_player:GetHealth() - damage
  83. print(local_player:GetHealth()*healthW,math.floor(health_left+0.5))
  84. if math.floor(health_left) < local_player:GetHealth()*healthW then
  85. C4Distance = C4Distance + 1
  86. end
  87.  
  88. if math.floor(health_left) > local_player:GetHealth()*healthW and math.floor(health_left) ~= local_player:GetHealth()*healthW then
  89. C4Distance = C4Distance - 1
  90. end
  91. until (C4Distance == 1500 or health_left > 0)
  92.  
  93. radius = C4Distance
  94.  
  95. -- thick circle
  96. --print(C4Distance,(math.sqrt((C4Distance^2)+((bomb_origin_z-player_origin_z)^2))),health_left)
  97. draw.Color(slider_r:GetValue(), slider_g:GetValue(), slider_b:GetValue(), slider_a:GetValue());
  98. drawCircle(bomb_origin_x, bomb_origin_y, player_origin_z, radius, 10, 1)
  99. end
  100. end)
  101.  
  102. client.AllowListener('bomb_exploded')
  103. client.AllowListener('round_start')
  104. callbacks.Register('FireGameEvent', function(event)
  105. if (event:GetName() == "bomb_exploded" or event:GetName() == "round_start") then
  106. C4Distance = 0
  107. end
  108. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement