Advertisement
Guest User

BodyAimDmg

a guest
May 22nd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.42 KB | None | 0 0
  1. local type=type;local setmetatable=setmetatable;local tostring=tostring;local a=math.pi;local b=math.min;local c=math.max;local d=math.deg;local e=math.rad;local f=math.sqrt;local g=math.sin;local h=math.cos;local i=math.atan;local j=math.acos;local k=math.fmod;local l={}l.__index=l;function Vector3(m,n,o)if type(m)~="number"then m=0.0 end;if type(n)~="number"then n=0.0 end;if type(o)~="number"then o=0.0 end;m=m or 0.0;n=n or 0.0;o=o or 0.0;return setmetatable({x=m,y=n,z=o},l)end;function l.__eq(p,q)return p.x==q.x and p.y==q.y and p.z==q.z end;function l.__unm(p)return Vector3(-p.x,-p.y,-p.z)end;function l.__add(p,q)local r=type(p)local s=type(q)if r=="table"and s=="table"then return Vector3(p.x+q.x,p.y+q.y,p.z+q.z)elseif r=="table"and s=="number"then return Vector3(p.x+q,p.y+q,p.z+q)elseif r=="number"and s=="table"then return Vector3(p+q.x,p+q.y,p+q.z)end end;function l.__sub(p,q)local r=type(p)local s=type(q)if r=="table"and s=="table"then return Vector3(p.x-q.x,p.y-q.y,p.z-q.z)elseif r=="table"and s=="number"then return Vector3(p.x-q,p.y-q,p.z-q)elseif r=="number"and s=="table"then return Vector3(p-q.x,p-q.y,p-q.z)end end;function l.__mul(p,q)local r=type(p)local s=type(q)if r=="table"and s=="table"then return Vector3(p.x*q.x,p.y*q.y,p.z*q.z)elseif r=="table"and s=="number"then return Vector3(p.x*q,p.y*q,p.z*q)elseif r=="number"and s=="table"then return Vector3(p*q.x,p*q.y,p*q.z)end end;function l.__div(p,q)local r=type(p)local s=type(q)if r=="table"and s=="table"then return Vector3(p.x/q.x,p.y/q.y,p.z/q.z)elseif r=="table"and s=="number"then return Vector3(p.x/q,p.y/q,p.z/q)elseif r=="number"and s=="table"then return Vector3(p/q.x,p/q.y,p/q.z)end end;function l.__tostring(p)return"( "..p.x..", "..p.y..", "..p.z.." )"end;function l:clear()self.x=0.0;self.y=0.0;self.z=0.0 end;function l:unpack()return self.x,self.y,self.z end;function l:length_2d_sqr()return self.x*self.x+self.y*self.y end;function l:length_sqr()return self.x*self.x+self.y*self.y+self.z*self.z end;function l:length_2d()return f(self:length_2d_sqr())end;function l:length()return f(self:length_sqr())end;function l:dot(t)return self.x*t.x+self.y*t.y+self.z*t.z end;function l:cross(t)return Vector3(self.y*t.z-self.z*t.y,self.z*t.x-self.x*t.z,self.x*t.y-self.y*t.x)end;function l:dist_to(t)return(t-self):length()end;function l:is_zero(u)u=u or 0.001;if self.x<u and self.x>-u and self.y<u and self.y>-u and self.z<u and self.z>-u then return true end;return false end;function l:normalize()local v=self:length()if v<=0.0 then return 0.0 end;self.x=self.x/v;self.y=self.y/v;self.z=self.z/v;return v end;function l:normalize_no_len()local v=self:length()if v<=0.0 then return end;self.x=self.x/v;self.y=self.y/v;self.z=self.z/v end;function l:normalized()local v=self:length()if v<=0.0 then return Vector3()end;return Vector3(self.x/v,self.y/v,self.z/v)end;function clamp(w,x,y)if w<x then return x elseif w>y then return y end;return w end;function normalize_angle(z)local A;local B;B=tostring(z)if B=="nan"or B=="inf"then return 0.0 end;if z>=-180.0 and z<=180.0 then return z end;A=k(k(z+360.0,360.0),360.0)if A>180.0 then A=A-360.0 end;return A end;function vector_to_angle(C)local v;local D;local E;v=C:length()if v>0.0 then D=d(i(-C.z,v))E=d(i(C.y,C.x))else if C.x>0.0 then D=270.0 else D=90.0 end;E=0.0 end;return Vector3(D,E,0.0)end;function angle_forward(z)local F=g(e(z.x))local G=h(e(z.x))local H=g(e(z.y))local I=h(e(z.y))return Vector3(G*I,G*H,-F)end;function angle_right(z)local F=g(e(z.x))local G=h(e(z.x))local H=g(e(z.y))local I=h(e(z.y))local J=g(e(z.z))local K=h(e(z.z))return Vector3(-1.0*J*F*I+-1.0*K*-H,-1.0*J*F*H+-1.0*K*I,-1.0*J*G)end;function angle_up(z)local F=g(e(z.x))local G=h(e(z.x))local H=g(e(z.y))local I=h(e(z.y))local J=g(e(z.z))local K=h(e(z.z))return Vector3(K*F*I+-J*-H,K*F*H+-J*I,K*G)end;function get_FOV(L,M,N)local O;local P;local Q;local R;P=angle_forward(L)Q=(N-M):normalized()R=j(P:dot(Q)/Q:length())return c(0.0,d(R))end
  2. local ui_set_visible, globals_absoluteframetime, globals_frametime, globals_tickinterval, get_prop, ui_get, sqrt, sin, cos, get_local_player, get_all_players, get_player_name, get_screen_size, draw_text, client_console_cmd, client_delay_call, get_player_name, get_classname, get_local_player, globals_realtime, globals_tickcount = ui.set_visible, globals.absoluteframetime, globals.frametime, globals.tickinterval, entity.get_prop, ui.get, math.sqrt, math.sin, math.cos, entity.get_local_player, entity.get_players, entity.get_player_name, client.screen_size, client.draw_text, client.exec, client.delay_call, entity.get_player_name, entity.get_classname, entity.get_local_player, globals.realtime, globals.tickcount
  3. local table_insert, table_remove, math_floor, math_sqrt, math_min, math_abs  = table.insert, table.remove, math.floor, math.sqrt, math.min, math.abs
  4. local entity_is_enemy, entity_is_alive, entity_is_dormant = entity.is_enemy, entity.is_alive, entity.is_dormant
  5. local ui_new_checkbox, ui_new_slider, ui_new_combobox, ui_new_multiselect = ui.new_checkbox, ui.new_slider, ui.new_combobox, ui.new_multiselect
  6. local getvar, setvar = client.get_cvar, client.set_cvar
  7. local ui_set, ui_ref, c_event_cb, ui_cb, ui_color_picker = ui.set, ui.reference, client.set_event_callback, ui.set_callback, ui.new_color_picker
  8.  
  9.  
  10. local ui_set_callback, ui_set_visible, globals_absoluteframetime, globals_frametime, globals_tickinterval, get_prop, ui_get, sqrt, sin, cos, get_local_player, get_all_players, get_player_name, get_screen_size, draw_text, client_console_cmd, client_delay_call, get_player_name, get_classname, get_local_player, globals_realtime, globals_tickcount = ui.set_callback, ui.set_visible, globals.absoluteframetime, globals.frametime, globals.tickinterval, entity.get_prop, ui.get, math.sqrt, math.sin, math.cos, entity.get_local_player, entity.get_players, entity.get_player_name, client.screen_size, client.draw_text, client.exec, client.delay_call, entity.get_player_name, entity.get_classname, entity.get_local_player, globals.realtime, globals.tickcount
  11. local table_insert, table_remove, math_floor, math_sqrt, math_min, math_abs  = table.insert, table.remove, math.floor, math.sqrt, math.min, math.abs
  12. local entity_is_enemy, entity_is_alive, entity_is_dormant = entity.is_enemy, entity.is_alive, entity.is_dormant
  13. local ui_new_checkbox, ui_new_slider, ui_new_combobox, ui_new_multiselect = ui.new_checkbox, ui.new_slider, ui.new_combobox, ui.new_multiselect
  14. local getvar, setvar = client.get_cvar, client.set_cvar
  15.  
  16.  
  17. local body_aim = ui_new_checkbox("LUA", "A", "Bodyaim if lethal")
  18. local body_aim_indic = ui_new_checkbox("LUA", "A", "Bodyaim indicator")
  19. local body_aim_logs = ui_new_checkbox("LUA", "A", "Bodyaim logs")
  20. local body_aim_hp = ui_new_slider("LUA", "A", "Bodyaim if hp is less then", 0, 100)
  21. local ba_md_def_m = ui_new_combobox("LUA", "A", "Default bodyaim mode", "Off", "Always on", "Moving targets", "Aggressive", "High inaccuracy")
  22. local ba_md_op = ui_new_checkbox("LUA", "A", "Bodyaim damage optimization")
  23. local ba_md_def_e = ui_new_slider("LUA", "A", "BDO enables at ", 0, 100, 20, true, "hp")
  24. local ba_md_def = ui_new_slider("LUA", "A", "BDO default damage", 0, 106)
  25.  
  26. local ref_target_hitbox = ui.reference("rage", "aimbot", "target hitbox")
  27. local ref_bodyaim = ui.reference("Rage", "Other", "Prefer body aim")
  28. local r_mindmg = ui.reference("Rage", "Aimbot", "Minimum damage")
  29.  
  30. local is_baiming = false
  31. local bdo_active = false
  32. local function runMenuThings()
  33.     ui_set_visible(body_aim_hp, ui_get(body_aim))
  34.     ui_set_visible(body_aim_logs, ui_get(body_aim))
  35.     ui_set_visible(body_aim_indic, ui_get(body_aim))
  36.     ui_set_visible(ba_md_def_m, ui_get(body_aim))
  37.     ui_set_visible(ba_md_def, ui_get(ba_md_op))
  38.     ui_set_visible(ba_md_def_e, ui_get(ba_md_op))
  39. end
  40.  
  41. runMenuThings()
  42.  
  43. local function enable_baim()
  44.     local hitboxes = ui_get(ref_target_hitbox)
  45.     for i=1, #hitboxes do
  46.         if hitboxes[i] == "Head" then
  47.             table_remove(hitboxes, i)
  48.             break
  49.         end
  50.     end
  51.     is_baiming = true
  52.     if ui_get(body_aim_logs) then
  53.         client.log("Succesfully enabled baim")
  54.     end
  55.     ui.set(ref_target_hitbox, hitboxes)
  56. end
  57.  
  58. local function disable_baim()
  59.     local hitboxes = ui_get(ref_target_hitbox)
  60.     table_insert(hitboxes, "Head")
  61.     if ui_get(body_aim_logs) then
  62.         client.log("Succesfully disabled baim")
  63.     end
  64.     is_baiming = false
  65.     ui.set(ref_target_hitbox, hitboxes)
  66.     ui.set(ref_bodyaim, ui_get(ba_md_def_m))
  67. end
  68.  
  69. local function run_cmd()
  70.     if (ui_get(body_aim)) then
  71.     local local_player = get_local_player()
  72.    
  73.     if local_player == nil or not entity.is_alive(local_player) then
  74.         return
  75.     end
  76.    
  77.     local v_origin_local = Vector3(get_prop(local_player, "m_vecAbsOrigin"))
  78.     if v_origin_local.x == nil then
  79.         return
  80.     end
  81.    
  82.     local players = get_all_players(true)
  83.     local closestplayer = nil
  84.     local pitch, yaw, roll = client.camera_angles()
  85.     local cam_angle = Vector3(pitch, yaw, 0)
  86.  
  87.     local fov = 180 -- get all players and calc closest
  88.     if ui_get(ba_md_op) then
  89.        
  90.     end
  91.     for i=1, #players do
  92.         local entindex = players[i]
  93.         if entity_is_enemy(entindex) and entity_is_alive(entindex) and not entity_is_dormant(entindex) then
  94.             local v_origin_enemy = Vector3(entity.get_prop(entindex, "m_vecOrigin"))
  95.             local cur_fov = get_FOV(cam_angle, v_origin_local, v_origin_enemy)
  96.             if cur_fov < fov then
  97.                 fov = cur_fov
  98.                 closestplayer = entindex
  99.             end
  100.         end
  101.     end
  102.    
  103.     if closestplayer ~= nil then
  104.         local localplayer = entity.get_local_player()
  105.         local closestplayer_hp = entity.get_prop(closestplayer, "m_iHealth")
  106.         if (closestplayer_hp <= ui_get(body_aim_hp)) then
  107.             if ui_get(body_aim_logs) then
  108.                 client.log("Body aiming " .. entity.get_player_name(closestplayer) .. " - " .. closestplayer_hp)
  109.             end
  110.             if ui_get(ba_md_op) and closestplayer_hp <= ui_get(ba_md_def_e) then
  111.                 ui.set(r_mindmg, closestplayer_hp)
  112.                 bdo_active = true
  113.             end
  114.             enable_baim()
  115.         else
  116.             --ui.set(ref_bodyaim, "On hotkey") --doesnt work cuz idk
  117.             ui.set(r_mindmg, ui_get(ba_md_def))
  118.             disable_baim()
  119.         end
  120.     else
  121.         if ui_get(ba_md_op) then
  122.             ui.set(r_mindmg, ui_get(ba_md_def))
  123.         end
  124.         bdo_active = false
  125.         disable_baim()
  126.     end
  127.     end
  128. end
  129. client.set_event_callback("paint", function()
  130.     if (is_baiming) and ui_get(body_aim_indic) then
  131.         renderer.indicator(140, 244, 66, 255, "BAIM")
  132.     end
  133.     if (bdo_active) and ui_get(body_aim_indic) and (is_baiming) then
  134.         renderer.indicator(66, 134, 244, 255, "BDO Active")
  135.     end
  136. end)
  137.  
  138. ui.set_callback(body_aim, function()
  139.     runMenuThings()
  140. end)
  141. ui.set_callback(ba_md_op, function()
  142.     runMenuThings()
  143. end)
  144.  
  145. client.set_event_callback("run_command", run_cmd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement