Skip to content

Commit

Permalink
Added fonts and locale switch saveable settings
Browse files Browse the repository at this point in the history
Added fonts and locale switch saveable settings
  • Loading branch information
luadebug authored Aug 1, 2024
1 parent 601c166 commit 1853624
Show file tree
Hide file tree
Showing 40 changed files with 12,091 additions and 7,007 deletions.
20 changes: 14 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,43 @@ cargo-features = ["edition2024", "profile-rustflags"]

[package]
name = "rusted-assault-cube"
version = "2.0.0"
version = "2.2.0"
edition = "2024"
authors = ["luadebug Lin Evelynn [email protected]"]
publish = false

[dependencies]
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"] }
hudhook = { git = "https://github.com/veeenu/hudhook/", features = ["opengl3", "imgui-freetype"] }
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"
serde_yml = "0.0.11"
gnal_tsur = "0.1.0"
pkg-config = "0.3.30"
imgui-sys = { version = "0.12.0", features = ["use-vcpkg"] }

[lib]
crate-type = ["cdylib"]


[profile.dev]
debug = true
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
#rustflags = ["-C", "target-feature=+crt-static"]
#rustflags = ["-C", "link-arg=-fuse-ld=lld"]
#rustflags = ["-C", "link-arg=-fuse-ld=mold"]
[profile.release]
incremental = true
lto = true
opt-level = "s" #z
debug = false
strip = true
#rustflags = ["-C", "target-feature=+crt-static"]
#rustflags = ["-C", "link-arg=-fuse-ld=lld"]
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
#rustflags = ["-C", "link-arg=-fuse-ld=mold"]

[target.'cfg(target_os="windows")'.build-dependencies]
vcpkg = "0.2.15"
12 changes: 12 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::path::Path;
use vcpkg::Error;

fn main() {



match vcpkg::find_package("freetype") {
Ok(freetype) => println!("{:?}", freetype.include_paths) ,
Err(err) => println!("{}", err),
}
}
249 changes: 127 additions & 122 deletions src/aimbot.rs
Original file line number Diff line number Diff line change
@@ -1,122 +1,127 @@
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::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::ui_vars::{IS_AIMBOT, IS_SMOOTH};
use crate::vec_structures::Vec3;
use crate::settings::AppSettings;
pub unsafe fn aimbot(app_settings: &AppSettings)
{
unsafe {
if !IS_AIMBOT.load(SeqCst)
{
return;
}

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);
}
}
}
}
use std::sync::atomic::Ordering::SeqCst;

use windows::Win32::UI::Input::KeyboardAndMouse::GetAsyncKeyState;

use crate::angle::Angle;
use crate::entity::Entity;
use crate::getclosestentity::get_closest_entity;
use crate::hotkey_widget::to_win_key;
use crate::offsets::offsets::{LOCAL_PLAYER_OFFSET, PITCH_OFFSET, YAW_OFFSET};
use crate::settings::AppSettings;
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::ui_vars::{IS_AIMBOT, IS_SMOOTH};
use crate::vec_structures::Vec3;

pub unsafe fn aimbot(app_settings: &AppSettings) {
unsafe {
if !IS_AIMBOT.load(SeqCst) {
return;
}

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);
}
}
}
}
61 changes: 30 additions & 31 deletions src/angle.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
use std::f32::consts::PI;

use crate::distance::distance_3d;
use crate::vec_structures::Vec3;

/// A struct representing angles in a 3D space.
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Angle {
pub yaw: f32,
pub pitch: f32,
}
impl Angle {
pub fn new(yaw: f32, pitch: f32) -> Angle {
Angle { yaw, pitch }
}
pub fn get_angle(player_pos: Vec3, enemy_pos: Vec3) -> Angle {
let distance = distance_3d(player_pos, enemy_pos);

// Calculate yaw
let yaw = -((enemy_pos.x - player_pos.x).atan2(enemy_pos.y - player_pos.y)) / PI * 180.0 + 180.0;

// Calculate pitch
let pitch = (enemy_pos.z - player_pos.z) / distance;
let pitch = pitch.asin() / PI * 180.0;

Angle { yaw, pitch }
}

}

use std::f32::consts::PI;

use crate::distance::distance_3d;
use crate::vec_structures::Vec3;

/// A struct representing angles in a 3D space.
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Angle {
pub yaw: f32,
pub pitch: f32,
}
impl Angle {
pub fn new(yaw: f32, pitch: f32) -> Angle {
Angle { yaw, pitch }
}
pub fn get_angle(player_pos: Vec3, enemy_pos: Vec3) -> Angle {
let distance = distance_3d(player_pos, enemy_pos);

// Calculate yaw
let yaw =
-((enemy_pos.x - player_pos.x).atan2(enemy_pos.y - player_pos.y)) / PI * 180.0 + 180.0;

// Calculate pitch
let pitch = (enemy_pos.z - player_pos.z) / distance;
let pitch = pitch.asin() / PI * 180.0;

Angle { yaw, pitch }
}
}
Loading

0 comments on commit 1853624

Please sign in to comment.