Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local menu = {
- active = ui.new_checkbox("AA", "Other", "Strict enemy checks")
- }
- local function draw_angle(c, name, distance, location_x, location_y, location_z, origin_x, origin_y, yaw, r, g, b, a)
- local location_x_angle = location_x + math.cos(math.rad(yaw)) * distance
- local location_y_angle = location_y + math.sin(math.rad(yaw)) * distance
- local world_x, world_y = client.world_to_screen(c, location_x_angle, location_y_angle, location_z)
- if world_x ~= nil then
- client.draw_line(c, origin_x, origin_y, world_x, world_y, r, g, b, 220)
- client.draw_text(c, world_x, world_y, r, g, b, a, "c-", 0, name)
- end
- end
- local function calc_angle(x_src, y_src, z_src, x_dst, y_dst, z_dst)
- x_delta = x_src - x_dst
- y_delta = y_src - y_dst
- z_delta = z_src - z_dst
- hyp = math.sqrt(x_delta^2 + y_delta^2)
- x = math.atan2(z_delta, hyp) * 57.295779513082
- y = math.atan2( y_delta , x_delta) * 180 / 3.14159265358979323846
- if y > 180 then
- y = y - 180
- end
- if y < -180 then
- y = y + 180
- end
- return y
- end
- local function normalize_angles(angle)
- angle = angle % 360
- angle = (angle + 360) % 360
- if (angle > 180) then
- angle = angle - 360
- end
- return angle
- end
- local function get_near_target()
- local enemy_players = entity.get_players(true)
- if #enemy_players ~= 0 then
- local own_x, own_y, own_z = client.eye_position()
- local own_pitch, own_yaw = client.camera_angles()
- local closest_enemy = nil
- local closest_distance = 999999999
- for i = 1, #enemy_players do
- local enemy = enemy_players[i]
- local enemy_x, enemy_y, enemy_z = entity.get_prop(enemy, "m_vecOrigin")
- local x = enemy_x - own_x
- local y = enemy_y - own_y
- local z = enemy_z - own_z
- local yaw = ((math.atan2(y, x) * 180 / math.pi))
- local pitch = -(math.atan2(z, math.sqrt(math.pow(x, 2) + math.pow(y, 2))) * 180 / math.pi)
- local yaw_dif = math.abs(own_yaw % 360 - yaw % 360) % 360
- local pitch_dif = math.abs(own_pitch - pitch ) % 360
- if yaw_dif > 180 then yaw_dif = 360 - yaw_dif end
- local real_dif = math.sqrt(math.pow(yaw_dif, 2) + math.pow(pitch_dif, 2))
- if closest_distance > real_dif then
- closest_distance = real_dif
- closest_enemy = enemy
- end
- end
- if closest_enemy ~= nil then
- return closest_enemy, closest_distance
- end
- end
- return nil, nil
- end
- -- CALLBACK
- g_pLocal = entity.get_local_player()
- local threat_id, threat_dist = get_near_target()
- if ui_get(menu.active) and (threat_dist and threat_dist <= 15) then
- local x, y, z = entity.get_prop(g_pLocal, "m_vecOrigin")
- if x ~= nil then
- local ent_x, ent_y, ent_z = entity.hitbox_position(threat_id, 0)
- angle = calc_angle(x, y, z, ent_x, ent_y, ent_z) + 180
- if isLeft then
- angle = angle - 130
- elseif isRight then
- angle = angle + 31
- end
- ui_set(aa_yaw, "Static")
- ui_set(aa_num, normalize_angles(angle))
- is_targeting = true
- client.draw_text(c, 12, 700, 243, 125, 124, 255, "-", "200", "THREAT: ", string.upper(entity.get_player_name(threat_id)))
- client.draw_text(c, 12, 710, 255, 255, 255, 255, "-", "200", "DISTANCE: ", round(threat_dist, 0) .. " FT")
- client.draw_text(c, 12, 720, 255, 255, 255, 255, "-", "200", "ANGLE: ", round(angle, 1))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement