Skip to content

Instantly share code, notes, and snippets.

@CryZe
Last active May 8, 2023 16:49
Show Gist options
  • Save CryZe/4cce2b62ea7c889c67a19e0150033d65 to your computer and use it in GitHub Desktop.
Save CryZe/4cce2b62ea7c889c67a19e0150033d65 to your computer and use it in GitHub Desktop.
New abstraction for writing auto splitters
#![no_std]
use asr::{
future::{next_tick, retry},
signature::Signature,
timer, Process,
};
asr::panic_handler!();
asr::async_main!(stable);
async fn main() {
const SIG_GWORLD: Signature<15> = Signature::new("80 7C 24 ?? 00 ?? ?? 48 8B 3D ???????? 48");
loop {
let process = Process::wait_attach("Redfall.exe").await;
process
.until_closes(async {
let (main_module_base, main_module_size) =
process.wait_module_range("Redfall.exe").await;
let ptr = SIG_GWORLD
.wait_scan_process_range(&process, main_module_base, main_module_size)
.await
.add(10);
let g_world = ptr + retry(|| process.read::<u32>(ptr).ok()).await;
loop {
let is_loading = process
.read_pointer_path64::<u32>(g_world, &[0x4, 0x180, 0x560])
.map_or(true, |load_addr| load_addr > 0);
if is_loading {
timer::pause_game_time();
} else {
timer::resume_game_time();
}
next_tick().await;
}
})
.await;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment