Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef TRIGGERBOT_H
- #define TRIGGERBOT_H
- #include <iostream>
- #include <Windows.h>
- #include "Engine.h"
- #include "Settings.h"
- #include "Vector.h"
- #include "PMemory.h"
- #include "Offsets.h"
- #include "Weapon.h"
- #include "Utils.h"
- using namespace std;
- bool b_true = true;
- bool b_false = false;
- bool attackState = false;
- bool useCoords = false;
- bool useCeid = true;
- bool msgSent = false;
- RECT m_Rect;
- typedef struct
- {
- float flMatrix[4][4];
- }
- WorldToScreenMatrix;
- struct MyPlayer
- {
- DWORD CLocalPlayer;
- DWORD CViewMatrix;
- DWORD CWeaponBase;
- int CrosshairEntityId;
- int Team;
- Vector Position;
- int WeaponID;
- Vector Velocity;
- WorldToScreenMatrix WorldToScreenMatrix;
- void ReadInfo()
- {
- Engine()->Memory()->Read<int>(Engine()->me.dwBase + Engine()->Offsets()->dwLocalPlayer);
- Engine()->Memory()->Read<int>(Engine()->me.dwBase + Engine()->Offsets()->dwInCross);
- Engine()->Memory()->Read<int>(Engine()->me.dwBase + Engine()->Offsets()->dwTeam);
- ReadViewMatrix();
- ReadWeaponId();
- }
- void ReadViewMatrix()
- {
- Engine()->Memory()->Read<int>(Engine()->me.dwBase + Engine()->Offsets()->dw_local_view_offset);
- Engine()->Memory()->Read<BYTE>(CViewMatrix, WorldToScreenMatrix + (sizeof(WorldToScreenMatrix)));
- }
- void ReadWeaponId()
- {
- int WeaponHandle;
- int WeaponIDFirst;
- Engine()->Memory()->Read<int>(Engine()->me.dwBase + Engine()->Offsets()->dwActiveWeapon);
- WeaponIDFirst = WeaponHandle & 0xFFF;
- Engine()->Memory()->Read<BYTE>(Engine()->me.dwBase + Engine()->Offsets()->dwEntityList + (-0x10 + (WeaponIDFirst * 0x10)) &CWeaponBase, 4, NULL);
- Engine()->Memory()->Read<BYTE>(Engine()->me.dwBase + Engine()->Offsets()->dwWeaponId + CWeaponBase, &WeaponID, 4, NULL);
- }
- }MyPlayer;
- struct PlayerList_t
- {
- DWORD CBaseEntity;
- int Team;
- Vector Position;
- void ReadInformation(int ceid)
- {
- DWORD offset = Engine()->Offsets()->dwEntityList + ((ceid - 1) * Engine()->Offsets()->dw_entity_size);
- ReadProcessMemory(fProcess.__HandleProcess,
- (PBYTE*)(fProcess.__dwordClient + offset),
- &CBaseEntity, sizeof(DWORD), 0);
- Engine()->Memory()->Read<int>(Engine()->me.dwBase + Engine()->Offsets()->dwTeam);
- Engine()->Memory()->Read<int>(Engine()->me.dwBase + Engine()->Offsets()->dwVecOrigin);
- }
- }PlayerList[32];
- FLOAT fScreenx, fScreeny;
- BOOL ScreenTransform(CONST Vector& point, OUT Vector& screen)
- {
- float worldToScreen[4][4];
- memcpy(worldToScreen, MyPlayer.WorldToScreenMatrix.flMatrix,
- sizeof(worldToScreen));
- screen.x = worldToScreen[0][0]
- * point.x + worldToScreen[0][1]
- * point.y + worldToScreen[0][2]
- * point.z + worldToScreen[0][3];
- screen.y = worldToScreen[1][0]
- * point.x + worldToScreen[1][1]
- * point.y + worldToScreen[1][2]
- * point.z + worldToScreen[1][3];
- FLOAT w;
- w = worldToScreen[3][0]
- * point.x + worldToScreen[3][1]
- * point.y + worldToScreen[3][2]
- * point.z + worldToScreen[3][3];
- screen.z = 0.0f;
- BOOL behind = FALSE;
- if (w < 0.001f)
- {
- behind = TRUE;
- screen.x *= 100000;
- screen.y *= 100000;
- }
- else
- {
- FLOAT invw = 1.0f / w;
- screen.x *= invw;
- screen.y *= invw;
- }
- return behind;
- }
- BOOL WorldToScreen(CONST Vector &origin, OUT Vector &screen)
- {
- BOOL bRet = FALSE;
- if (!ScreenTransform(origin, screen))
- {
- INT width = (int)(m_Rect.right - m_Rect.left);
- INT height = (int)(m_Rect.bottom - m_Rect.top);
- fScreenx = width / 2.0f;
- fScreeny = height / 2.0f;
- fScreenx += 0.5f * screen.x * width + 0.5f;
- fScreeny -= 0.5f * screen.y * height + 0.5f;
- screen.x = fScreenx;
- screen.y = fScreeny;
- bRet = TRUE;
- }
- return bRet;
- }
- int mp_playerid()
- {
- if (!useCeid)
- return 1;
- int out;
- Engine()->Memory()->Read<int>(Engine()->me.dwBase + Engine()->Offsets()->dwActiveWeapon, &out, <int>, 0);
- if (!msgSent && out > 0)
- {
- cout << "WARNING: mp_playerid is nonzero. "
- << "This may affect triggerbot accuracy, as boundingbox will be used"
- << endl;
- msgSent = true;
- }
- return out;
- }
- int NumberOfPlayers()
- {
- return 32;
- }
- void Attack()
- {
- if (!attackState)
- {
- attackState = true;
- Engine()->Memory()->Write<int>(Engine()->getClientModule()->dwBase + Engine()->Offsets()->dwAttack, 1);
- }
- else
- {
- attackState = false;
- Engine()->Memory()->Write<int>(Engine()->getClientModule()->dwBase + Engine()->Offsets()->dwAttack, 0);
- }
- Sleep(1);
- }
- int halfWidth = (int)(m_Rect.right - m_Rect.left) / 2;
- int halfHeight = (int)(m_Rect.bottom - m_Rect.top) / 2;
- class Triggerbot
- {
- public:
- void run()
- {
- bool attackState = false;
- while (true)
- if (attackState && IsWeaponSemiAuto(MyPlayer.WeaponID))
- Attack();
- if (Settings()->triggerEnabled || GetAsyncKeyState(Settings()->trigger_holdkey))
- {
- if (attackState)
- Attack();
- }
- MyPlayer.ReadInfo();
- if (IsWeaponNonAim(MyPlayer.WeaponID))
- bool hit = false;
- for (int i = 1; i <= NumberOfPlayers(); ++i)
- {
- PlayerList[i].ReadInformation(i);
- if (!((MyPlayer.CrosshairEntityId > 0
- && MyPlayer.CrosshairEntityId <= NumberOfPlayers())
- || mp_playerid() > 0))
- {
- if (attackState && !IsWeaponSemiAuto(MyPlayer.WeaponID))
- Attack();
- continue;
- }
- PlayerList[i].ReadInformation(i);
- if (MyPlayer.Team == PlayerList[i].Team && Settings()->ALLOW_FRIENDLYFIRE)
- continue;
- bool shouldShoot = true;
- if (useCoords && !IsWeaponScoped(MyPlayer.WeaponID))
- {
- shouldShoot = false;
- Vector ScreenPos;
- if (WorldToScreen(PlayerList[i].Position, ScreenPos))
- {
- double distance = Get3dDistance(MyPlayer, Position, PlayerList[i].Position);
- int playerWidth = (int)max(Settings()->PLAYER_WIDTH / distance, 11);
- int playerHeight = (int)max(Settings()->PLAYER_HEIGHT / distance, 5);
- int halfPlayerWidth = (int)(playerWidth / 2);
- int heightOffset = (int)(Settings()->PLAYER_HEIGHT_OFFSET / distance);
- if (ScreenPos.x > halfWidth - halfPlayerWidth
- && ScreenPos.x < halfWidth + halfPlayerWidth
- && ScreenPos.y > halfHeight + heightOffset
- && ScreenPos.y < halfHeight + playerHeight + heightOffset)
- shouldShoot = true;
- }
- }
- if (shouldShoot)
- {
- bool hit = true;
- if (Settings()->DELAY > 0)
- {
- Sleep(Settings()->DELAY);
- }
- if (!attackState)
- Attack();
- Sleep(35);
- break;
- }
- }
- Sleep(1);
- }
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement