I recently found this file that has a working aimbot in it, however its not the aimbot Im interested in. Its the fact that this file had a number of different .h and .cpp files, that have examples of Bf1942 source code being modified to create content. Ima look into these files, edit them, and see just what I can compile for use in bf1942, ill post a few examples here...if someone figures this out, this brings into light a whole new can of worms for BF1942 Mods, maybe not serverside, but definately client side.
some examples:
#include "stdafx.h" #ifdef _MANAGED #pragma managed(push, off) #endif
CPlayerManager *g_pPlayerManager = NULL; CClassManager *g_pClassManager = NULL; CInputDeviceManager *g_pInputDeviceManager = NULL; CControlMapManager *g_pControlmapManager = NULL; CRenderer *g_pRenderer = NULL; CObjectManager *g_pObjectManager = NULL; CSettingsBase *g_pBase = NULL; CTextManager *g_pTextManager = NULL; CRendererView *g_pRendererView = NULL; CTemplateManager *g_pTemplateManager = NULL; CMaterialManager *g_pMaterialManager = NULL; CBasicPhysicsSystem *g_pBasicPhysicsSystem = NULL; CConsole *g_pConsole = NULL; CVMTHookManager *g_HookBase = NULL; CVMTHookManager *g_TextWriterHookBase = NULL;
SetTextColour_t pSetTextColour = NULL; GetActionBuffer_t pGetActionBuffer = NULL; DrawDetour_t pDrawDetour = NULL;
static bool bAimbotOn = false; UINT ibone = 15;
void CalcAngles( D3DXMATRIX* view_matrix, D3DXMATRIX* target_matrix, float fov, D3DXVECTOR3 *aim_angles ) { D3DXVECTOR3 aim_right,aim_up,aim_dir,aim_pos,target_pos; float aim_angle_z; GET_XAXIS_FROMMATRIX(&aim_right, view_matrix); GET_YAXIS_FROMMATRIX(&aim_up, view_matrix); GET_ZAXIS_FROMMATRIX(&aim_dir, view_matrix); GET_ORIGIN_FROMMATRIX(&aim_pos, view_matrix);
GET_ORIGIN_FROMMATRIX(&target_pos, target_matrix ); D3DXVec3Subtract(&target_pos, &target_pos, &aim_pos); D3DXVec3Normalize(&target_pos, &target_pos);
//copy z to local var, we need real z for target selection aim_angle_z = aim_angles->z = D3DXVec3Dot(&aim_dir, &target_pos); if (aim_angle_z < 0.000f) aim_angle_z+=D3DXToRadian(180.0f); aim_angles->x = D3DXVec3Dot(&aim_right, &target_pos) * aim_angle_z; aim_angles->y = D3DXVec3Dot(&aim_up, &target_pos) * aim_angle_z; //this calculation could be a bit more accurate as it dont compensate for bf's stupid rotationalbrundle(not reversed yet) //but it gets the job done. aim_angles->x = 1.0f / fov * aim_angles->x * 5.0 * 4.0f; aim_angles->y = -1.0f / fov * aim_angles->y * 5.0 * 4.0f; }
BOOL bWorld2Screen( D3DXMATRIX* view_matrix, D3DXMATRIX *object_matrix, float fov, D3DXVECTOR3 *Screen) {
D3DXVECTOR3 view_right,view_up,view_dir, view_pos,view_angles, object_pos; GET_XAXIS_FROMMATRIX(&view_right, view_matrix); GET_YAXIS_FROMMATRIX(&view_up, view_matrix); GET_ZAXIS_FROMMATRIX(&view_dir, view_matrix); GET_ORIGIN_FROMMATRIX(&view_pos, view_matrix);
GET_ORIGIN_FROMMATRIX(&object_pos, object_matrix ); D3DXVec3Subtract(&object_pos, &object_pos, &view_pos); D3DXVec3Normalize( &object_pos, &object_pos );
view_angles.z = D3DXVec3Dot( &view_dir, &object_pos);
if (view_angles.z < 0.001f)//behind return FALSE;
view_angles.x = D3DXVec3Dot(&view_right, &object_pos) ; view_angles.y = -D3DXVec3Dot(&view_up, &object_pos);
float as = ( float )g_pBase->pViewSettings->ViewPortWidth / ( float )g_pBase->pViewSettings->ViewPortHeight; float fs = ( float )g_pBase->pViewSettings->ViewPortWidth / 2 / as / tanf( fov/2);
Screen->x = view_angles.x * fs / view_angles.z; Screen->y = -view_angles.y * fs / view_angles.z; Screen->x = Screen->x + g_pBase->pViewSettings->ViewPortWidth/2; Screen->y = -Screen->y + g_pBase->pViewSettings->ViewPortHeight/2; return TRUE; }
void WINAPI DrawDetour() {
__asm pushad;
if (GetAsyncKeyState( 0x5 ) & 1)//mouse 4 change me to get a diferent aimkey bAimbotOn=!bAimbotOn;
if (GetAsyncKeyState(VK_NUMPAD5)&1) ibone++; if (GetAsyncKeyState(VK_NUMPAD4)&1) { ibone--; if (ibone <= 0) ibone = 0; } //in singelplayer its possible to hook the CRendererView::DrawView() but that dont work in multiplayer //so i use this dirty trick to disable shadowing of text on ground, im sure there is some alternative to this i just havent looked more into it if ((DWORD)_ReturnAddress()==0x0046760B) {
CPlayer *target_player = NULL; CPlayer* local_player = g_pPlayerManager->GetLocalePlayer(); list<CPlayer*>::iterator target_iter; for( target_iter = g_pPlayerManager->player_list.begin(); target_iter != g_pPlayerManager->player_list.end(); target_iter++ ) { ----------------------------------and another-----------------------------this time classes and teams
////////////////////////////////////////////////////////////////////////// #define TEAM_AXIS 1 #define TEAM_ALLIES 2 <-------- possibilty for more than 2 teams? #define TEAM_UNKNOWN 3 ////////////////////////////////////////////////////////////////////////// #define VCLand 0 #define VCSea 1 #define VCAir 2
//////////////////////////////////////////////////////////////////////////
#define VTHeavyTank 0 #define VTLightTank 1 #define VTArtillery 2 #define VTApc 3 #define VTScoutCar 4 #define VTFighter 5 #define VTDiveBomber 6 #define VTBomber 7 #define VTAAGun 8 #define VTStationaryMG 9 #define VTDestroyer 10 #define VTBattleship 11 #define VTCarrier 12 #define VTSubmarine 13 #define VTLcvp 14 #define VTDefGun 15 #define VTLevelBomber 16 #define VTArmoredCar 17 #define VTTankHunter 18 #define VTATGun 19 #define VTAA 20 #define VTBoat 21 #define VTHelicopterAttack 22 #define VTHelicopterTransport 23 #define VTSniper 24 #define VTInfantry 25 #define VTNoVehicleType 26 ////////////////////////////////////////////////////////////////////////// #define defaultGameControlMap 0 #define defaultPlayerInputControlMap 1 #define LandSeaPlayerInputControlMap 2 #define AirPlayerInputControlMap 3 ////////////////////////////////////////////////////////////////////////// #define STATIC_OFFSET_BASE 0x00A5C630 #define STATIC_OFFSET_MAINCONSOLE 0x009A9424 #define STATIC_OFFSET_CLASSMANAGER 0x009A4F50 #define STATIC_OFFSET_PLAYERMANAGER 0x0097D76C #define STATIC_OFFSET_INPUTDEVICEMAGAGER 0x009A2388 #define STATIC_OFFSET_CONTROLMAPMANAGER 0x009A238C #define STATIC_OFFSET_RENDERER 0x009A99D4 #define STATIC_OFFSET_OBJECTMANAGER 0x0097D764 #define STATIC_OFFSET_RENDERERVIEW 0x009AB868 #define STATIC_OFFSET_TEMPLATEMANAGER 0x0097D768 #define STATIC_OFFSET_TEXTWRITER 0x00971EAC #define STATIC_OFFSET_MATERIALMANAGER 0x0097AC08 #define STATIC_OFFSET_BASICPHYSICSMANAGER 0x0097D770 //////////////////////////////////////////////////////////////////////////
#define OBJECT_COMPONET_OBJECT 0xC378 #define OBJECT_COMPONET_SOLDIER 0xC49D #define OBJECT_COMPONET_PLAYERCONTROLOBJECT 0xC4C5 #define OBJECT_COMPONET_GENERICFIREARM 0xC49E #define OBJECT_COMPONET_DEVATION 0xC49C
////////////////////////////////////////////////////////////////////////// #define TEMPLATE_CAMERA_ID 0x9472 #define TEMPLATE_ENGINE_ID 0x9476 #define TEMPLATE_ROTATIONALBUNDLE_ID 0x947D #define TEMPLATE_SIMPLEOBJECT_ID 0x947E #define TEMPLATE_WING_ID 0x9483 #define TEMPLATE_FREECAMERA_ID 0x948B #define TEMPLATE_OVERHEADCAMERA_ID 0x948C #define TEMPLATE_ITEM_ID 0x9492 #define TEMPLATE_SOLDIER_ID 0x9493 #define TEMPLATE_GENERICPROJECTILE_ID 0x9595 #define TEMPLATE_KIT_ID 0x9496 #define TEMPLATE_HANDFIREARM_ID 0x9497 #define TEMPLATE_FIREARM_ID 0x9494 #define TEMPLATE_PLAYERCONTROLOBJECT_ID 0xC4C2 ////////////////////////////////////////////////////////////////////////// #define TEMPLATE_COMPONENT_TEMPLATE 0xC364 #define TEMPLATE_COMPONENT_GENERICFIREARM 0xC365 //i should come up with a better name fot this #define TEMPLATE_COMPONENT_GENERICPROJECTILE 0xC365 //i should come up with a better name fot this #define TEMPLATE_COMPONENT_DEVIATION 0xC49A #define TEMPLATE_COMPONENT_CONTROLOBJECT_0 0xC365 //i should come up with a better name fot this #define TEMPLATE_COMPONENT_CONTROLOBJECT_1 0xC4C4
////////////////////////////////////////////////////////////////////////// #define SKELETON_BONE_STOMACH 0 #define SKELETON_BONE_FOOT 7 #define SKELETON_BONE_TORSO 15 #define SKELETON_BONE_HEAD 17
////////////////////////////////////////////////////////////////////////// class CPlayerManager; class CPlayer; ////////////////////////////////////////////////////////////////////////// class CClassManager; ////////////////////////////////////////////////////////////////////////// class CRenderer; class CRendererView; ////////////////////////////////////////////////////////////////////////// class CInputDeviceManager; class CInputDevice; class CMouseDevice; class CControlMapManager; class CControlMap; class CSettingsBase; class CViewSettingsBase; class CMouseSettingsBase; class CMouseInfantry; class CMouseAir; class CMouseLandSeaVehicle; class CMouseCommon; ////////////////////////////////////////////////////////////////////////// class CTextWirterBase; class CTextManagerHolder; class CTextManager; ////////////////////////////////////////////////////////////////////////// class CObjectManager; class CObject; class CBundleObjects; class COComponent; class COComponent_Weapon; class COComponent_PlayerControlObject; class COComponent_Soldier; ////////////////////////////////////////////////////////////////////////// class CSkeletonInfo; struct CSkeleton; class CGeometryTemplateManager; class CGeometry; class CPhysicsNode; class CBasicPhysicsSystem; class CMaterialManager; class CMaterial;
-------------------------------------
along with this stuff I can get a basic understanding on how BF1942's source code works, there is much more than this, but at risk of getting in trouble, I wont post it, I hope to have fun with this. Would like to point out that it is a very similar code used by Quake 3, so if anybody has ever done .dlls for Quake 3...you should get used to this quick.
|