[ASSAULTCUBE] Hack Tutorials

Posts 76–90 of 102 · Page 6 of 7
Quote Originally Posted by ShadowVL View Post
Thanks, I used this to create an aimbot (first one :P) and using the same idea for the closest enemy aimbot I was able to make closest to crosshair with smooth aim and an aim range. (It may be mediocre execution, but it works and that was what I was aiming for as my first bot)

C++ pastebin - collaborative debugging tool

This was very helpful as I've been trying to figure out how to do it for a while, and this made me realize how.
Looks fine to me Good job and I hope you stick around these forums
Nice TuT,I think i'll start with this as my first bot
Hey for some weird reason i modified the source and nothing happened. Am i to re compile? or what. Or is it just because im on a mac :P
Quote Originally Posted by Hell_Demon View Post
Download page
the download is version 1.0.2, you'll need to apply the 1.0.4 patch which can be found on the same page.

Download the sourcecode

Some information about assaultcube:
40mb in size
OpenGL
Opensource
No anticheats
No dev enforced builds(epic fail )

Since this game doesnt enforce dev builds, you can just recompile the source, replace the games exe and you're good to go

Other pieces of code:
Shooting through walls
No spread and Recoil
Aimbot(this page)
Teleport the flag to you

Step 1
Looking through the files.
The first thing I noticed when I opened the project in MSVC was the bot folder.
So lets open that, and take a look at the file names to see if we can find something interesting.
I'd say we open up bot_util.h.
By quickly reading through bot_util.h I found the following functions interesting:
Code:
bool IsVisible(vec v1, vec v2, dynent *tracer = NULL, bool SkipTags=false);
float GetDistance(vec v1, vec v2);
float Get2DDistance(vec v1, vec v2);
vec PredictPos(vec pos, vec vel, float Time);
Why would those be interesting?
IsVisible - Aimbot with visibility check
Get(2D)Distance - Distance based aimbot or prediction
PredictPos - Hmmm, now why could that be interesting? ^^

Since we'd want our aimbot code to execute alot(once per frame would be enough) we'll need to find the render functions, now if you'd go open the render folder you'd find renderhud.cpp.
since your HUD is rendered every frame that would be a good place to add our aimbot.

Step 2
Adding stuff to the game.
Open up renderhud.cpp and add
Code:
#include "bot/bot_util.h"
to the top(since we want to make use of certain functions from there )

Since i've been around with assaultcube(and some other cube mods) since they started I still have parts of the old bot code(the old aim angle code to be precise )
Code:
void getyawpitch(const vec &from, const vec &to, float &yaw, float &pitch)
{
	float dist = from.dist(to);
	yaw = -(float)atan2(to.x-from.x, to.y-from.y)/PI*180+180;
	pitch = asin((to.z-from.z)/dist)/RAD;
}
Now lets look at a way to get the coordinates of all players.
By looking through alot of these files I found out you can acces all players the following way:
Code:
loopv(players)
{
	players[i];
}
}
all players have the following members that we're going to use:
o - the origin
vel - the velocity(ill exclude this part of the aimbot for now since mines not perfect yet)
state - they're state(states are defined in headers/entity.h)

