Freitag, 25. Oktober 2013

Counter Strike: Source / Half Life 2 Trigger Bot Tutorial

Hello and welcome to my Triggerbot Tutorial


This triggerbot will be based on the players bone position (Head, Neck, Spine) etcetera. (Calculating the FOV between your aim angles & players bone position.)

Unfortunately, There will not be alot of shown sourcecode in this tutorial, basically just an explination on how you can do it, let's get started.


[Step 1] - Getting the players bone position.

To get the other players bone positions you first need the "Bone Base", Witch is located in C_BaseEntity. so how do you find it? Open up hl2.exe in ollydbg, go into client.dll, and search for the string "C_BaseAnimating::SetupBones", Doubleclick it and reverse the function.
Currently the working offset is


5CCEC8C1   33C9             XOR ECX,ECX
5CCEC8C3   898E 70050000    MOV DWORD PTR DS:[ESI+570],ECX
5CCEC8C9   898E 74050000    MOV DWORD PTR DS:[ESI+574],ECX
That's C_BaseEntity + 0x570.

Keep in mind that it will NOT look the same for other versions of CSS.
Also makesure you write these addresses down in a notepad to remember them.

Now when you've got the BoneBase offset, Go into your project (assuming you have been following Fleeps triggerbot tutorial, Or perhaps using my aimbot source) Add a new line in the GetInformation function for the player loop.



ReadProcessMemory(Process, (PBYTE*)(C_BaseEntity + 0x570), &BoneBase, sizeof(DWORD), 0);

Now you got the bone base, now all you need to do is get the X, Y, Z positions from each bone (Or the bone you want to use).

To do this, Create a float array where you wanna store the positions in.

So you would have to do something like this:

ReadProcessMemory(Process, (PBYTE*)(BoneBase + 0x30 *BoneNumber + 0x0C), &FloatArray[0], 4, 0);
ReadProcessMemory(Process, (PBYTE*)(BoneBase + 0x30 *BoneNumber + 0x1C), &FloatArray[1], 4, 0);
ReadProcessMemory(Process, (PBYTE*)(BoneBase + 0x30 *BoneNumber + 0x2C), &FloatArray[2], 4, 0);

The reason I am not just using 1 readprocessmemory and storing it into the array that way is because each position is not 4 bytes away. However I did make a function to be able to just use 1 ReadProcessMemory, Since that will give your cheat better performance.


float m_vecStoreboneData[3][4];

void GetBonePosition(int BoneNumber, float *FloatArray){
   ReadProcessMemory(fpd.hpr, (PBYTE*)(BoneBase + BoneNumber* 0x30), &m_vecStoreboneData, sizeof(m_vecStoreboneData), NULL);
   FloatArray[0] = m_vecStoreboneData[0][3];
   FloatArray[1] = m_vecStoreboneData[1][3];
   FloatArray[2] = m_vecStoreboneData[2][3]-59;  
}

The reason I set FloatArray[2] to be -=59 is because the Y position of a bone on a player is usally 64 "units?" higher then it actually is on the player, And the reason I didnt do -64 is because I think -59 is more accurate, for the head that is.
"HL2 player's Horizontal Eye-Level is 64 units above floor-level when standing/walking (or 30 units when crouching). So a standing player cannot see a horizontal surface if it is 64 units above his floor-level." - https://developer.valvesoftware.com/...alk:Dimensions

Now you can use it like this:

float Head[3];
GetBonePosition(14, Head);

Now you got the X, Y, Z Positions stored inside of the Head float array. and as you can see the bone number 14 is = head bone. Here is a list of all the bones (I have posted this in 1 of my other threads)


