-- ============================================================ -- PHANTOM AA v1.0 - Powerful Anti-Aim System for Gamesense -- Based on emberlash.lua patterns & architecture -- ============================================================ ---@diagnostic disable: undefined-global -- ============================================================ -- MODULE LOADING (safe require with fallback) -- ============================================================ local function safe_require(name) local ok, mod = pcall(require, name) return ok and mod or nil end local vector = safe_require('vector') local aa_func = safe_require('gamesense/antiaim_funcs') local trace = safe_require('gamesense/trace') -- ============================================================ -- BUILT-IN GAMESENSE AA REFERENCES -- These are the internal Gamesense controls we override -- each tick to drive the anti-aim angles -- ============================================================ local ref = {} local function try_ref(tab, group, name) local ok, r = pcall(ui.reference, tab, group, name) return ok and r or nil end ref.aa_enabled = try_ref("AA", "Anti-aimbot angles", "Enabled") ref.pitch = try_ref("AA", "Anti-aimbot angles", "Pitch") ref.pitch_val = try_ref("AA", "Anti-aimbot angles", "Pitch value") ref.yaw = try_ref("AA", "Anti-aimbot angles", "Yaw") ref.yaw_base = try_ref("AA", "Anti-aimbot angles", "Yaw base") ref.yaw_offset = try_ref("AA", "Anti-aimbot angles", "Yaw offset") ref.yaw_jitter = try_ref("AA", "Anti-aimbot angles", "Yaw jitter") ref.body_yaw = try_ref("AA", "Anti-aimbot angles", "Body yaw") ref.body_val = try_ref("AA", "Anti-aimbot angles", "Body yaw value") ref.freestand = try_ref("AA", "Anti-aimbot angles", "Freestanding") ref.edge_yaw = try_ref("AA", "Anti-aimbot angles", "Edge yaw") ref.fl_enabled = try_ref("AA", "Fake lag", "Enabled") ref.fl_amount = try_ref("AA", "Fake lag", "Amount") ref.fl_limit = try_ref("AA", "Fake lag", "Limit") ref.fl_variance = try_ref("AA", "Fake lag", "Variance") ref.on_shot = try_ref("AA", "Other", "On shot anti-aim") ref.slow_motion = try_ref("AA", "Other", "Slow motion") local function set_ref(r, v) if r then ui.set(r, v) end end local function get_ref(r) if r then return ui.get(r) end end -- ============================================================ -- CUSTOM UI - Main toggle & global pitch -- ============================================================ local ui_enabled = ui.new_checkbox("AA", "A", "Enable Phantom AA") local ui_pitch = ui.new_combobox("AA", "A", "Pitch", {"Down", "Up", "Zero", "Custom"}) local ui_pitch_val = ui.new_slider ("AA", "A", "Custom pitch", -89, 89, -89) -- ============================================================ -- PER-STATE CONFIGURATION -- States: Stand / Run / Walk / Crouch / Sneak / Air / Air+ -- ============================================================ local STATES = {"Stand", "Run", "Walk", "Crouch", "Sneak", "Air", "Air+"} local cfg = {} -- cfg[state] = { yaw_mode, offset, jitter, ... } for _, s in ipairs(STATES) do cfg[s] = { yaw_base = ui.new_combobox ("AA", "A", s.." yaw base", {"Local view", "At targets", "Away from targets"}), yaw_mode = ui.new_combobox ("AA", "A", s.." yaw mode", {"Static", "Jitter", "X-Way", "Skitter", "Spin", "Random"}), yaw_offset = ui.new_slider ("AA", "A", s.." yaw offset", -180, 180, 180), jitter_amt = ui.new_slider ("AA", "A", s.." jitter", 0, 180, 58), body_mode = ui.new_combobox ("AA", "A", s.." body yaw", {"Off", "Static", "Freestanding", "Jitter"}), body_val = ui.new_slider ("AA", "A", s.." body value", -180, 180, 58), fs_body_yaw = ui.new_checkbox ("AA", "A", s.." freestand body yaw"), fl_amount = ui.new_slider ("AA", "A", s.." fakelag", 0, 14, 0), fl_variance = ui.new_slider ("AA", "A", s.." fl variance", 0, 7, 0), } end -- ============================================================ -- MANUAL DIRECTION HOTKEYS -- ============================================================ local ui_manual_left = ui.new_hotkey("AA", "B", "Manual left", false) local ui_manual_right = ui.new_hotkey("AA", "B", "Manual right", false) local ui_manual_back = ui.new_hotkey("AA", "B", "Manual back", false) local ui_inverter = ui.new_hotkey("AA", "B", "Inverter", false) local ui_freestand_hk = ui.new_hotkey("AA", "B", "Force freestanding", false) local ui_edge_yaw_hk = ui.new_hotkey("AA", "B", "Force edge yaw", false) local ui_slow_walk_hk = ui.new_hotkey("AA", "B", "Slow walk", false) -- ============================================================ -- SETTINGS FLAGS -- ============================================================ local ui_settings = ui.new_multiselect("AA", "B", "Settings", { "Anti backstab", "Safe head", "Safe head height advantage", "Spin on warmup", "Spin when enemies dead", "Fast ladder", "Bombsite fix", "Low ping disable defensive", }) local ui_on_shot = ui.new_combobox("AA", "B", "On shot AA", {"Off", "Jitter", "Switch", "Spin"}) local ui_on_shot_j = ui.new_slider ("AA", "B", "On shot jitter", 0, 180, 58) -- ============================================================ -- VISUALS -- ============================================================ local ui_arrows = ui.new_checkbox("AA", "C", "Desync arrows") local ui_arrows_style = ui.new_combobox("AA", "C", "Arrow style", {"Pointers", "Semicircle"}) local ui_arrows_color = ui.new_color_picker("AA", "C", "Arrow color", 136, 93, 252, 230) local ui_state_ind = ui.new_checkbox("AA", "C", "State indicator") local ui_watermark = ui.new_checkbox("AA", "C", "Watermark") -- ============================================================ -- INTERNAL STATE -- ============================================================ local aa_state = "Stand" local is_on_ground = false local desync_side = 1 -- 1 = right, -1 = left local manual_dir = 0 -- 0=off 1=left 2=right 3=back local anti_backstab = false local xway_idx = 1 local xway_tick = 0 local lby_flip_side = 1 -- ============================================================ -- HELPERS -- ============================================================ local function clamp(v, lo, hi) return math.max(lo, math.min(hi, v)) end local function normalize_yaw(y) while y > 180 do y = y - 360 end while y < -180 do y = y + 360 end return y end local function get_speed(me) local vx, vy = entity.get_prop(me, "m_vecVelocity") if not vx then return 0 end return math.sqrt(vx * vx + vy * vy) end -- ============================================================ -- STATE DETECTION (Stand / Run / Walk / Crouch / Sneak / Air / Air+) -- ============================================================ local function get_state() local me = entity.get_local_player() if not me or not entity.is_alive(me) then return "Stand" end local flags = entity.get_prop(me, "m_fFlags") or 0 local on_gnd = bit.band(flags, 1) == 1 local duck = entity.get_prop(me, "m_flDuckAmount") or 0 local speed = get_speed(me) if not on_gnd then return (duck >= 0.9) and "Air+" or "Air" end if duck >= 0.85 then return (speed > 8) and "Sneak" or "Crouch" end -- Walk = slow_walk hotkey OR speed 1..110 if ui.get(ui_slow_walk_hk) then return "Walk" end if speed > 110 then return "Run" end if speed > 8 then return "Walk" end return "Stand" end -- ============================================================ -- FREESTANDING DETECTION -- Casts rays left/right of view to find which side is more open -- Returns 1 (right-side open) or -1 (left-side open) -- ============================================================ local function get_freestand_side() local me = entity.get_local_player() if not me then return 1 end local ex, ey, ez = client.eye_position() if not ex then return 1 end local _, view_yaw = client.camera_angles() local eye = {x = ex, y = ey, z = ez} local left_sum, right_sum = 0, 0 for angle_offset = 10, 120, 10 do local function cast(deg) local rad = math.rad(deg) local tx = ex + 512 * math.cos(rad) local ty = ey + 512 * math.sin(rad) return client.trace_line(me, ex, ey, ez, tx, ty, ez) end left_sum = left_sum + cast(view_yaw - angle_offset) right_sum = right_sum + cast(view_yaw + angle_offset) end -- More fraction = less blocked = more open return (left_sum > right_sum) and -1 or 1 end -- ============================================================ -- MANUAL DIRECTION -- Returns: 0=none, 1=left, 2=right, 3=back -- ============================================================ local function get_manual() if ui.get(ui_manual_back) then return 3 end if ui.get(ui_manual_left) then return 1 end if ui.get(ui_manual_right) then return 2 end return 0 end -- ============================================================ -- DESYNC SIDE TRACKER -- Tracks current fake side for arrow rendering -- ============================================================ local function update_desync_side(body_mode, body_value) if body_mode == "Static" then desync_side = (body_value >= 0) and 1 or -1 elseif body_mode == "Freestanding" then desync_side = get_freestand_side() end end -- ============================================================ -- ANTI-BACKSTAB CHECK -- If an enemy with a knife is close and behind us → rotate away -- ============================================================ local function check_backstab() local me = entity.get_local_player() if not me then return false end local mx, my, mz = entity.get_origin(me) if not mx then return false end for _, ent in ipairs(entity.get_players(true)) do local weapon = entity.get_player_weapon(ent) if weapon and entity.get_classname(weapon) == "CKnife" then local ex, ey, ez = entity.get_origin(ent) if ex then local dx, dy = mx - ex, my - ey local dist = math.sqrt(dx * dx + dy * dy) if dist < 500 then -- Check if enemy can reach our back local eyex, eyey, eyez = client.eye_position() if eyex then local frac, hit = client.trace_line(ent, ex, ey, ez, eyex, eyey, eyez) if hit == me or frac >= 0.97 then return true end end end end end end return false end -- ============================================================ -- COMPUTE ANGLES (called every setup_command tick) -- Returns a table: { pitch, pitch_val, yaw, yaw_base, -- offset, jitter, body, body_val } -- ============================================================ local function compute_angles(state) local c = cfg[state] or cfg["Stand"] -- Retrieve config values local yaw_base = ui.get(c.yaw_base) local yaw_mode = ui.get(c.yaw_mode) local yaw_offset = ui.get(c.yaw_offset) local jitter_amt = ui.get(c.jitter_amt) local body_mode = ui.get(c.body_mode) local body_val = ui.get(c.body_val) -- Map combobox strings to Gamesense reference values local base_map = { ["Local view"] = "Local View", ["At targets"] = "At Targets", ["Away from targets"] = "Away from Targets", } local yaw_map = { ["Static"] = "Static", ["Jitter"] = "Jitter", ["X-Way"] = "Static", -- handled manually ["Skitter"] = "Static", -- handled manually ["Spin"] = "Spinbot", ["Random"] = "Random", } local body_map = { ["Off"] = "Off", ["Static"] = "Static", ["Freestanding"] = "Freestanding", ["Jitter"] = "Static", -- jitter handled via offset flipping } -- Global pitch local pitch_mode = ui.get(ui_pitch) local pitch_value = ui.get(ui_pitch_val) local pitch_gs = pitch_mode -- "Down" / "Up" / "Zero" / "Custom" -- Manual override local manual = get_manual() if manual ~= 0 then yaw_base = "Local View" yaw_mode = "Static" if manual == 1 then yaw_offset = -90 -- left elseif manual == 2 then yaw_offset = 90 -- right elseif manual == 3 then yaw_offset = 180 -- back end body_mode = "Static" body_val = 58 end -- Inverter hotkey flips body side if ui.get(ui_inverter) then body_val = -body_val yaw_offset = -yaw_offset end -- X-Way / Skitter: alternate offset each tick local final_offset = yaw_offset if yaw_mode == "X-Way" then -- 3-way: offset, +jitter, -jitter local ways = {yaw_offset, yaw_offset + jitter_amt, yaw_offset - jitter_amt} xway_tick = xway_tick + 1 if xway_tick >= 2 then xway_tick = 0 xway_idx = (xway_idx % #ways) + 1 end final_offset = ways[xway_idx] or yaw_offset jitter_amt = 0 elseif yaw_mode == "Skitter" then -- Skitter: random small extra offset on every other tick xway_tick = xway_tick + 1 if xway_tick >= 2 then xway_tick = 0 local skitter = client.random_int(-35, 35) final_offset = yaw_offset + skitter end jitter_amt = 0 end -- Body jitter mode: flip side every tick local final_body_val = body_val if body_mode == "Jitter" then lby_flip_side = -lby_flip_side final_body_val = math.abs(body_val) * lby_flip_side end update_desync_side(body_mode, final_body_val) return { pitch = pitch_gs, pitch_val = pitch_value, yaw = yaw_map[yaw_mode] or "Static", yaw_base = base_map[yaw_base] or "Local View", offset = clamp(final_offset, -180, 180), jitter = clamp(jitter_amt, 0, 180), body = body_map[body_mode] or "Off", body_val = clamp(final_body_val, -180, 180), fs_body = ui.get(c.fs_body_yaw), fl_amount = ui.get(c.fl_amount), fl_var = ui.get(c.fl_variance), } end -- ============================================================ -- APPLY ANGLES (called inside setup_command) -- ============================================================ local function apply_angles(a) -- Pitch if ref.pitch then set_ref(ref.pitch, a.pitch) end if ref.pitch_val and a.pitch == "Custom" then set_ref(ref.pitch_val, a.pitch_val) end -- Yaw if ref.yaw then set_ref(ref.yaw, a.yaw) end if ref.yaw_base then set_ref(ref.yaw_base, a.yaw_base) end if ref.yaw_offset then set_ref(ref.yaw_offset, a.offset) end if ref.yaw_jitter then set_ref(ref.yaw_jitter, a.jitter) end -- Body yaw if ref.body_yaw then set_ref(ref.body_yaw, a.body) end if ref.body_val then set_ref(ref.body_val, a.body_val) end -- Freestanding & Edge yaw hotkeys if ref.freestand then set_ref(ref.freestand, ui.get(ui_freestand_hk)) end if ref.edge_yaw then set_ref(ref.edge_yaw, ui.get(ui_edge_yaw_hk)) end -- Fake lag local fl = a.fl_amount if ref.fl_enabled then set_ref(ref.fl_enabled, fl > 0) end if ref.fl_amount then set_ref(ref.fl_amount, fl > 0 and "Custom" or "Dynamic") end if ref.fl_limit then set_ref(ref.fl_limit, fl) end if ref.fl_variance then set_ref(ref.fl_variance, a.fl_var) end end -- ============================================================ -- SPECIAL OVERRIDES -- (anti-backstab / safe-head / spin / bombsite fix) -- Called AFTER apply_angles to override per-special-case -- ============================================================ local function apply_specials(e) local me = entity.get_local_player() if not me then return end local settings = ui.get(ui_settings) local function has(flag) for _, v in ipairs(settings) do if v == flag then return true end end return false end -- ANTI-BACKSTAB if has("Anti backstab") and anti_backstab then set_ref(ref.pitch, "Down") set_ref(ref.yaw_base, "At Targets") set_ref(ref.yaw, "Static") set_ref(ref.yaw_offset, 180) set_ref(ref.yaw_jitter, 0) return end -- SAFE HEAD (knife / taser threat above) if has("Safe head") then local weapon_ent = entity.get_player_weapon(me) local wcls = weapon_ent and entity.get_classname(weapon_ent) or "" local is_knife = wcls == "CKnife" local is_taser = wcls == "CWeaponTaser" local flags = entity.get_prop(me, "m_fFlags") or 0 local in_air = bit.band(flags, 1) == 0 local height_adv = false if has("Safe head height advantage") then local threat = client.current_threat and client.current_threat() if threat then local my_z = select(3, entity.get_origin(me)) or 0 local en_z = select(3, entity.get_origin(threat)) or 0 height_adv = (my_z - en_z) > 100 end end if (is_knife or is_taser or height_adv) and in_air then set_ref(ref.pitch, "Down") set_ref(ref.yaw_base, "At Targets") set_ref(ref.yaw, "Static") set_ref(ref.yaw_offset, 0) set_ref(ref.yaw_jitter, 0) set_ref(ref.body_yaw, "Off") return end end -- SPIN: warmup period if has("Spin on warmup") then local proxy = entity.get_all and entity.get_all("CCSGameRulesProxy") local is_warmup = proxy and proxy[1] and entity.get_prop(proxy[1], "m_bWarmupPeriod") == 1 if is_warmup then set_ref(ref.pitch, "Custom") set_ref(ref.pitch_val, 0) set_ref(ref.yaw, "Spinbot") set_ref(ref.yaw_offset, 0) set_ref(ref.yaw_jitter, 0) set_ref(ref.body_yaw, "Static") set_ref(ref.body_val, 58) set_ref(ref.fl_limit, 6) return end end -- SPIN: no enemies alive if has("Spin when enemies dead") then local alive = 0 for i = 1, globals.maxplayers() do if entity.get_classname(i) == "CCSPlayer" and entity.is_alive(i) and entity.is_enemy(i) then alive = alive + 1 end end if alive == 0 then set_ref(ref.pitch, "Custom") set_ref(ref.pitch_val, 0) set_ref(ref.yaw, "Spinbot") set_ref(ref.yaw_offset, 30) set_ref(ref.yaw_jitter, 0) set_ref(ref.body_yaw, "Static") set_ref(ref.body_val, 58) set_ref(ref.fl_limit, 6) return end end -- FAST LADDER if has("Fast ladder") then local move_type = entity.get_prop(me, "m_MoveType") if move_type == 9 then -- MOVETYPE_LADDER if e.forwardmove and e.forwardmove > 0 then e.pitch = 89 e.in_back = 1 e.in_forward = 0 elseif e.forwardmove and e.forwardmove < 0 then e.pitch = 89 e.in_forward = 1 e.in_back = 0 end return end end -- BOMBSITE FIX (T-side: prevent bomb drop on 'E') if has("Bombsite fix") then if entity.get_prop(me, "m_iTeamNum") == 2 then if entity.get_prop(me, "m_bInBombZone") and entity.get_prop(me, "m_bInBombZone") > 0 then local weapon_ent = entity.get_player_weapon(me) local wcls = weapon_ent and entity.get_classname(weapon_ent) or "" if e.buttons and bit.band(e.buttons, 32) == 32 and wcls ~= "CC4" then e.buttons = bit.band(e.buttons, bit.bnot(32)) set_ref(ref.yaw_base, "Local View") set_ref(ref.yaw, "Static") set_ref(ref.yaw_offset, 180) set_ref(ref.body_yaw, "Static") set_ref(ref.body_val, 1) end end end end end -- ============================================================ -- ON-SHOT AA OVERRIDE -- Applied when the player fires (hideshots / double-tap) -- ============================================================ local function apply_on_shot() local mode = ui.get(ui_on_shot) if mode == "Off" or not ref.on_shot then return end if mode == "Jitter" then set_ref(ref.on_shot, "Jitter") elseif mode == "Switch" then set_ref(ref.on_shot, "Switch") elseif mode == "Spin" then set_ref(ref.on_shot, "Spinbot") end end -- ============================================================ -- SETUP_COMMAND CALLBACK - Main AA tick -- ============================================================ local function on_setup_command(e) if not ui.get(ui_enabled) then return end local me = entity.get_local_player() if not me or not entity.is_alive(me) then return end -- Detect state aa_state = get_state() anti_backstab = check_backstab() -- Enable AA in Gamesense if ref.aa_enabled then set_ref(ref.aa_enabled, true) end -- Compute & apply angles for current state local angles = compute_angles(aa_state) apply_angles(angles) -- Apply specials (overrides happen after base angles) apply_specials(e) -- On-shot override apply_on_shot() end -- ============================================================ -- GROUND TRACKING (used for state detection) -- ============================================================ do local pre_flags = 0 client.set_event_callback("setup_command", function() local me = entity.get_local_player() if me and entity.is_alive(me) then pre_flags = entity.get_prop(me, "m_fFlags") or 0 end end) client.set_event_callback("run_command", function() local me = entity.get_local_player() if me and entity.is_alive(me) then local post = entity.get_prop(me, "m_fFlags") or 0 is_on_ground = bit.band(pre_flags, 1) == 1 and bit.band(post, 1) == 1 end end) end -- Register main AA callback client.set_event_callback("setup_command", on_setup_command) -- ============================================================ -- DESYNC ARROWS RENDERER -- Draws arrows showing real / fake body side -- ============================================================ local function draw_desync_arrows() if not ui.get(ui_arrows) then return end local me = entity.get_local_player() if not me or not entity.is_alive(me) then return end local sw, sh = client.screen_size() local cx, cy = sw / 2, sh / 2 local r, g, b, a = ui.get(ui_arrows_color) local style = ui.get(ui_arrows_style) local size = 12 local gap = 34 if style == "Pointers" then -- Left arrow (real side pointer) local lx = cx - gap - size local ly = cy - size / 2 renderer.triangle(lx, ly + size / 2, lx + size, ly, lx + size, ly + size, r, g, b, desync_side == -1 and a or (a / 3)) -- Right arrow local rx = cx + gap local ry = cy - size / 2 renderer.triangle(rx + size, ry + size / 2, rx, ry, rx, ry + size, r, g, b, desync_side == 1 and a or (a / 3)) elseif style == "Semicircle" then -- Semicircle arc on the desync side local arc_r = 36 local start_a = desync_side == 1 and -90 or 90 renderer.circle_outline(cx, cy, r, g, b, a, arc_r, start_a, 0.5, 2) end -- Manual direction text indicator local manual = get_manual() if manual ~= 0 then local labels = {"", "← LEFT", "RIGHT →", "↓ BACK"} renderer.text(cx, cy - 50, r, g, b, a, "c", 0, labels[manual + 1] or "") end end -- ============================================================ -- STATE INDICATOR (HUD) -- ============================================================ local function draw_state_indicator() if not ui.get(ui_state_ind) then return end local me = entity.get_local_player() if not me or not entity.is_alive(me) then return end local sw, sh = client.screen_size() local x, y = 10, sh - 80 local r, g, b, a = 136, 93, 252, 220 renderer.text(x, y, r, g, b, a, "", 0, "PHANTOM AA") renderer.text(x, y + 14, 200, 200, 200, 180, "", 0, string.format("State: %s", aa_state)) renderer.text(x, y + 26, 200, 200, 200, 180, "", 0, string.format("Side: %s Manual: %d", desync_side == 1 and "Right" or "Left", get_manual())) if anti_backstab then renderer.text(x, y + 40, 255, 80, 80, 220, "", 0, "! ANTI-BACKSTAB") end end -- ============================================================ -- WATERMARK -- ============================================================ local function draw_watermark() if not ui.get(ui_watermark) then return end local sw, _ = client.screen_size() local fps = globals.framecount and "" or "" local ping = "" -- Try to get ping from local player resource local me = entity.get_local_player() if me then local res = entity.get_player_resource(me) if res then local p = entity.get_prop(res, "m_iPing", me) if p then ping = string.format(" | %dms", p) end end end local text = string.format("Phantom AA v1.0%s | %s | %s", ping, aa_state, string.format("%.0f FPS", 1 / math.max(globals.absoluteframetime(), 0.001))) local tw, _ = renderer.measure_text("", text) local x = sw - tw - 10 renderer.rectangle(x - 6, 4, tw + 12, 18, 14, 14, 14, 190) renderer.text(x, 8, 136, 93, 252, 255, "", 0, text) end -- ============================================================ -- PAINT CALLBACK -- ============================================================ client.set_event_callback("paint", function() draw_desync_arrows() draw_state_indicator() draw_watermark() end) -- ============================================================ -- RESET ON DEATH / LEVEL CHANGE -- ============================================================ client.set_event_callback("player_death", function(e) local me = entity.get_local_player() if me and client.userid_to_entindex(e.userid) == me then xway_idx = 1 xway_tick = 0 lby_flip_side = 1 manual_dir = 0 anti_backstab = false end end) client.set_event_callback("level_init", function() xway_idx = 1 xway_tick = 0 lby_flip_side = 1 anti_backstab = false end) -- ============================================================ -- LOAD MESSAGE -- ============================================================ client.color_log(136, 93, 252, "[Phantom AA] ") client.color_log(200, 200, 200, "Loaded successfully! States: ") client.color_log(136, 93, 252, table.concat(STATES, " / ")) client.color_log(200, 200, 200, "\n")