-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added hotkey widget, GDI font should be loaded from RAM now. Refactored code.
- Loading branch information
Showing
21 changed files
with
20,232 additions
and
763 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,22 +8,29 @@ authors = ["luadebug Lin Evelynn [email protected]"] | |
publish = false | ||
|
||
[dependencies] | ||
windows = { github = "microsoft/windows-rs", version = "0.58.0", features = ["Win32_System_Console", "Win32_System_SystemServices", "Win32_System_LibraryLoader", "Win32_System_Threading", "Win32_Security", "Win32_System_Memory", "Win32_System_Diagnostics", "Win32_System_Diagnostics_Debug", "Win32_Graphics", "Win32_Graphics_OpenGL", "Win32_UI", "Win32_UI_Input", "Win32_UI_Input_KeyboardAndMouse", "Win32_Graphics_Gdi", "Win32_UI_WindowsAndMessaging", "Win32_Globalization", "Win32_System_ProcessStatus"] } | ||
windows = { version = "0.58.0", features = ["Win32_System_Console", "Win32_System_SystemServices", "Win32_System_LibraryLoader", "Win32_System_Threading", "Win32_Security", "Win32_System_Memory", "Win32_System_Diagnostics", "Win32_System_Diagnostics_Debug", "Win32_Graphics", "Win32_Graphics_OpenGL", "Win32_UI", "Win32_UI_Input", "Win32_UI_Input_KeyboardAndMouse", "Win32_Graphics_Gdi", "Win32_UI_WindowsAndMessaging", "Win32_Globalization", "Win32_System_ProcessStatus"] } | ||
hudhook = { version = "0.7.1", features = ["opengl3"] } | ||
tracing-subscriber = "0.3.18" | ||
once_cell = "1.19.0" | ||
ilhook = "2.1.1" | ||
|
||
serde = { version = "1.0.204", features = ["derive"] } | ||
log = "0.4.22" | ||
anyhow = "1.0.86" | ||
serde_yaml = "0.9.34+deprecated" | ||
lazy_static = "1.5.0" | ||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
|
||
[profile.dev] | ||
debug = true | ||
|
||
rustflags = ["-C", "link-arg=-fuse-ld=lld"] | ||
rustflags = ["-C", "link-arg=-fuse-ld=mold"] | ||
#rustflags = ["-C", "link-arg=-fuse-ld=lld"] | ||
[profile.release] | ||
incremental = true | ||
lto = true | ||
opt-level = "z" | ||
debug = true # Enable debug information for release profile | ||
rustflags = ["-C", "link-arg=-fuse-ld=lld"] | ||
opt-level = "s" #z | ||
debug = false | ||
strip = true | ||
#rustflags = ["-C", "link-arg=-fuse-ld=lld"] | ||
rustflags = ["-C", "link-arg=-fuse-ld=mold"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,122 @@ | ||
use std::sync::atomic::Ordering::SeqCst; | ||
use hudhook::imgui::Key; | ||
use windows::Win32::UI::Input::KeyboardAndMouse::GetAsyncKeyState; | ||
|
||
use crate::angle::Angle; | ||
use crate::entity::Entity; | ||
use crate::getclosestentity::get_closest_entity; | ||
use crate::offsets::offsets::{ENTITY_LIST_OFFSET, LOCAL_PLAYER_OFFSET, NUMBER_OF_PLAYERS_IN_MATCH_OFFSET, PITCH_OFFSET, VIEW_MATRIX_ADDR, YAW_OFFSET}; | ||
use crate::vars::game_vars::{ENTITY_LIST_PTR, LOCAL_PLAYER, NUM_PLAYERS_IN_MATCH, SMOOTH, VIEW_MATRIX}; | ||
use crate::hotkey_widget::{HotKey, to_win_key}; | ||
use crate::offsets::offsets::{LOCAL_PLAYER_OFFSET, PITCH_OFFSET, YAW_OFFSET}; | ||
use crate::utils::{read_memory, write_memory}; | ||
use crate::vars::game_vars::{LOCAL_PLAYER, SMOOTH}; | ||
use crate::vars::handles::AC_CLIENT_EXE_HMODULE; | ||
use crate::vars::hotkeys::AIM_KEY; | ||
|
||
use crate::vars::ui_vars::{IS_AIMBOT, IS_SMOOTH}; | ||
use crate::vec_structures::Vec3; | ||
|
||
pub unsafe fn aimbot() | ||
use crate::settings::AppSettings; | ||
pub unsafe fn aimbot(app_settings: &AppSettings) | ||
{ | ||
if !IS_AIMBOT | ||
{ | ||
return; | ||
} | ||
LOCAL_PLAYER = Entity::from_addr(*((AC_CLIENT_EXE_HMODULE + LOCAL_PLAYER_OFFSET) as *mut usize)); | ||
VIEW_MATRIX = VIEW_MATRIX_ADDR as *mut [f32; 16]; | ||
NUM_PLAYERS_IN_MATCH = *((AC_CLIENT_EXE_HMODULE + NUMBER_OF_PLAYERS_IN_MATCH_OFFSET) as *const i32) as usize; | ||
ENTITY_LIST_PTR = *((AC_CLIENT_EXE_HMODULE + ENTITY_LIST_OFFSET) as *const u32); | ||
if GetAsyncKeyState(AIM_KEY.0 as i32) & 1 == 1 { | ||
let enemy = get_closest_entity(); | ||
if LOCAL_PLAYER.entity_starts_at_addr == 0 || enemy.entity_starts_at_addr == 0 | ||
{ | ||
return; //Didn't find player or enemy | ||
} | ||
if enemy.health() < 0 || enemy.team() == LOCAL_PLAYER.team() | ||
unsafe { | ||
if !IS_AIMBOT.load(SeqCst) | ||
{ | ||
return; //Skipping dead or ally | ||
return; | ||
} | ||
let angle = Angle::get_angle( | ||
Vec3::new( | ||
LOCAL_PLAYER.head_position().x, | ||
LOCAL_PLAYER.head_position().y, | ||
LOCAL_PLAYER.head_position().z), | ||
Vec3::new(enemy.head_position().x, | ||
enemy.head_position().y, | ||
enemy.head_position().z) | ||
); | ||
let smooth = Angle::new( | ||
angle.yaw - *((LOCAL_PLAYER.entity_starts_at_addr + YAW_OFFSET) as *const f32), | ||
angle.pitch - *((LOCAL_PLAYER.entity_starts_at_addr + PITCH_OFFSET) as *const f32) | ||
); | ||
if IS_SMOOTH | ||
{ | ||
*((LOCAL_PLAYER.entity_starts_at_addr + YAW_OFFSET) as *mut f32) += smooth.yaw / SMOOTH; | ||
*((LOCAL_PLAYER.entity_starts_at_addr + PITCH_OFFSET) as *mut f32) += smooth.pitch / SMOOTH; | ||
} | ||
else | ||
{ | ||
*((LOCAL_PLAYER.entity_starts_at_addr + YAW_OFFSET) as *mut f32) = angle.yaw; | ||
*((LOCAL_PLAYER.entity_starts_at_addr + PITCH_OFFSET) as *mut f32) = angle.pitch; | ||
|
||
let local_player_addr = match read_memory::<usize>(AC_CLIENT_EXE_HMODULE + LOCAL_PLAYER_OFFSET) { | ||
Ok(addr) => addr, | ||
Err(err) => { | ||
println!("Error reading local player address: {}", err); | ||
return; | ||
} | ||
}; | ||
|
||
LOCAL_PLAYER = Entity::from_addr(local_player_addr); | ||
|
||
if GetAsyncKeyState(to_win_key(app_settings.AIM_KEY.as_ref().unwrap().key).0 as i32) & 1 == 1 { | ||
let enemy = get_closest_entity(); | ||
if LOCAL_PLAYER.entity_starts_at_addr == 0 || enemy.entity_starts_at_addr == 0 { | ||
return; // Didn't find player or enemy | ||
} | ||
|
||
// Handle health and team checks | ||
if enemy.health().unwrap_or(0) < 0 || enemy.team() == LOCAL_PLAYER.team() { | ||
return; // Skipping dead or ally | ||
} | ||
|
||
// Safely read player and enemy positions | ||
let player_head_pos = match LOCAL_PLAYER.head_position() { | ||
Ok(pos) => pos, | ||
Err(err) => { | ||
println!("Error reading player head position: {}", err); | ||
return; | ||
} | ||
}; | ||
|
||
let enemy_head_pos = match enemy.head_position() { | ||
Ok(pos) => pos, | ||
Err(err) => { | ||
println!("Error reading enemy head position: {}", err); | ||
return; | ||
} | ||
}; | ||
|
||
// Calculate angle | ||
let angle = Angle::get_angle( | ||
Vec3::new(player_head_pos.x, player_head_pos.y, player_head_pos.z), | ||
Vec3::new(enemy_head_pos.x, enemy_head_pos.y, enemy_head_pos.z), | ||
); | ||
|
||
// Safely read and update yaw and pitch | ||
let update_view_angle = |offset: usize, value: f32| { | ||
let address = LOCAL_PLAYER.entity_starts_at_addr + offset; | ||
match read_memory::<f32>(address) { | ||
Ok(current_value) => { | ||
// Only write if the value is different to avoid unnecessary writes | ||
if current_value != value { | ||
if let Err(err) = write_memory::<f32>(address, value) { | ||
println!("Error writing to address {:x} storing value {}: {}", address, current_value, err); | ||
} | ||
} | ||
} | ||
Err(err) => { | ||
println!("Error reading from address {:x}: {}", address, err); | ||
} | ||
} | ||
}; | ||
|
||
// Read yaw and pitch with error handling | ||
let (local_player_yaw, local_player_pitch) = match (LOCAL_PLAYER.yaw(), LOCAL_PLAYER.pitch()) { | ||
(Ok(y), Ok(p)) => (y as f32, p as f32), | ||
(Err(err), _) => { | ||
println!("Error reading yaw: {}", err); | ||
return; | ||
} | ||
(_, Err(err)) => { | ||
println!("Error reading pitch: {}", err); | ||
return; | ||
} | ||
}; | ||
|
||
// Calculate the angle difference | ||
let angle_diff_yaw = angle.yaw - local_player_yaw; | ||
let angle_diff_pitch = angle.pitch - local_player_pitch; | ||
|
||
let smooth = Angle::new(angle_diff_yaw, angle_diff_pitch); | ||
let smooth_value = SMOOTH.load(SeqCst) as f32; | ||
|
||
if IS_SMOOTH.load(SeqCst) { | ||
if smooth_value > 0.0 { | ||
let new_yaw = local_player_yaw + (smooth.yaw / smooth_value); | ||
let new_pitch = local_player_pitch + (smooth.pitch / smooth_value); | ||
update_view_angle(YAW_OFFSET, new_yaw); | ||
update_view_angle(PITCH_OFFSET, new_pitch); | ||
} else { | ||
return; | ||
} | ||
} else { | ||
update_view_angle(YAW_OFFSET, angle.yaw); | ||
update_view_angle(PITCH_OFFSET, angle.pitch); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.