BoneNumber:[0] = [Pelvis]
BoneNumber:[1] = [Left_Thigh]
BoneNumber:[2] = [Left_Calf]
BoneNumber:[4] = [Left_Toe0]
BoneNumber:[5] = [Right_Thigh]
BoneNumber:[6] = [Right_Calf]
BoneNumber:[7] = [Right_Foot]
BoneNumber:[8] = [Right_Toe0]
BoneNumber:[9] = [Spine]
BoneNumber:[10] = [Spine1]
BoneNumber:[11] = [Spine2]
BoneNumber:[12] = [Spine4]
BoneNumber:[13] = [Neck1]
BoneNumber:[14] = [Head1]
BoneNumber:[15] = [Left_Clavicle]
BoneNumber:[16] = [Left_UpperArm]
BoneNumber:[17] = [Left_Forearm]
BoneNumber:[18] = [Left_Hand]
BoneNumber:[19] = [Left_Finger2]
BoneNumber:[20] = [Left_Finger21]
BoneNumber:[21] = [Left_Finger22]
BoneNumber:[22] = [Left_Finger1]
BoneNumber:[23] = [Left_Finger11]
BoneNumber:[24] = [Left_Finger12]
BoneNumber:[25] = [Left_Finger0]
BoneNumber:[26] = [Left_Finger01]
BoneNumber:[27] = [Left_Finger02]
BoneNumber:[28] = [Right_Clavicle]
BoneNumber:[29] = [Right_UpperArm]
BoneNumber:[30] = [Right_Forearm]
BoneNumber:[31] = [Right_Hand]
BoneNumber:[32] = [Right_Finger2]
BoneNumber:[33] = [Right_Finger21]
BoneNumber:[34] = [Right_Finger22]
BoneNumber:[35] = [Right_Finger1]
BoneNumber:[36] = [Right_Finger11]
BoneNumber:[37] = [Right_Finger12]
BoneNumber:[38] = [Right_Finger0]
BoneNumber:[39] = [Right_Finger01]
BoneNumber:[40] = [Right_Finger02]
BoneNumber:[41] = [Right_Wrist]
BoneNumber:[42] = [Left_Wrist]
BoneNumber:[43] = [Left_Ulna]
BoneNumber:[44] = [Right_Ulna]
BoneNumber:[45] = [weapon_bone]
BoneNumber:[46] = [weapon_bone_RightHand]
BoneNumber:[47] = [weapon_bone_LleftHand]
BoneNumber:[48] = [weapon_bone_Clip]

[Step 2] - Making the Triggerbot

So now when you've got the player bone positions, what you need to do is calculate the fov between your angles and the bone.

To get the fov, I will be using a function called GetFOV from who I beleive is aVitamin, not sure.




float GetFOV( float *Angles, float *Source, float *Dst, float Distance)
   {
float ang[3],aim[3];
float fov;
CalcAngleDst(Source, Dst, ang, &Distance);
MakeVector(Angles, aim);
MakeVector(ang, ang);    
float mag_s = sqrt((aim[0]*aim[0]) + (aim[1]*aim[1]) + (aim[2]*aim[2]));
float mag_d = sqrt((aim[0]*aim[0]) + (aim[1]*aim[1]) + (aim[2]*aim[2]));
float u_dot_v = aim[0]*ang[0] + aim[1]*ang[1] + aim[2]*ang[2];
fov = acos(u_dot_v / (mag_s*mag_d)) * (180.0 / 3.14159265358979323846);
return fov;
   }

The CalcAngleDst function is just like the CalcAngle function, but it calculates the distance for the player aswell, Using the normal CalcAngle function works fine aswell.


Now lets calculate the fov using the GetFov function:

float Fov = GetFOV(MyViewangles, MyPosition, Head);

Now all you need to do to check if you're aiming at the bone is:


if(Fov<0 .6="" br="" nbsp="">{
   Fire();
}

Now obviously before doing that you would want some sort of team check, and check if the enmy is dead but if you were following Fleeps tuts that would already be included.

Im sorry that this tutorial was very sloppy, Really tired atm but I tried. I hope it helps.

Result

Keine Kommentare:

Kommentar veröffentlichen