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
