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;
}