Step 3
The aimbot logic.
A good aimbot won't jump from 1 player to another if more of them are visible. So we'll need a way to remember our last target, and we also want to keep the 'best' distance in memory.
so at the top under the includes put the following(I have added a small 'mistake' to prevent people like dylan from compiling it, asuming he's as stupid as he appears to be, read the comments and find the same error which appears in 2 places) :
Code:
int lasttarget = -1;
float lastdist = 0.0f;
now lets start on our target function(point based )
Code:
int GetBestTarget()
{
	int ttarget=-1;
	if(lasttarget != -1 && players[lasttarget]->state == CS_ALIVE && players[lasttarget] != NULL && player1 != NULL && player1->state == CS_ALIVE)
	{
		if(IsVisible(player1->o, players[lasttarget]->o)==true)
		{
			return lasttarget; // our old target is visible so lets keep aiming for him =D
		}
	}
	loopv(players)
	{
		if(players[i] == NULL || player1 == NULL || players[i] == player1) // if player or a possible target is null, or if our possible target is ourselves skip  it.
		{
			continue;
		}
		if(players[i]->state == CS_ALIVE && player1->state == CS_ALIVE) // if we're both alive.
		{
			if(isteam(player1->team, players[i]->team)) // if our target is on our team skip it.
			{
				continue;
			}
			float tDist = Get2DDistance(player1->o, players[i]->o); // assign tDist with the 2d distance between us and our temporary target
			if(IsVisible(player1->o, players[i]->o) && tDist<bestdist) //if he is visible and closer then the previous visible enemies
			{
				ttarget=i; // set him as our temporary target
				bestdist=tDist; // set the last distance as the best distance
			}
		}	
	}
	if(ttarget==-1)
	{
		lasttarget=-1;
		return -1;
	}
	lasttarget=ttarget; // assign the current target as last target
	bestdist=0.0f; //reset the best distance so we wont fuck up next time we call the target function
	return ttarget; // return the temp target
}
Now scroll all the way down untill you find 'gl_drawhud', which is where you're going to do the actual targetting.
At the end of gl_drawhud(just before the glMatrixMode(GL_MODELVIEW)) put this code:
Code:
	int tmptarget = GetBestTarget();
	float rX, rY;
	if(tmptarget!=-1)
	{
		getyawpitch(player1->o,players[tmptarget]->o,rX,rY);
		player1->pitch = rY;
		player1->yaw = rX;
	}
You should add your favorite style yourself(for example only aim when right mouse button is down).

Step 4
Have fun owning people/bots
I'm relatively new to C++, and I've been dabbling in a few things, but this I don't understand... I know that we have to declare that identifier (bestdist) But i don't exactly understand HOW to do this... I would be grateful if anybody could explain this to me, and thanks for these awesome tut's! I learned a lot from them...
The game is open source(I think). So he's showing you what to add/replace in the source to make this work.

I THINK!
Ok, so I decided to go ahead and place
Code:
int bestdist = 50;
underneath
Code:
float lastdist = 0.0f;
I then compiled and replaced the ac_client.exe... Not exactly. I'm complicated. I compiled ac_client.exe and I renamed it ac_client_hacked.exe, then edited assaultcube.bat to point to the hacked .exe. It loads, but when I shoot, it crashes. Any suggestions? Is it because it's called ac_client_hacked.exe? I'm gonna go try and just name it ac_client.exe... THat's not the reason, I tried with both names both times i crash when I shoot.
ive never seen the code but i assume.
Code:
float bestdist = 50f;
When I try
Code:
float bestdist = 50f;
i get this error before even getting to compile it:

Code:
1>C:\custom_aimbot_test\assaultcube_v1.0.4-source\source\src\renderhud.cpp(8) : error C2059: syntax error : 'bad suffix on number'
1>c:\custom_aimbot_test\assaultcube_v1.0.4-source\source\src\renderhud.cpp(8) : error C2146: syntax error : missing ';' before identifier 'f'
1>c:\custom_aimbot_test\assaultcube_v1.0.4-source\source\src\renderhud.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Quote Originally Posted by cody3290 View Post
When I try
Code:
float bestdist = 50f;
i get this error before even getting to compile it:

Code:
1>C:\custom_aimbot_test\assaultcube_v1.0.4-source\source\src\renderhud.cpp(8) : error C2059: syntax error : 'bad suffix on number'
1>c:\custom_aimbot_test\assaultcube_v1.0.4-source\source\src\renderhud.cpp(8) : error C2146: syntax error : missing ';' before identifier 'f'
1>c:\custom_aimbot_test\assaultcube_v1.0.4-source\source\src\renderhud.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Probably won't change anything but try:
Code:
float bestdist = 50.0f;
Quote Originally Posted by Void View Post
Probably won't change anything but try:
Code:
float bestdist = 50.0f;
it said it cant be default.
so play around and maybe use like this.

Code:
 unsigned int bestdist = 50;
it crashes if you shoot before the game made enemies for you(so play against bots or go online before shooting).
the reason it crashes is because the enemy list isnt yet located, so basicly your trying to acces a NULL pointer ^^
what are those .bat files? are they some kind of autoshutdown.bat files?

heheh...just asking..sorry...
Quote Originally Posted by sakthis7 View Post
what are those .bat files? are they some kind of autoshutdown.bat files?

heheh...just asking..sorry...

No. They're not "Autoshutdown.bat" Files. They are the bat files that configure ac_client.exe to run.

And yes. You're right. I didn't realize that! When there's no players, i crash. Thanks for telling me that, I was worried I was completely botching all of my coding xD

Edit: is there a way to make it so that you DON'T shoot through the wall? I can't figure it out...

And one more question. would setting the bestdist to 0 target the closest person to me? or would it not target anybody... OK I lied. I have one more question. Is there away to JUST target anybody in my reticule? When I shoot, it shoots someone through a crate (who was not whom I was targeting)
Quote Originally Posted by cody3290 View Post
No. They're not "Autoshutdown.bat" Files. They are the bat files that configure ac_client.exe to run.

And yes. You're right. I didn't realize that! When there's no players, i crash. Thanks for telling me that, I was worried I was completely botching all of my coding xD

Edit: is there a way to make it so that you DON'T shoot through the wall? I can't figure it out...

And one more question. would setting the bestdist to 0 target the closest person to me? or would it not target anybody... OK I lied. I have one more question. Is there away to JUST target anybody in my reticule? When I shoot, it shoots someone through a crate (who was not whom I was targeting)
1. Use keytoggles(or chattoggles if you know how to) and use an if/else statement to see if you want to shoot the closest person, or just fire a normal shot.

2. Bestdistance should be set to something high, since all it does it keep track of the last found closest player in the loop.
e.g.
bestdist starts at 99999.9f
player 1 is 1337 units away(bestdist = 1337 now)
player 2 is 500 units away(bestdist = 500)
player 3 is 750 units away(bestdist = 500, because hes further away then the last checked player).
so setting it to 0 would mean it targets noone.

3. Compare the aimbot angles for every player to your current viewangles, closest to your view angles be the one you're aiming for(dont forget teamchecks :P)
Quote Originally Posted by Hell_Demon View Post
1. Use keytoggles(or chattoggles if you know how to) and use an if/else statement to see if you want to shoot the closest person, or just fire a normal shot.

2. Bestdistance should be set to something high, since all it does it keep track of the last found closest player in the loop.
e.g.
bestdist starts at 99999.9f
player 1 is 1337 units away(bestdist = 1337 now)
player 2 is 500 units away(bestdist = 500)
player 3 is 750 units away(bestdist = 500, because hes further away then the last checked player).
so setting it to 0 would mean it targets noone.

3. Compare the aimbot angles for every player to your current viewangles, closest to your view angles be the one you're aiming for(dont forget teamchecks :P)
1)Ok, thanks.
2)So bestdist should be float? It seems to be working when I set it as an int...
3)Thanks!
Posts 76–90 of 102 · Page 6 of 7
This thread is closed for replies.

Similar Threads

Tags for this Thread

Need help?