Your angles are being set to map origin, check for null pointers correctly.
Hi,
I'm having a issue that my aimbot is locking itself on the ground when I hold the key for it.
Now, the weird thing is is that this exact aimbot works perfectly fine in my other project, the only difference is is that in this project I am not using /CLR. Before, I had the issue that when I started the aimbot it said 'Run-Time Check Failure #3 - The variable 'index' is being used without being initialized.' but I've moved the variable index to above the closestenemytocrosshair code and that seems to be solved now.
Code:void CalcAngle(Vec3 src, Vec3 dst, Vec3 &angles) { Vec3 delta; delta.x = src.x - dst.x; delta.y = src.y - dst.y; delta.z = src.z - dst.z; double hyp = sqrt(delta.x * delta.x + delta.y * delta.y); angles.x = (float)(atan(delta.z / hyp) * 57.295779513082f); angles.y = (float)(atan(delta.y / delta.x) * 57.295779513082f); angles.z = 0.0f; if (delta.x >= 0.0) angles.y += 180.0f; } int index; int ClosestEnemyToCrosshair(float maxfov) { DWORD LocalPlayer = Mem.Read <DWORD>(Client + 0x00A31504); int LocalTeam = Mem.Read<int>(LocalPlayer + m_iTeamNum); for (int i = 0; i < 64; i++) { DWORD entitybase = Mem.Read<DWORD>(Client + EntityList + (i * 0x10)); if (entitybase == LocalPlayer) continue; bool entitydormant = Mem.Read<bool>(entitybase + isDormant); if (entitydormant) continue; int entityteam = Mem.Read<int>(entitybase + m_iTeamNum); if (entityteam == LocalTeam) continue; int entitylifestate = Mem.Read<byte>(entitybase + 0x25B); //is lifestate if (entitylifestate != 0) continue; DWORD Engine = Mem.Module("engine.dll"); DWORD clientstate = Mem.Read<DWORD>(Engine + clientState); Vec3 currentangles = Mem.Read<Vec3>(clientstate + viewAngle); Vec3 pos = BonePos(entitybase, 0x2698, aimbone); //bonematrix float entitydistance = GetFOV(currentangles, position, pos); if (entitydistance < maxfov) { maxfov = entitydistance; index = i; } } return index; }
Your angles are being set to map origin, check for null pointers correctly.
What / how / where should I check for null pointers?
//EDIT: The closest enemy to crosshair code does seem to work, it only locks to the ground when the enemy is in sight
//EDIT EDIT: Maybe it is a problem with procmem? I tried to add noflash as a feature, but that doesn't seem to be doing ANYTHING but the code can't really not work..
Used the offsets instead of using my premade offset list to make sure those are working, tried debugging the code and that actually worked too, it just doesn't understand / seem to trigger itself with the 0x0000A2F4 > 0.fCode:void NoFlash() { if (visual_visibleonly && 0x0000A2F4 > 0.f) /* Remove Flash by setting the value back to 0.f */ Mem.Write<float>(0x00A31504 + 0, 0.f); /* Sleep to reduce CPU usage */ Sleep(1); }
Last edited by F4DE; 07-18-2016 at 12:30 PM.
0xA2F4 is -0.000000, of course your check won't succeed. You want to check if the value of m_flFlashMaxAlpha is bigger than 0.f, it obviously won't work if you aren't even reading anything. You're also writing to a completely wrong memory address.Code:0x0000A2F4 > 0.f
By adding a check if it's valid into your ClosestEnemyToCrosshair function right after you get the entitybase.What / how / where should I check for null pointers?
Code:if ( !entitybase ) continue;
Hmm, doesn't seem to fix the problem ;l
Gif of what is happening;
The noflash part was pritty dumb though I have this right now, but it seems to still not be doing anything and I'm out of ideas
//EDIT: Think I know what is going on with the noflash, I think I should actually set LocalBase and FlashMaxAlpha in the loop to let it updateCode:void NoFlash() { LocalBase = Mem.Read<DWORD>(Client + 0x00A31504); FlashMaxAlpha = Mem.Read<float>(LocalBase + 0x0000A2F4); while (true) { if (visual_visibleonly && FlashMaxAlpha > 0.f) /* Remove Flash by setting the value back to 0.f */ Mem.Write<float>(LocalBase + 0x0000A2F4, 0.f); /* Sleep to reduce CPU usage */ Sleep(1); } }
Last edited by F4DE; 07-18-2016 at 02:06 PM.
Code:void CalcAngle(Vec3 src, Vec3 dst, Vec3 &angles) { Vec3 delta; delta.x = src.x - dst.x; delta.y = src.y - dst.y; delta.z = src.z - dst.z; double hyp = sqrt(delta.x * delta.x + delta.y * delta.y); angles.x = (float)(atan(delta.z / hyp) * 57.295779513082f); angles.y = (float)(atan(delta.y / delta.x) * 57.295779513082f); angles.z = 0.0f; if (delta.x >= 0.0) angles.y += 180.0f; }Yeah, having this right now but it still doesn't do anythingCode:void CalcAngle(Vec3 src, Vec3 dst, Vec3 &angles) { Vec3 delta; delta.x = src.x - dst.x; delta.y = src.y - dst.y; delta.z = src.z - dst.z; double hyp = sqrt(delta.x * delta.x + delta.y * delta.y); angles.x = (float)(atan(delta.z / hyp) * 57.295779513082f); angles.y = (float)(atan(delta.y / delta.x) * 57.295779513082f); angles.z = 0.0f; if (delta.x >= 0.0) angles.y += 180.0f; }
Code:void ReadData() { while (true) { LocalBase = Mem.Read<DWORD>(Client + 0x00A31504); FlashMaxAlpha = Mem.Read<float>(LocalBase + 0x0000A2F4); Sleep(1); } } void NoFlash() { while (true) { if (visual_visibleonly && FlashMaxAlpha > 0.f) /* Remove Flash by setting the value back to 0.f */ Mem.Write<float>(LocalBase + 0x0000A2F4, 0.f); /* Sleep to reduce CPU usage */ Sleep(1); } }
Ah I'm sorry, thought you meant the other thing.
I'm calling ReadData in the Main part, also calling it before the noflash thread.Code:int entindex = ClosestEnemyToCrosshair(90.f); if (entindex == 0) continue; DWORD LocalPlayer = Mem.Read <DWORD>(Client + 0x00A31504); Vec3 origin = Mem.Read<Vec3>(LocalPlayer + 0x134); Vec3 vecview = Mem.Read<Vec3>(LocalPlayer + 0x104); position.x = origin.x + vecview.x; position.y = origin.y + vecview.y; position.z = origin.z + vecview.z; Vec3 punch = Mem.Read<Vec3>(LocalPlayer + 0x3018); Vec3 angles; DWORD entitybase = Mem.Read<DWORD>(Client + EntityList + (entindex * 0x10)); Vec3 pos = BonePos(entitybase, 0x2698, bonePosition); CalcAngle(position, pos, angles); angles.x = angles.x - punch.x * 2.f; angles.y = angles.y - punch.y * 2.f; ClampAngles(angles); if (angles.x == 0 && angles.y == 0) continue; DWORD Engine = Mem.Module("engine.dll"); DWORD clientstate = Mem.Read<DWORD>(Engine + clientState); Mem.Write<Vec3>(clientstate + 0x4D0C, angles);
Code:std::thread t3(ReadData); std::thread t1(Aimbot); std::thread t2(NoFlash);
Bumbing this to the top!
Code:Vec3 BonePos(DWORD target, DWORD address, int boneId) { DWORD boneBase = Mem.Read<DWORD>(target + address); Vec3 vBone; vBone.x = Mem.Read<float>(boneBase + 0x30 * boneId + 0x0C); vBone.y = Mem.Read<float>(boneBase + 0x30 * boneId + 0x1C); vBone.z = Mem.Read<float>(boneBase + 0x30 * boneId + 0x2C); return vBone; }