const global_print = Global.Print,
global_print_chat = Global.PrintChat,
global_print_color = Global.PrintColor,
global_register_callback = Global.RegisterCallback,
global_execute_command = Global.ExecuteCommand,
global_frame_stage = Global.FrameStage,
global_tickcount = Global.Tickcount,
global_tickrate = Global.Tickrate,
global_tick_interval = Global.TickInterval,
global_curtime = Global.Curtime,
global_realtime = Global.Realtime,
global_frametime = Global.Frametime,
global_latency = Global.Latency,
global_get_view_angles = Global.GetViewAngles,
global_set_view_angles = Global.SetViewAngles,
global_get_map_name = Global.GetMapName,
global_is_key_pressed = Global.IsKeyPressed,
global_get_screen_size = Global.GetScreenSize,
global_get_cursor_position = Global.GetCursorPosition,
global_play_sound = Global.PlaySound,
global_play_microphone = Global.PlayMicrophone,
global_stop_microphone = Global.StopMicrophone,
global_get_username = Global.GetUsername,
global_set_clan_tag = Global.SetClanTag,
globals_tickcount = Globals.Tickcount,
globals_tickrate = Globals.Tickrate,
globals_tick_interval = Globals.TickInterval,
globals_curtime = Globals.Curtime,
globals_realtime = Globals.Realtime,
globals_frametime = Globals.Frametime,
sound_play = Sound.Play,
sound_play_microphone = Sound.PlayMicrophone,
sound_stop_microphone = Sound.StopMicrophone,
cheat_get_username = Cheat.GetUsername,
cheat_register_callback = cheat_register_callback = new Proxy(Cheat.RegisterCallback, {
apply: function(_, _, args) {
switch(args[0]) {
case 'paint':
Cheat.RegisterCallback('Draw', args[1]);
break;
case 'create_move':
Cheat.RegisterCallback('CreateMove', args[1]);
break;
case 'fsn':
Cheat.RegisterCallback('FrameStageNotify', args[1]);
break;
default:
Cheat.RegisterCallback(args[0], args[1]);
break;
}
}
}),
cheat_execute_command = Cheat.ExecuteCommand,
cheat_frame_stage = Cheat.FrameStage,
cheat_print = Cheat.Print,
cheat_print_chat = Cheat.PrintChat,
cheat_print_color = Cheat.PrintColor,
local_latency = Local.Latency,
local_get_view_angles = Local.GetViewAngles,
local_set_view_angles = Local.SetViewAngles,
local_set_clan_tag = Local.SetClanTag,
local_get_real_yaw = Local.GetRealYaw,
local_get_fake_yaw = Local.GetFakeYaw,
local_get_spread = Local.GetSpread,
local_get_inaccuracy = Local.GetInaccuracy,
world_get_map_name = World.GetMapName,
world_get_server_string = World.GetServerString,
input_get_cursor_position = Input.GetCursorPosition,
input_is_key_pressed = Input.IsKeyPressed,
render_string = Render.String,
render_text_size = Render.TextSize,
render_line = Render.Line,
render_rect = Render.Rect,
render_filled_rect = Render.FilledRect,
render_gradient_rect = Render.GradientRect,
render_circle = Render.Circle,
render_filled_circle = Render.FilledCircle,
render_polygon = Render.Polygon,
render_world_to_screen = Render.WorldToScreen,
render_add_font = Render.AddFont,
render_find_font = Render.FindFont,
render_string_custom = Render.StringCustom,
render_textured_rect = Render.TexturedRect,
render_add_texture = Render.AddTexture,
render_text_size_custom = Render.TextSizeCustom,
render_get_screen_size = Render.GetScreenSize,
ui_get_value = UI.GetValue,
ui_set_value = UI.SetValue,
ui_add_checkbox = UI.AddCheckbox,
ui_add_slider_int = UI.AddSliderInt,
ui_add_slider_float = UI.AddSliderFloat,
ui_add_hotkey = UI.AddHotkey,
ui_add_label = UI.AddLabel,
ui_add_dropdown = UI.AddDropdown,
ui_add_multi_dropdown = UI.AddMultiDropdown,
ui_add_color_picker = UI.AddColorPicker,
ui_add_textbox = UI.AddTextbox,
ui_set_enabled = UI.SetEnabled,
ui_get_string = UI.GetString,
ui_is_hotkey_active = UI.IsHotkeyActive,
ui_toggle_hotkey = UI.ToggleHotkey,
ui_is_menu_open = UI.IsMenuOpen,
convar_get_int = Convar.GetInt,
convar_set_int = Convar.SetInt,
convar_get_float = Convar.GetFloat,
convar_set_float = Convar.SetFloat,
convar_get_string = Convar.GetString,
convar_set_string = Convar.SetString,
event_get_int = Event.GetInt,
event_get_float = Event.GetFloat,
event_get_string = Event.GetString,
entity_get_entities = Entity.GetEntities,
entity_get_entities_by_class_i_d = Entity.GetEntitiesByClassID,
entity_get_players = Entity.GetPlayers,
entity_get_enemies = Entity.GetEnemies,
entity_get_teammates = Entity.GetTeammates,
entity_get_local_player = Entity.GetLocalPlayer,
entity_get_game_rules_proxy = Entity.GetGameRulesProxy,
entity_get_entity_from_user_i_d = Entity.GetEntityFromUserID,
entity_is_teammate = Entity.IsTeammate,
entity_is_enemy = Entity.IsEnemy,
entity_is_bot = Entity.IsBot,
entity_is_local_player = Entity.IsLocalPlayer,
entity_is_valid = Entity.IsValid,
entity_is_alive = Entity.IsAlive,
entity_is_dormant = Entity.IsDormant,
entity_get_class_i_d = Entity.GetClassID,
entity_get_class_name = Entity.GetClassName,
entity_get_name = Entity.GetName,
entity_get_weapon = Entity.GetWeapon,
entity_get_weapons = Entity.GetWeapons,
entity_get_render_origin = Entity.GetRenderOrigin,
entity_get_prop = Entity.GetProp,
entity_set_prop = Entity.SetProp,
entity_get_hitbox_position = Entity.GetHitboxPosition,
entity_get_eye_position = Entity.GetEyePosition,
trace_line = Trace.Line,
trace_bullet = Trace.Bullet,
usercmd_set_movement = UserCMD.SetMovement,
usercmd_get_movement = UserCMD.GetMovement,
usercmd_set_angles = UserCMD.SetAngles,
usercmd_force_jump = UserCMD.ForceJump,
usercmd_force_crouch = UserCMD.ForceCrouch,
antiaim_get_override = AntiAim.GetOverride,
antiaim_set_override = AntiAim.SetOverride,
antiaim_set_real_offset = AntiAim.SetRealOffset,
antiaim_set_fake_offset = AntiAim.SetFakeOffset,
antiaim_set_l_b_y_offset = AntiAim.SetLBYOffset,
exploit_get_charge = Exploit.GetCharge,
exploit_recharge = Exploit.Recharge,
exploit_disable_recharge = Exploit.DisableRecharge,
exploit_enable_recharge = Exploit.EnableRecharge,
ragebot_override_minimum_damage = Ragebot.OverrideMinimumDamage,
ragebot_override_hitchance = Ragebot.OverrideHitchance,
ragebot_override_accuracy_boost = Ragebot.OverrideAccuracyBoost,
ragebot_override_multipoint_scale = Ragebot.OverrideMultipointScale,
ragebot_force_safety = Ragebot.ForceSafety;
var menu = {
_class: 'BetterUI'
};
const menu_spacer = " ";
menu.concat = function(a, b) {
var arr = [];
for(var c in a) {
arr.push(a[c]);
}
arr.push(b);
return arr;
}
menu.label = function(label) {
UI.AddLabel(label);
};
menu.call = function(func, name, label, properties) {
const final_name = name + menu_spacer + label;
var final_props = [final_name];
const element_info_t = {
path: ["Misc", "JAVASCRIPT", "Script items", final_name]
};
if(properties != null) {
for(var i = 0; i < properties.length; i++) {
final_props.push(properties[i]);
}
}
func.apply(null, final_props);
return element_info_t;
};
menu.reference = function(path) {
const element_info_t = {
path: path
};
return element_info_t;
};
menu.get = function(elem) {
if(!(elem.path));
return UI.GetValue.apply(null, elem.path);
};
menu.get_hotkey = function(elem) {
if(!(elem.path));
return UI.IsHotkeyActive.apply(null, elem.path);
};
menu.toggle = function(elem) {
if(!(elem.path));
UI.ToggleHotkey.apply(null, elem.path);
};
menu.visibility = function(elem, visible) {
if(!(elem.path));
const properties = elem;
UI.SetEnabled.apply(null, this.concat(properties.path, visible));
};
var vector = {
_class: 'vector'
};
vector.new = function(data) {
return {
x: data[0],
y: data[1],
z: data[2]
};
};
vector.operate = function(vec, vec2, operation) {
switch(operation) {
case '+':
return {
x: vec.x + vec2.x,
y: vec.y + vec2.y,
z: vec.z + vec2.z
};
case '-':
return {
x: vec.x - vec2.x,
y: vec.y - vec2.y,
z: vec.z - vec2.z
};
case '*':
return {
x: vec.x * vec2.x,
y: vec.y * vec2.y,
z: vec.z * vec2.z
};
case '/':
return {
x: vec.x / vec2.x,
y: vec.y / vec2.y,
z: vec.z / vec2.z
};
default:
throw new Error("[Vector] Invalid operation type.");
}
};
vector.length2d = function(vec) {
return Math.sqrt(vec.x * vec.x + vec.y * vec.y);
};
vector.angles = function(vec) {
return {
x: -Math.atan2(vec.z, this.length2d(vec)) * 180 / Math.PI,
y: Math.atan2(vec.y, vec.x) * 180 / Math.PI,
z: 0
};
};
vector.fov_to = function(origin, destination, view) {
const angles = this.angles(this.operate(destination, origin, '-'));
const delta = this.new([Math.abs(view.x - angles.x), Math.abs(view.y % 360 - angles.y % 360) % 360, 0]);
if(delta.y > 180) delta.y = 360 - delta.y;
return this.length2d(delta);
};
vector.to_array = function(vec) {
return [vec.x, vec.y, vec.z];
};
function normalize_yaw(angle) {
var adjusted_yaw = angle;
if(adjusted_yaw < -180) adjusted_yaw += 360;
if(adjusted_yaw > 180) adjusted_yaw -= 360;
return adjusted_yaw;
}
var plugin = {
last_hit_lby: [],
last_target_visibility: false,
override_flip: false,
last_override_time: globals_curtime()
};
const body = menu.call(ui_add_dropdown, "Desync Direction", "lby_body_mode", [
["Peek Fake", "Peek Real"]
]);
const ref_inverter = menu.reference(["Anti-Aim", "Fake angles", "Inverter"]);
const ref_bodyflip = menu.reference(["Anti-Aim", "Fake angles", "Inverter flip"]);
const ref_inverter_legit = menu.reference(["Anti-Aim", "Legit Anti-Aim", "Direction key"]);
const ref_ragebot = menu.reference(["Rage", "GENERAL", "General", "Enabled"]);
function update_anti_aim_state(state) {
if(menu.get(ref_ragebot)) {
if(menu.get_hotkey(ref_inverter) !== state) menu.toggle(ref_inverter);
return;
}
state = (state + 1) % 2;
if(menu.get_hotkey(ref_inverter_legit) !== state) menu.toggle(ref_inverter_legit);
}
function get_closest_target() {
const players = entity_get_enemies();
const me = entity_get_local_player();
const data = {
id: null,
fov: 180
};
for(var i = 0; i < players.length; i++) {
const e = players[i];
const destination = vector.new(entity_get_hitbox_position(e, 0)),
origin = vector.new(entity_get_eye_position(me));
const angles = vector.new(local_get_view_angles());
const fov = vector.fov_to(origin, destination, angles);
if(fov < data.fov) {
data.id = e;
data.fov = fov;
}
}
return data.id;
}
function get_target_visibility() {
const target = get_closest_target();
if(!target || !entity_is_valid(target)) return false;
if(entity_is_dormant(target)) return false;
const me = entity_get_local_player();
var origin = vector.new(entity_get_eye_position(me)),
velocity = vector.new(entity_get_prop(me, "CBasePlayer", "m_vecVelocity[0]")),
destination = entity_get_hitbox_position(target, 0);
velocity = vector.operate(velocity, vector.new([0.25, 0.25, 0.25]), '*');
origin = vector.operate(origin, velocity, '+');
const result = trace_line(me, vector.to_array(origin), destination)[0];
return result === target;
}
function get_optimal_angle() {
const _mode = menu.get(body);
const me = entity_get_local_player();
const origin = vector.new(entity_get_render_origin(me));
var yaw = local_get_view_angles()[1];
var data = {
left: 0,
right: 0
};
for(var r = yaw - 90; r <= yaw + 90; r += 30) {
if(r === yaw) continue;
const rad = r * Math.PI / 180;
const point = vector.operate(origin, vector.new([256 * Math.cos(rad), 256 * Math.sin(rad), 0]), "+");
const line = trace_line(me, vector.to_array(origin), vector.to_array(point));
const side = r < yaw ? "left" : "right";
data[side] += line[1];
}
data.left /= 3;
data.right /= 3;
if(data.left > data.right) return _mode === 0 ? 0 : 1;
return _mode === 0 ? 1 : 0;
}
function update_anti_aim() {
const me = entity_get_local_player();
if(!entity_is_valid(me) || !entity_is_alive(me)) return;
const target = get_closest_target();
if(target) {
if(target == null) {
update_anti_aim_state(get_optimal_angle());
return;
}
if(plugin.last_hit_lby[target] == null) {
update_anti_aim_state(get_optimal_angle());
return;
}
if(plugin.last_hit_lby[target] === 0) {
update_anti_aim_state(1);
return;
}
update_anti_aim_state(0);
return;
}
update_anti_aim_state(get_optimal_angle());
}
function on_tick() {
update_anti_aim();
}
function on_player_hurt() {
const me = entity_get_local_player();
const attacker = entity_get_entity_from_user_i_d(event_get_int("attacker"));
const userid = entity_get_entity_from_user_i_d(event_get_int("userid"));
if(me !== attacker && me === userid) {
plugin.last_hit_lby[attacker] = menu.get_hotkey(ref_inverter);
}
}
function reset() {
plugin.last_hit_lby = [];
}
cheat_register_callback('create_move', 'on_tick');
cheat_register_callback('player_hurt', 'on_player_hurt');
cheat_register_callback('player_connect_full', 'reset');