Thread: Tweakable Radar...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    6

    Question Tweakable Radar...

    This is a little project I have been working on for a game called Tactical Ops.. It's a mod off of Unreal Tournament 99...

    Code:
    /*DoraSource.cpp*/
    
    
    #include "DoraHeader.h"
    
    
    float inline Dot (const FVector& V1, const FVector& V2)
    {
    	return ( V1.X*V2.X + V1.Y*V2.Y + V1.Z*V2.Z );
    };
    
    
    void inline GetAxes (FRotator R, FVector &X, FVector &Y, FVector &Z)
    {	
    	X = R.Vector();
    	X.Normalize();
    	R.Yaw += 16384;
    	FRotator R2 = R;
    	R2.Pitch = 0.f;
    	Y = R2.Vector();
    	Y.Normalize();
    	Y.Z = 0.f;
    	R.Yaw -= 16384;
    	R.Pitch += 16384;
    	Z = R.Vector();
    	Z.Normalize();
    }
    
    
    FColor inline TeamColor (APawn* Target)
    {
    
    	switch( Target->PlayerReplicationInfo->Team )
    	{
    		case 0: 
    			return FColor(200,0,0);
    			break;
    
    		case 1: 
    			return FColor(0,200,200);
    			break;
    
    		default: 
    			return FColor(200,0,0);
    			break;
    	}
    }
    
    
    #define ResetCanvas \
    	Canvas->SpaceX=0; \
    	Canvas->SpaceY=0; \
    	Canvas->OrgX=0; \
    	Canvas->OrgY=0; \
    	Canvas->CurX=0; \
    	Canvas->CurY=0; \
    
    
    #define SetPos(PosX,PosY) \
    	Canvas->CurX = PosX; \
    	Canvas->CurY = PosY; \
    
    
    #define RadarTexture (UTexture*)UTexture::StaticLoadObject( UTexture::StaticClass(), NULL, TEXT("BotPack.CHair3"), NULL, LOAD_NoFail, NULL )
    #define RedTexture (UTexture*)UTexture::StaticLoadObject( UTexture::StaticClass(), NULL, TEXT("BotPack.AmmoCountJunk"), NULL, LOAD_NoFail, NULL )
    #define GreenTexture (UTexture*)UTexture::StaticLoadObject( UTexture::StaticClass(), NULL, TEXT("BotPack.AmmoCountBar"), NULL, LOAD_NoFail, NULL )
    #define BlueTexture (UTexture*)UTexture::StaticLoadObject( UTexture::StaticClass(), NULL, TEXT("UBrowser.HighLight"), NULL, LOAD_NoFail, NULL )
    
    void inline DrawPlayerOnRadar (UCanvas* Canvas, APawn* Target)
    {
    	FVector X,Y,Z,D,HisLoc;
    	FLOAT PosX, PosY;
    
    	
    	GetAxes(MyCameraRotation,X,Y,Z);
    
    	
    	HisLoc = Target->Location;
    	HisLoc.Z += Target->CollisionHeight / 2;
    
    	D = HisLoc - MyCameraLocation;
    
    
    	if ( Dot(D / D.Size(), X) > 0.7 )
    	{
    		
    		PosX = (Canvas->ClipX / 2) + ( Dot(D, Y)) * ((Canvas->ClipX / 2) / tan(Me->FovAngle * PI/360)) / Dot(D, X);
    		PosY = (Canvas->ClipY / 2) + (-Dot(D, Z)) * ((Canvas->ClipX / 2) / tan(Me->FovAngle * PI/360)) / Dot(D, X);
    
    
    		if ( (PosX < 0) || (PosX > Canvas->ClipX) ) return;
    		if ( (PosY < 0) || (PosY > Canvas->ClipY) ) return;
    
    
    		Canvas->Color = TeamColor(Target);
    
    	
    		Canvas->DrawIcon(RadarTexture, PosX - 32, PosY - 32, 64, 64, NULL, 1, Canvas->Color.Plane(), FPlane(1,1,1,1), PF_Translucent);
    
    		
    		SetPos(PosX + 10, PosY - 21)
    		Canvas->WrappedPrintf(Canvas->SmallFont,0,TEXT("UserName: %s"), Target->PlayerReplicationInfo->PlayerName);
    
    		SetPos(PosX + 10, PosY - 14)
    		Canvas->WrappedPrintf(Canvas->SmallFont,0,TEXT("Team: %s"), Target->PlayerReplicationInfo->TeamName);
    		
    		SetPos(PosX + 10, PosY - 7)
    		Canvas->WrappedPrintf(Canvas->SmallFont,0,TEXT("Health: %d"), Target->Health);
    
    		SetPos(PosX + 10, PosY)
    		Canvas->WrappedPrintf(Canvas->SmallFont,0,TEXT("Distance: %.0f"), D.Size() / 48);
    
    		SetPos(PosX + 10, PosY + 7)
    		Canvas->WrappedPrintf(Canvas->SmallFont,0,TEXT("Weapon: %s"), Target->Weapon->GetClass()->GetName());
    
    		SetPos(PosX + 10, PosY + 14)
    		Canvas->WrappedPrintf(Canvas->SmallFont,0,TEXT("Ping: %d"), Target->PlayerReplicationInfo->Ping);
    
    		SetPos(PosX + 10, PosY + 21)
    		Canvas->WrappedPrintf(Canvas->SmallFont,0,TEXT("Kills: %d"), Target->KillCount);
    
    		SetPos(PosX + 10, PosY + 28)
    		Canvas->WrappedPrintf(Canvas->SmallFont,0,TEXT("Deaths: %d"), Target->DieCount);
    
    		ResetCanvas
    	}
    
    }
    
    
    void inline Fire (void)
    {
    	struct Fire_Parms { FLOAT F; };
    	static Fire_Parms Parms;
    
    	Parms.F = 0;
    	UFunction* pFunc = Me->FindFunction(TEXT("AutoFire"));
    	if ( pFunc != NULL )
    	{
    		Me->ProcessEvent(pFunc, &Parms);
    	}
    }
    
    
    bool bBotShooting = false;
    
    
    void inline FireMyWeapon (void)
    {
    	bBotShooting = true;
    
    	Me->bFire = 1;
    	Me->bAltFire = 0;
    	Fire();
    }
    
    
    void inline StopMyWeapon (void)
    {
    	if ( bBotShooting )
    	{
    		bBotShooting = false;
    
    		Me->bFire = 0;
    		Me->bAltFire = 0;
    	}
    }
    
    
    bool inline IsGoodWeapon (void)
    {
    	if ( Me->Weapon != NULL )
    	{
    		if ( Me->Weapon->AmmoType != NULL )
    		{
    			return (Me->Weapon->AmmoType->AmmoAmount > 0) || (Me->Weapon->AmmoType->MaxAmmo <= 0);
    		}
    		else
    		{
    			return true;
    		}
    	}
    	else
    	{
    		return false;
    	}
    }
    
    
    bool inline IsVisible (APawn* Target)
    {
    	FVector MyPos, HisPos;
    
    	MyPos = Me->Location;
    	MyPos.Z += Me->BaseEyeHeight;
    
    	HisPos = Target->Location;
    	HisPos.Z += Target->CollisionHeight * 0.75;
    
    	if ( Me->XLevel->Model->FastLineCheck(HisPos, MyPos) > 0 )
    	{
    		return true;
    	}
    	else
    	{
    		return false;
    	}
    }
    
    
    bool inline IsEnemy (APawn* Target)
    {
    	if ( (Me->GameReplicationInfo != NULL) && (Me->GameReplicationInfo->bTeamGame) )
    	{
    		if (Target->PlayerReplicationInfo->Team != Me->PlayerReplicationInfo->Team)
    		{
    			return true;
    		}
    		else
    		{
    			return false;
    		}
    	}
    	else
    	{
    		return true;
    	}
    }
    
    
    #define Normalize(Rot) \
    	while (Rot.Yaw > 32768) Rot.Yaw -= 65536; \
    	while (Rot.Yaw < -32768) Rot.Yaw += 65536; \
    	while (Rot.Pitch > 32768) Rot.Pitch -= 65536; \
    	while (Rot.Pitch < -32768) Rot.Pitch += 65536; \
    
    
    void inline SetMyRotation (APawn* Target)
    {
    	FVector MyPos, HisPos;
    
    	MyPos = Me->Location;
    	MyPos.Z += Me->BaseEyeHeight;
    
    	HisPos = Target->Location;
    	HisPos.Z += Target->CollisionHeight * 0.75;
    
        Me->ViewRotation = (HisPos - MyPos).Rotation();
    
    }
    
    
    APawn* GetBestTarget (APawn* BestTarget, APawn* Target)
    {
    	if ( BestTarget == NULL )
    	{
    		return Target;
    	}
    	else
    	{
    		if ( (Target->Location - Me->Location).Size() < (BestTarget->Location - Me->Location).Size() )
    		{
    			return Target;
    		}
    		else
    		{
    			return BestTarget;
    		}
    	}
    }
    
    
    bool inline ValidTarget (APawn* Target)
    {
    	return	(Target != NULL) &&
    			(Target != Me) &&
    			(!Target->bHidden) &&
    			(!Target->bDeleteMe) &&
    			(Target->bIsPlayer) &&
    			(Target->Health > 0) &&
    			(Target->PlayerReplicationInfo != NULL) &&
    			(!Target->PlayerReplicationInfo->bIsSpectator) &&
    			(!Target->PlayerReplicationInfo->bWaitingPlayer) &&
    			(Target->Level == Me->Level);
    
    	return  (Target != NULL) &&
    			(Target != Me) &&
    			(Target->Health > 0) &&
    			(!Target->bHidden) &&
    			(!Target->bDeleteMe) &&
    			(Target->bCollideActors) &&
    			(Target->bIsPlayer) &&
    			(Target->DrawType != DT_None) &&
    			(Target->Style != STY_None) &&
    			(Target->PlayerReplicationInfo != NULL) &&
    			(!Target->PlayerReplicationInfo->bIsSpectator) &&
    			(!Target->PlayerReplicationInfo->bWaitingPlayer) &&
    			(Target->Level == Me->Level);
    }
    
    
    bool inline ValidRender (UCanvas* Canvas)
    {
    	return	(Canvas != NULL) &&
    			(Canvas->SmallFont != NULL) &&	
    			(Canvas->Viewport != NULL) &&
    			(Canvas->Viewport->Actor != NULL) &&
    			(Canvas->Viewport->Actor->PlayerReplicationInfo != NULL) &&
    			(Canvas->Viewport->Actor->XLevel != NULL);
    }
    
    
    void inline PawnRelated (UCanvas* Canvas)
    {
    	APawn* BestTarget = NULL;
    
    	for (TObjectIterator<APawn> Target; Target; ++Target)
    	{
    		if ( ValidTarget(*Target) )
    		{
    			if( b3DRadar )
    			{
    				DrawPlayerOnRadar(Canvas, *Target);
    			}
                  if ( bAutoAim )
    			{
    				if ( IsGoodWeapon() && IsEnemy(*Target) && IsVisible(*Target) ) 
    				{
    					BestTarget = GetBestTarget(BestTarget, *Target);
    				}
    			}
    		}
    	}
    
    	if ( BestTarget != NULL )
    	{
    		SetMyRotation(BestTarget);
    
    		if ( bAutoFire )
    		{
    			FireMyWeapon();
    		}
    	}
    	else
    	{
    		StopMyWeapon();
    	}
    }
    
    
    void inline MyPostRender (UCanvas* Canvas)
    {
    	if ( !ValidRender(Canvas) ) return;
    
    	Me = Canvas->Viewport->Actor;
    
    	PawnRelated(Canvas);
    
    	SetPos(20, Canvas->ClipY / 2)
    	Canvas->WrappedPrintf(Canvas->MedFont,0,TEXT("---------"));
    	SetPos(20, Canvas->ClipY / 2 + 10)
    	Canvas->WrappedPrintf(Canvas->MedFont,0,TEXT(" DoraHook "));
    	SetPos(20, Canvas->ClipY / 2 + 20)
    	Canvas->WrappedPrintf(Canvas->MedFont,0,TEXT("---------"));
        SetPos(20, Canvas->ClipY / 2 + 30)
    	Canvas->WrappedPrintf(Canvas->MedFont,0,TEXT("AutoAim: %d"), bAutoAim);
    	SetPos(20, Canvas->ClipY / 2 + 40)
    	Canvas->WrappedPrintf(Canvas->MedFont,0,TEXT("AutoFire: %d"), bAutoFire);
    	SetPos(20, Canvas->ClipY / 2 + 50)
    	Canvas->WrappedPrintf(Canvas->MedFont,0,TEXT("3DRadar: %d"), b3DRadar);
    	SetPos(20, Canvas->ClipY / 2 + 60)
    }
    
    
    void *pProcessEvent;
    
    
    void WINAPI xProcessEvent (class UFunction* Function, void* Parms, void* Result=NULL)
    {
    	__asm pushad
    
    	if ( Function->FriendlyName == ENGINE_PostRender )
    	{
    		if ( Function->GetOwnerClass()->IsChildOf(APlayerPawn::StaticClass()) )
    		{
    			MyPostRender(((APlayerPawn_eventPostRender_Parms*)Parms)->Canvas);
    		}
    	}
    
    	__asm popad
    
    	__asm
    	{
    		push Result
    		push Parms
    		push Function
    		call pProcessEvent
    	}
    
    	__asm pushad
    
    	if ( Function->FriendlyName == ENGINE_PlayerCalcView )
    	{
    		if ( Function->GetOwnerClass()->IsChildOf(APlayerPawn::StaticClass()) )
    		{
    			MyCameraLocation = ((APlayerPawn_eventPlayerCalcView_Parms*)Parms)->CameraLocation;
    			MyCameraRotation = ((APlayerPawn_eventPlayerCalcView_Parms*)Parms)->CameraRotation;
    		}
    	}
    
    	__asm popad
    }
    
    
    void HookFunctions (void)
    {
    	HMODULE hCore = GetModuleHandleA("Core.dll");
    
    	if ( hCore != NULL )
    	{
    		void *pAddress = (void*)GetProcAddress(hCore, "?ProcessEvent@UObject@@UAEXPAVUFunction@@PAX1@Z");
    
    		if ( pAddress != NULL )
    		{
    			pProcessEvent = DetourJump(pAddress, xProcessEvent);
    		}
    	}
    }
    
    
    BOOL APIENTRY DllMain (HMODULE hDll, DWORD reason, PVOID lpReserved)
    {
    	if( reason == DLL_PROCESS_ATTACH )
      	{
    		DisableThreadLibraryCalls(hDll);
    		HookFunctions();
    	}
    
    	return TRUE;
    }

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    That helps no one.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6
    It's an aimbot/radar... I was asking how to tweak it...

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I got an idea. How bout you stop cheating at the game at take your lamo aimbot crap somewhere else.



    This is isn't a mod it's an aimbot cheat. I deal daily with your type on Delta Force Extreme, Joint Ops, and other games. Just learn to get good at the game w/o cheating at it.

    Aimbots are cheats. Period.

    This is a not the type of hooking of DLLs I like to see:

    Code:
    void HookFunctions (void)
    {
    	HMODULE hCore = GetModuleHandleA("Core.dll");
    
    	if ( hCore != NULL )
    	{
    		void *pAddress = (void*)GetProcAddress(hCore, "?ProcessEvent@UObject@@UAEXPAVUFunction@@PAX1@Z");
    
    		if ( pAddress != NULL )
    		{
    			pProcessEvent = DetourJump(pAddress, xProcessEvent);
    		}
    	}
    }
    
    
    BOOL APIENTRY DllMain (HMODULE hDll, DWORD reason, PVOID lpReserved)
    {
    	if( reason == DLL_PROCESS_ATTACH )
      	{
    		DisableThreadLibraryCalls(hDll);
    		HookFunctions();
    	}
    
    	return TRUE;
    }
    Last edited by VirtualAce; 06-06-2005 at 08:54 PM.

  5. #5
    ---
    Join Date
    May 2004
    Posts
    1,379
    hehe

  6. #6

    Join Date
    May 2005
    Posts
    1,042
    I can't even tell what that code is really supposed to do...while I suppose it is possible it could be bot AI code I have seen posts lately in the Game forum about people wanting to write cheats, therefore I'm equally wary.

  7. #7
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    It's just targeting the nearest enemy for you and creating an auto-fire solution. Essentially you just move your guy and when an enemy is pickedc up on radar, regardless of his position, stance, or cover...the aimbot will create a rotation matrix to rotate the player so that he is facing the enemy and will automatically fire the gun.

    Most of the functions just check to see if the target found is an enemy or friend. One of the functions creates the rotation matrix (can be accomplished as well using D3DXMatrixLookAtLH() or RH()), and one of the the functions actually renders the cheat radar which shows exactly where the enemy is.

    The two bottom functions hook the DLL process in a way that is suspect at best. Essentially GetProcAddress will return the address of a process or function. He hooks the DLL, gets the address of a function so he can trap for messages from the game and essentially control the player. He is mapping this file into the address space of the game - in fact he must because Windows does not allow you to use GetModuleHandleA() from another address space - or another program. I'm not sure what DetourJump does but I'm sure it's just as stupid.

    It's not a good habit to get into and what people don't understand is that this creates a lot of system instability.

    For more information look in your SDK under hooking DLLs or look up some of the API functions used in the code. You will begin to see what is going on.

  8. #8

    Join Date
    May 2005
    Posts
    1,042
    I must say I have never dabbled with cheats before, but I find that interesting so I may take a look at it. I wish programmers would all use their skills for good instead of evil.

  9. #9
    Registered User
    Join Date
    May 2005
    Posts
    73
    damn u all.. u are putting evil thoughts into my innocent programming brain... this isn't healthy..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading in a two line file
    By deadpickle in forum C Programming
    Replies: 1
    Last Post: 05-08-2009, 05:35 PM
  2. Game radar
    By VirtualAce in forum Game Programming
    Replies: 0
    Last Post: 04-03-2008, 07:33 PM
  3. Weird twisters?
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 40
    Last Post: 02-08-2008, 01:18 PM
  4. Texas UFO sightings
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 02-06-2008, 03:33 PM
  5. drawing minimaps and radar screens.
    By Eber Kain in forum Game Programming
    Replies: 4
    Last Post: 03-08-2002, 11:44 AM