Skip to content

Instantly share code, notes, and snippets.

@CanadianJeff
Created November 7, 2021 05:22
Show Gist options
  • Save CanadianJeff/ca669d5d3fcb9c2fe22eb7bcd528844a to your computer and use it in GitHub Desktop.
Save CanadianJeff/ca669d5d3fcb9c2fe22eb7bcd528844a to your computer and use it in GitHub Desktop.
l4d2_autobunnyhop.c
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Memory;
using NAudio;
using NAudio.Wave;
namespace BunnyHopL4D2
{
public partial class Form1 : Form
{
Mem m = new Mem();
[DllImport("user32.dll")]
static extern short GetAsyncKeyState(Keys vkey);
string F_CTRL = "client.dll+0x74AA00";
string F_JUMP = "client.dll+0x74AA48";
string IN_AIR = "client.dll+0x6D6EE0";
int result;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
int PID = m.GetProcIdFromName("left4dead2");
Debug.Assert(PID != 0, "PID returned zero");
if (PID > 0)
{
bool ret = m.OpenProcess(PID);
Debug.Assert(ret, "OpenProcess returned false");
Thread BH = new Thread(BHOP) { IsBackground = true };
BH.Start();
}
else
{
MessageBox.Show("Game Not Found");
}
}
void BHOP()
{
while (true)
{
if (checkBox1.Checked)
{
if (GetAsyncKeyState(Keys.Space)<0)
{
result = m.ReadInt(IN_AIR);
if (result < 5000)
{
m.WriteMemory(F_CTRL, "int", "4");
}
if (result == 0)
{
if (checkBox2.Checked)
{
m.WriteMemory(F_CTRL, "int", "5");
}
m.WriteMemory(F_JUMP, "int", "5");
IWavePlayer waveOutDevice = new WaveOut();
AudioFileReader audioFileReader = new AudioFileReader("Jump.wav");
waveOutDevice.Init(audioFileReader);
//waveOutDevice.Play();
Thread.Sleep(35);
m.WriteMemory(F_JUMP, "int", "4");
if (checkBox2.Checked)
{
m.WriteMemory(F_CTRL, "int", "4");
}
}
}
}
Thread.Sleep(1);
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment