Special Force 2 完整SDK + Source
版上沒什麼類似這樣的文章分享 或者 該款遊戲的外掛輔助都是成品或者廣告商
故想說盡這麼一小份心力,提供相關的文章供學習參考用
小弟我個人非原創 , 但保證絕對可用。
有興趣的要研究的 歡迎詢問
可以在下方留言給我,我會盡我能知道的盡量回答。
之後看情況發"可執行檔"
遊戲引擎繪製 " Unreal Engine 3 "
其功能包含:方框,骨骼,頭圈,標記線,血量,距離透視 + 十字準心
同以下程式碼。
程式碼內涵:自瞄,2D雷達,3D框透,敵我判別+選項設定
有興趣的可以加以研究,學習。
Visual Studio 2017 編譯
MenuDefines.hpp#define URotationToRadians( URotation ) ( ( URotation ) * ( CONST_Pi / 32768.0f ) )
bool bHWNDtaken = false;
HWND hwnd;
INT Spam = 0;
FLOAT LastTickSpam = 0.0f;
FLOAT CurrentTickSpam;
INT Bone = 0;
FLOAT LastTickBone = 0.0f;
FLOAT CurrentTickBone;
INT RandBone = 0;
FLOAT LastTickRandBone = 0.0f;
FLOAT CurrentTickRandBone;
bool bEnableAim = false;
wchar_t* wAimKey[] = { L"RMOUSE", L"LMOUSE", L"SHIFT", L"L.ALT", L"ALWAYS" };
int iAimKey = 0;
wchar_t* wAimBy[] = { L"DISTANCE", L"FOV", L"HP" };
int iAimBy = 0;
wchar_t* wFovAngle[] = { L"1", L"2", L"3", L"5", L"10", L"25", L"30", L"45" };
int iFovAngle = 0;
wchar_t* wHPLimit[] = { L"0", L"25", L"50", L"75", L"99" };
int iHPLimit = 0;
wchar_t* wAimPosition[] = { L"RAND", L"HEAD", L"CHEST", L"HAND" };
int iAimPosition = 0;
wchar_t* wBoneRefreshTime[] = { L"0", L"20ms", L"40ms", L"60ms", L"80ms", L"100ms" };
int iBoneRefreshTime = 0;
bool bBoneRefreshed = false;
bool bAutoFire = false;
wchar_t* wSmoothAim[] = { L"0", L"1", L"2", L"3", L"4", L"5" };
int iSmoothAim = 0;
bool bSilentAim = false;
bool bSmartAccuracy = false;
bool bHardLock = false;
wchar_t* wEnableEsp[] = { L"ENEMY", L"TEAM", L"BOTH" };
int iEnableEsp = 2;
bool bNameEsp = false;
bool bDistanceEsp = false;
bool bHealthEsp = false;
bool bBoneEsp = false;
bool bHeadCircle = false;
wchar_t* wBoundingBox[] = { L"OFF", L"3D", L"2D" };
int iBoundingBox = 0;
bool bLaserEsp = false;
bool AlienZombie = false;
bool bSnapLines = false;
bool bGrenadeEsp = false;
bool bDeadVisible = false;
bool bShowStats = false;
wchar_t* wEnemyVis[] = { L"BLUE", L"RED", L"YELLOW" };
int iEnemyVis = 1;
wchar_t* wEnemyInv[] = { L"BLUE", L"RED", L"YELLOW" };
int iEnemyInv = 0;
wchar_t* wTeamVis[] = { L"BLUE", L"GREEN", L"YELLOW" };
int iTeamVis = 1;
wchar_t* wTeamInv[] = { L"BLUE", L"GREEN", L"YELLOW" };
int iTeamInv = 1;
wchar_t* wCrosshair[] = { L"OFF", L"ON" };
int iCrosshair = 0;
wchar_t* wCrosshairSize[] = { L"5", L"6", L"7", L"8", L"9", L"10", L"11", L"12", L"13", L"14", L"15", L"16", L"17", L"18", L"19", L"20", L"21", L"22", L"23", L"24", L"25", L"26", L"27", L"28", L"29", L"30", L"31", L"32", L"33", L"34", L"35", L"36", L"37", L"38", L"39", L"40", L"41", L"42", L"43", L"44", L"45", L"46", L"47", L"48", L"49", L"50", L"51", L"52", L"53", L"54", L"55", L"56", L"57", L"58", L"59", L"60", L"61", L"62", L"63", L"64", L"65", L"66", L"67", L"68", L"69", L"70", L"71", L"72", L"73", L"74", L"75", L"76", L"77", L"78", L"79", L"80", L"81", L"82", L"83", L"84", L"85", L"86", L"87", L"88", L"89", L"90", L"91", L"92", L"93", L"94", L"95", L"96", L"97", L"98", L"99", L"100" };
int iCrosshairSize = 0;
bool bDropWeapon;
int iPlayerRadius = 0;
wchar_t userData;
DWORD userDataSize = 160;
#define Bone_Root 0
#define Bone_Hand_L 3
#define Bone_Hand_R 4
#define Bone_Foot_L 6
#define Bone_Foot_R 7
#define Bone_Pelvis 9
#define Bone_Spine 10
#define Bone_Spine1 11
#define Bone_Spine2 12
#define Bone_Neck 13
#define Bone_Head 14
#define Bone_Helmet 15
#define Bone_LClavicle 16
#define Bone_LArmUp 17
#define Bone_LArmLow 18
#define Bone_LHand 19
#define Bone_RClavicle 37
#define Bone_RArmUp 38
#define Bone_RArmLow 39
#define Bone_RHand 40
#define Bone_LLegUp 58
#define Bone_LLegLow 59
#define Bone_LFoot 60
#define Bone_RLegUp 62
#define Bone_RLegLow 63
#define Bone_RFoot 64
PostRender.hpp#ifndef _POSTRENDER_HPP
#define _POSTRENDER_HPP
#include "MenuDefines.hpp"
#define HACK_MAJOR_VERSION 1
#define HACK_MINOR_VERSION 1
using namespace std;
HWND hSf2 = NULL;
ASFPlayerController* PlayerController;
FRotator SilentAimRot;
bool Restored = false;
bool Saved = false;
bool Loaded = false;
int iRandomNum = 14;
bool bRandomNumChange = false;
bool IsMyPawn = false;
bool bBullet = false;
bool bOPKKey = false;
bool bRespawnKey = false;
bool bHeroKey1 = false;
bool bHeroKey2 = false;
bool bRButton = false;
bool bLButton = false;
bool bShiftButton = false;
bool bAltButton = false;
float MouseX;
float MouseY;
int SlideBoxMin = 304;
int SlideBoxMax = 454;
#define MapColorValueA(health, inMax) (unsigned char)(255 - (((((health - inMax) * 100) / inMax) * 255) / 100))
#define MapColorValueB(health, inMax) (unsigned char)((((health * 100) / inMax) * 255) / 100)
#define MakeColor(R, G, B) { B, G, R, 255 }
FColor Black MakeColor(0, 0, 0);
FColor Gray MakeColor(110, 110, 110);
FColor White MakeColor(255, 255, 255);
FColor Red MakeColor(85, 85, 85);
FColor Menu MakeColor(128, 196, 196);
FColor Green MakeColor(0, 255, 0);
FColor Blue MakeColor(0, 162, 232);
FColor Orange MakeColor(255, 0, 0);
FColor Yellow MakeColor(255, 255, 0);
FColor Cyan MakeColor(128, 255, 255);
enum BONE
{
CHEST = 12, HEAD = 14,
LEFT_SHOULDER = 17, LEFT_ELBOW, LEFT_WRIST,
RIGHT_SHOULDER = 38, RIGHT_ELBOW, RIGHT_WRIST,
LEFT_HIP = 58, LEFT_KNEE, LEFT_ANKLE, LEFT_TOE,
RIGHT_HIP = 62, RIGHT_KNEE, RIGHT_ANKLE, RIGHT_TOE
};
UObject* GetInstanceOf(UClass* Class)
{
static UObject* ObjectInstance;
ObjectInstance = NULL;
for (int i = 0; i < UObject::GObjObjects()->Count; ++i)
{
UObject* CheckObject = (*UObject::GObjObjects())(i);
if (CheckObject && CheckObject->IsA(Class))
{
if (!strstr(CheckObject->GetFullName(), "Default"))
ObjectInstance = CheckObject;
}
}
return ObjectInstance;
};
FVector inline Vector_Sub(FVector v1, const FVector& v2)
{
v1.X -= v2.X;
v1.Y -= v2.Y;
v1.Z -= v2.Z;
return v1;
}
FRotator inline Rotator_Sub(FRotator r1, const FRotator& r2)
{
r1.Pitch -= r2.Pitch;
r1.Yaw -= r2.Yaw;
r1.Roll -= r2.Roll;
return r1;
}
FRotator inline Rotator_Sum(FRotator r1, const FRotator& r2)
{
r1.Pitch += r2.Pitch;
r1.Yaw += r2.Yaw;
r1.Roll += r2.Roll;
return r1;
}
FRotator inline VectorToRotation(const FVector& vector)
{
FRotator rotation;
rotation.Pitch = PlayerController->Atan2(vector.Z, PlayerController->Sqrt((vector.X * vector.X) + (vector.Y * vector.Y))) * CONST_RadToUnrRot;
rotation.Yaw = PlayerController->Atan2(vector.Y, vector.X) * CONST_RadToUnrRot;
rotation.Roll = 0;
return rotation;
}
FVector cameraLocation;
FRotator cameraRotation;
FVector WorldToScreen(UCanvas* canvas, const FVector& location)
{
FVector output,
axisX, axisY, axisZ, delta, transformed;
canvas->GetAxes(cameraRotation, &axisX, &axisY, &axisZ);
delta = PlayerController->Subtract_VectorVector(location, cameraLocation);
transformed.X = PlayerController->Dot_VectorVector(delta, axisY);
transformed.Y = PlayerController->Dot_VectorVector(delta, axisZ);
transformed.Z = PlayerController->Dot_VectorVector(delta, axisX);
if (transformed.Z < 1)
transformed.Z = 1;
float FOVAngle = PlayerController->PlayerCamera->GetFOVAngle();
output.X = (canvas->ClipX / 2) + transformed.X * ((canvas->ClipX / 2) / PlayerController->Tan(FOVAngle * CONST_Pi / 360)) / transformed.Z;
output.Y = (canvas->ClipY / 2) + -transformed.Y * ((canvas->ClipX / 2) / PlayerController->Tan(FOVAngle * CONST_Pi / 360)) / transformed.Z;
return output;
}
void inline Draw2DLine(UCanvas* canvas, APawn* pawn, const FColor& color)
{
FVector location = pawn->Location;
location = WorldToScreen(canvas, location);
canvas->Draw2DLine(canvas->ClipX / 2, canvas->ClipY, location.X, location.Y, color);
}
bool inline IsVisible(const FVector& end, APawn* pawn)
{
FVector extent = { 0, 0, 0 };
FVector hitLocation;
FVector hitNormal;
FTraceHitInfo hitInfo;
AActor* actor = PlayerController->Trace(end, cameraLocation, true, extent, 0, &hitLocation, &hitNormal, &hitInfo);
return (pawn == actor);
}
bool IsTargetVisible(APawn* target)
{
if (!target->Mesh)
return false;
if (PlayerController->CanSee(target))
return true;
FVector boneLocation;
char table[] = { 14, 19, 40, 61, 65 };
for (int i = 0; i < 5; i++)
{
boneLocation = target->Mesh->GetBoneLocation(target->Mesh->GetBoneName(table), 0);
if (IsVisible(boneLocation, target))
return true;
}
return false;
}
bool inline IsSameTeam(APawn* pawn, APawn* target)
{
return PlayerController->WorldInfo
&& PlayerController->WorldInfo->GRI
&& PlayerController->WorldInfo->GRI->OnSameTeam(pawn, target);
}
float inline Get3DDistance(AActor* pawn, AActor* target)
{
return sqrt
(pow(target->Location.X - pawn->Location.X, 2)
+ pow(target->Location.Y - pawn->Location.Y, 2)
+ pow(target->Location.Z - pawn->Location.Z, 2));
}
FRotator inline LimitRotation(UCanvas* canvas, const FRotator& startRotation, const FRotator& endRotation)
{
int realSmoothAim = 9999;
if (iSmoothAim == 1) realSmoothAim = 5;
else
if (iSmoothAim == 2) realSmoothAim = 4;
else
if (iSmoothAim == 3) realSmoothAim = 3;
else
if (iSmoothAim == 4) realSmoothAim = 2;
else
if (iSmoothAim == 5) realSmoothAim = 1;
int maxRotation = realSmoothAim * 100;
FRotator deltaRotation = canvas->Normalize(Rotator_Sub(endRotation, startRotation));
if (deltaRotation.Yaw > maxRotation) { deltaRotation.Yaw = maxRotation; }
else if (deltaRotation.Yaw < -maxRotation) { deltaRotation.Yaw = -maxRotation; }
if (deltaRotation.Pitch > maxRotation) { deltaRotation.Pitch = maxRotation; }
else if (deltaRotation.Pitch < -maxRotation) { deltaRotation.Pitch = -maxRotation; }
return Rotator_Sum(startRotation, deltaRotation);
}
bool IsInFOV(APawn* pawn, APawn* target)
{
double dist;
int HP = iHPLimit * 25;
if (HP == 100) HP = 99;
if (target->bDeleteMe
|| target->Health < 1
|| IsSameTeam(pawn, target)
|| (!IsTargetVisible(target))
|| target->Health <= HP
|| target == pawn)
return false;
float dist2 = Get3DDistance(pawn, target);
FRotator newRotation = VectorToRotation(Vector_Sub(target->Location, cameraLocation));
float fYaw = PlayerController->Rotation.Yaw - newRotation.Yaw;
if (fYaw < 0) fYaw = -fYaw;
fYaw = (fYaw / 182.0444f);
int HowMany = (int)fYaw;
int Inside = HowMany / 360;
if (Inside > 0) fYaw = (fYaw - (360 * Inside));
switch (iFovAngle)
{
case 0:
if (fYaw <= 1) return true;
else return false;
break;
case 1:
if (fYaw <= 2) return true;
else return false;
break;
case 2:
if (fYaw <= 3) return true;
else return false;
break;
case 3:
if (fYaw <= 5) return true;
else return false;
break;
case 4:
if (fYaw <= 10) return true;
else return false;
break;
case 5:
if (fYaw <= 25) return true;
else return false;
break;
case 6:
if (fYaw <= 30) return true;
else return false;
break;
case 7:
if (fYaw <= 45) return true;
else return false;
break;
default:
return false;
}
}
void inline AutoAim(UCanvas* canvas, AWeapon* weapon, APawn* target)
{
if (target->Health < 1 || !target->Mesh || target->bDeleteMe) return;
FVector boneLocation;
if (bRandomNumChange == true)
{
iRandomNum = rand() % 61;
bRandomNumChange = false;
}
if (iAimPosition == 0) boneLocation = target->Mesh->GetBoneLocation(target->Mesh->GetBoneName(iRandomNum), 0);
else if (iAimPosition == 1) boneLocation = target->Mesh->GetBoneLocation(target->Mesh->GetBoneName(HEAD), 0);
else if (iAimPosition == 2) boneLocation = target->Mesh->GetBoneLocation(target->Mesh->GetBoneName(CHEST), 0);
else if (iAimPosition == 3) boneLocation = target->Mesh->GetBoneLocation(target->Mesh->GetBoneName(RIGHT_WRIST), 0);
FRotator newRotation = VectorToRotation(Vector_Sub(boneLocation, cameraLocation));
FRotator OldRotation = PlayerController->Pawn->Rotation;
if (iSmoothAim > 0)
newRotation = LimitRotation(canvas, cameraRotation, newRotation);
float bak1, bak2, bak3;
if ((ASFPawn_Player*)PlayerController->Pawn)
{
bak1 = ((ASFPawn_Player*)PlayerController->Pawn)->RecoilResult.impactIncreaseEye;
bak2 = ((ASFPawn_Player*)PlayerController->Pawn)->RecoilResult.impactSpinZ;
bak3 = ((ASFPawn_Player*)PlayerController->Pawn)->RecoilResult.spinz;
((ASFPawn_Player*)PlayerController->Pawn)->RecoilResult.impactIncreaseEye = 0.0f;
((ASFPawn_Player*)PlayerController->Pawn)->RecoilResult.impactSpinZ = 0.0f;
((ASFPawn_Player*)PlayerController->Pawn)->RecoilResult.spinz = 0.0f;
}
PlayerController->Rotation = newRotation;
PlayerController->Pawn->Rotation = newRotation;
PlayerController->PlayerCamera->Rotation = newRotation;
PlayerController->Pawn->ClientSetRotation(newRotation);
PlayerController->rotInput = newRotation;
}
FRotator CalcSilentAimRot(APawn* target)
{
if (target->Health < 1 || !target->Mesh || target->bDeleteMe) return { 0,0,0 };
FVector boneLocation;
if (bRandomNumChange == true)
{
iRandomNum = rand() % 61;
bRandomNumChange = false;
}
if (iAimPosition == 0) boneLocation = target->Mesh->GetBoneLocation(target->Mesh->GetBoneName(iRandomNum), 0);
else if (iAimPosition == 1) boneLocation = target->Mesh->GetBoneLocation(target->Mesh->GetBoneName(HEAD), 0);
else if (iAimPosition == 2) boneLocation = target->Mesh->GetBoneLocation(target->Mesh->GetBoneName(CHEST), 0);
else if (iAimPosition == 3) boneLocation = target->Mesh->GetBoneLocation(target->Mesh->GetBoneName(RIGHT_WRIST), 0);
FRotator newRotation = VectorToRotation(Vector_Sub(boneLocation, cameraLocation));
return newRotation;
}
APawn* FindClosedTarget(APawn* pawn, APawn* target)
{
APawn* result = NULL;
double dist;
int HP = iHPLimit * 25;
if (HP == 100) HP = 99;
while (target)
{
if (target->bDeleteMe
|| target->Health < 1
|| !target->IsAliveAndWell()
|| IsSameTeam(pawn, target)
|| (!IsTargetVisible(target))
|| target->Health <= HP
|| target == pawn)
{
target = target->NextPawn;
continue;
}
if (iAimBy == 1 && !IsInFOV(pawn, target))
{
target = target->NextPawn;
continue;
}
float dist2 = Get3DDistance(pawn, target);
if (!result || (dist2 < dist))
{
result = target;
dist = dist2;
}
target = target->NextPawn;
}
return result;
}
APawn* FindLowestHP(APawn* pawn, APawn* target)
{
APawn* result = NULL;
int hp1;
while (target)
{
if (target->bDeleteMe
|| target->Health < 1
|| IsSameTeam(pawn, target)
|| !target->IsAliveAndWell()
|| (!IsTargetVisible(target))
|| target == pawn)
{
target = target->NextPawn;
continue;
}
if (iAimBy != 2) return nullptr;
int hp2 = target->Health;
if (!result || (hp2 < hp1))
{
result = target;
hp1 = hp2;
}
target = target->NextPawn;
}
return result;
}
void HeadCircle(APawn* target, UCanvas* pCanvas, int numSides, FColor Color)
{
FVector hHead = target->Mesh->GetBoneLocationByIndex(14, 0);
hHead = WorldToScreen(pCanvas, hHead);
FVector HeadUp = target->Mesh->GetBoneLocationByIndex(14, 0);
HeadUp.Z += 14;
HeadUp = WorldToScreen(pCanvas, HeadUp);
FVector HeadLeft = target->Mesh->GetBoneLocationByIndex(14, 0);
HeadLeft.X += 14;
HeadLeft = WorldToScreen(pCanvas, HeadLeft);
FVector HeadRight = target->Mesh->GetBoneLocationByIndex(14, 0);
HeadRight.Y += 14;
HeadRight = WorldToScreen(pCanvas, HeadRight);
int X = hHead.X;
int Y = hHead.Y;
int radius = 0;
int up = (HeadUp.Y - hHead.Y);
int left = (X - HeadLeft.X);
int right = (X - HeadRight.X);
if (up < 0) up = -up;
if (left < 0) left = -left;
if (right < 0) right = -right;
if (up >= left && up >= right) radius = up;
else if (left >= up && left >= right) radius = left;
else if (right >= up && right >= up) radius = right;
if (radius < 0) radius = -radius;
float Step = CONST_Pi * 2.0 / numSides;
int Count = 0;
FVector2D V;
for (float a = 0; a < CONST_Pi * 2.0; a += Step) {
float X1 = radius * cos(a) + X;
float Y1 = radius * sin(a) + Y;
float X2 = radius * cos(a + Step) + X;
float Y2 = radius * sin(a + Step) + Y;
V.X = X1;
V.Y = Y1;
V.X = X2;
V.Y = Y2;
pCanvas->Draw2DLine(V.X, V.Y, X2, Y2, Color);
}
}
void inline DrawHealthBar(UCanvas* canvas, APawn* pawn)
{
FVector min, max, center;
FBox box;
pawn->GetComponentsBoundingBox(&box);
if (box.IsValid)
{
min = box.Min;
max = box.Max;
float size = (70.0f / pawn->HealthMax) * pawn->Health;
FColor color;
if (pawn->Health > (pawn->HealthMax / 2))
{
color = MakeColor(MapColorValueA(pawn->Health, (pawn->HealthMax / 2)), 255, 0);
}
else
{
color = MakeColor(255, MapColorValueB(pawn->Health, (pawn->HealthMax / 2)), 0);
}
float W = max.X - min.X;
float H = max.Y - min.Y;
float D = max.Z - min.Z;
center.X = max.X - (W / 2);
center.Y = max.Y - (H / 2);
center.Z = max.Z - (D + 8);
center = WorldToScreen(canvas, center);
center.Y += 7;
canvas->Draw2DLine(center.X - 35 - 1, center.Y, ((center.X - 35) + size), center.Y, color);
canvas->Draw2DLine(center.X - 35 - 1, center.Y - 1, ((center.X - 35) + size), center.Y - 1, color);
canvas->Draw2DLine(center.X - 35 - 1, center.Y - 2, ((center.X - 35) + size), center.Y - 2, color);
canvas->Draw2DLine(center.X - 35 - 1, center.Y - 3, ((center.X - 35) + size), center.Y - 3, color);
canvas->Draw2DLine(center.X - 36, center.Y + 1, center.X + 36, center.Y + 1, Black);
canvas->Draw2DLine(center.X - 36 - 1, center.Y - 4, center.X + 36, center.Y - 4, Black);
canvas->Draw2DLine(center.X - 36, center.Y - 4, center.X - 36, center.Y + 1, Black);
canvas->Draw2DLine(center.X + 36, center.Y - 4, center.X + 36, center.Y + 1, Black);
}
}
void DrawPlayerBones(UCanvas* pCanvas, APawn* Target, FColor Color)
{
FVector vTopHead, vHead, vNeck, vPelvis, vLArmUp, vLArmLow, vLHand, vLLegUp, vLLegLow, vLFoot, vRArmUp, vRArmLow, vRHand, vRLegUp, vRLegLow, vRFoot;
vHead = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(14, 0));
vNeck = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_Neck, 0));
vPelvis = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_Pelvis, 0));
vLArmUp = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_LArmUp, 0));
vLArmLow = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_LArmLow, 0));
vLHand = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_LHand, 0));
vLLegUp = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_LLegUp, 0));
vLLegLow = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_LLegLow, 0));
vLFoot = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_LFoot, 0));
vRArmUp = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_RArmUp, 0));
vRArmLow = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_RArmLow, 0));
vRHand = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_RHand, 0));
vRLegUp = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_RLegUp, 0));
vRLegLow = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_RLegLow, 0));
vRFoot = WorldToScreen(pCanvas, Target->Mesh->GetBoneLocationByIndex(Bone_RFoot, 0));
pCanvas->Draw2DLine(vHead.X, vHead.Y, vNeck.X, vNeck.Y, Color);
pCanvas->Draw2DLine(vNeck.X, vNeck.Y, vPelvis.X, vPelvis.Y, Color);
pCanvas->Draw2DLine(vLArmUp.X, vLArmUp.Y, vNeck.X, vNeck.Y, Color);
pCanvas->Draw2DLine(vRArmUp.X, vRArmUp.Y, vNeck.X, vNeck.Y, Color);
pCanvas->Draw2DLine(vLLegUp.X, vLLegUp.Y, vPelvis.X, vPelvis.Y, Color);
pCanvas->Draw2DLine(vRLegUp.X, vRLegUp.Y, vPelvis.X, vPelvis.Y, Color);
pCanvas->Draw2DLine(vLArmUp.X, vLArmUp.Y, vLArmLow.X, vLArmLow.Y, Color);
pCanvas->Draw2DLine(vLArmLow.X, vLArmLow.Y, vLHand.X, vLHand.Y, Color);
pCanvas->Draw2DLine(vLLegUp.X, vLLegUp.Y, vLLegLow.X, vLLegLow.Y, Color);
pCanvas->Draw2DLine(vLLegLow.X, vLLegLow.Y, vLFoot.X, vLFoot.Y, Color);
pCanvas->Draw2DLine(vRArmUp.X, vRArmUp.Y, vRArmLow.X, vRArmLow.Y, Color);
pCanvas->Draw2DLine(vRArmLow.X, vRArmLow.Y, vRHand.X, vRHand.Y, Color);
pCanvas->Draw2DLine(vRLegUp.X, vRLegUp.Y, vRLegLow.X, vRLegLow.Y, Color);
pCanvas->Draw2DLine(vRLegLow.X, vRLegLow.Y, vRFoot.X, vRFoot.Y, Color);
}
void inline Draw3DBoundingBox(UCanvas* canvas, APawn* pawn, const FColor& color)
{
if (pawn->Health < 1) return;
FVector min, max, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8;
FBox box;
pawn->GetComponentsBoundingBox(&box);
if (box.IsValid)
{
min = box.Min;
max = box.Max;
vec3 = min;
vec3.X = max.X;
vec4 = min;
vec4.Y = max.Y;
vec5 = min;
vec5.Z = max.Z;
vec6 = max;
vec6.X = min.X;
vec7 = max;
vec7.Y = min.Y;
vec8 = max;
vec8.Z = min.Z;
vec1 = WorldToScreen(canvas, min);
vec2 = WorldToScreen(canvas, max);
vec3 = WorldToScreen(canvas, vec3);
vec4 = WorldToScreen(canvas, vec4);
vec5 = WorldToScreen(canvas, vec5);
vec6 = WorldToScreen(canvas, vec6);
vec7 = WorldToScreen(canvas, vec7);
vec8 = WorldToScreen(canvas, vec8);
canvas->Draw2DLine(vec1.X, vec1.Y, vec5.X, vec5.Y, color);
canvas->Draw2DLine(vec2.X, vec2.Y, vec8.X, vec8.Y, color);
canvas->Draw2DLine(vec3.X, vec3.Y, vec7.X, vec7.Y, color);
canvas->Draw2DLine(vec4.X, vec4.Y, vec6.X, vec6.Y, color);
canvas->Draw2DLine(vec1.X, vec1.Y, vec3.X, vec3.Y, color);
canvas->Draw2DLine(vec1.X, vec1.Y, vec4.X, vec4.Y, color);
canvas->Draw2DLine(vec8.X, vec8.Y, vec3.X, vec3.Y, color);
canvas->Draw2DLine(vec8.X, vec8.Y, vec4.X, vec4.Y, color);
canvas->Draw2DLine(vec2.X, vec2.Y, vec6.X, vec6.Y, color);
canvas->Draw2DLine(vec2.X, vec2.Y, vec7.X, vec7.Y, color);
canvas->Draw2DLine(vec5.X, vec5.Y, vec6.X, vec6.Y, color);
canvas->Draw2DLine(vec5.X, vec5.Y, vec7.X, vec7.Y, color);
}
}
void Draw2DBoundingBox(UCanvas* Canvas, APawn* Target, FColor color)
{
if (Target->Health < 1) return;
FBox Box;
Target->GetComponentsBoundingBox(&Box);
FVector vpjMax = WorldToScreen(Canvas, Box.Max);
FVector vpjMin = WorldToScreen(Canvas, Box.Min);
FVector vpjCenter = WorldToScreen(Canvas, Target->Location);
float flWidth = fabs((vpjMax.Y - vpjMin.Y) / 4);
Canvas->Draw2DLine(vpjCenter.X - flWidth, vpjMin.Y, vpjCenter.X + flWidth, vpjMin.Y, color);
Canvas->Draw2DLine(vpjCenter.X - flWidth, vpjMax.Y, vpjCenter.X + flWidth, vpjMax.Y, color);
Canvas->Draw2DLine(vpjCenter.X - flWidth, vpjMin.Y, vpjCenter.X - flWidth, vpjMax.Y, color);
Canvas->Draw2DLine(vpjCenter.X + flWidth, vpjMax.Y, vpjCenter.X + flWidth, vpjMin.Y, color);
}
void inline DrawSnapLines(UCanvas* canvas, APawn* pawn, const FColor& color)
{
FVector location = pawn->Location;
location = WorldToScreen(canvas, location);
canvas->Draw2DLine(canvas->ClipX / 2, canvas->ClipY, location.X, location.Y, color);
}
void inline ESP(UCanvas* canvas, APawn* pawn, APawn* target)
{
if (target == NULL || pawn == NULL || target->Health < 1) return;
if (AlienZombie == false && (target->IsA(ASFPawn_Aliens::StaticClass())
|| target->IsA(ASFPawn_AlienPlayer::StaticClass())
|| target->IsA(ASFPawn_AI_Aliens_Base::StaticClass())
|| target->IsA(ASFZombieHideSeekPlayerController::StaticClass())
|| target->IsA(ASFAIController_ZombieHideSeek::StaticClass())
|| target->IsA(ASFPawnAI_ZombieHideSeekWalker::StaticClass())
|| target->IsA(ASFAIController_Zombie::StaticClass())
|| target->IsA(ASFAIController_ZombieMelee::StaticClass())
|| target->IsA(ASFAIController_ZombiePuker::StaticClass())
|| target->IsA(ASFPawnAI_Zombie::StaticClass())
|| target->IsA(ASFPawnAI_ZombiePunisher::StaticClass())
|| target->IsA(ASFPawnAI_ZombieWalker::StaticClass()))) return;
if (AlienZombie == true && (target->IsA(ASFPawn_Aliens::StaticClass())
|| target->IsA(ASFPawn_AlienPlayer::StaticClass())
|| target->IsA(ASFPawn_AI_Aliens_Base::StaticClass())
|| target->IsA(ASFZombieHideSeekPlayerController::StaticClass())
|| target->IsA(ASFAIController_ZombieHideSeek::StaticClass())
|| target->IsA(ASFPawnAI_ZombieHideSeekWalker::StaticClass())
|| target->IsA(ASFAIController_Zombie::StaticClass())
|| target->IsA(ASFAIController_ZombieMelee::StaticClass())
|| target->IsA(ASFAIController_ZombiePuker::StaticClass())
|| target->IsA(ASFPawnAI_Zombie::StaticClass())
|| target->IsA(ASFPawnAI_ZombiePunisher::StaticClass())
|| target->IsA(ASFPawnAI_ZombieWalker::StaticClass())))
{
ASFPawn* sfTarget = (ASFPawn*)target;
FColor color;
if (sfTarget)
{
if (sfTarget->bIsSpawnProtection) color = Gray;
else
{
if (IsSameTeam(pawn, target))
{
if (IsTargetVisible(target))
{
if (iTeamVis == 0) color = Blue;
if (iTeamVis == 1) color = Green;
if (iTeamVis == 2) color = Yellow;
}
else
{
if (iTeamInv == 0) color = Blue;
if (iTeamInv == 1) color = Green;
if (iTeamInv == 2) color = Yellow;
}
}
else
{
if (IsTargetVisible(target))
{
if (iEnemyVis == 0) color = Menu;
if (iEnemyVis == 1) color = Orange;
if (iEnemyVis == 2) color = Yellow;
}
else
{
if (iEnemyInv == 0) color = Menu;
if (iEnemyInv == 1) color = Orange;
if (iEnemyInv == 2) color = Yellow;
}
}
}
}
else color = Black;
if (iEnableEsp == 0 && !IsSameTeam(pawn, target))
{
if (bHealthEsp) DrawHealthBar(canvas, target);
if (iBoundingBox == 1) Draw3DBoundingBox(canvas, target, color);
if (iBoundingBox == 2) Draw2DBoundingBox(canvas, target, color);
if (bSnapLines) DrawSnapLines(canvas, target, color);
}
else if (iEnableEsp == 1 && IsSameTeam(pawn, target))
{
if (bHealthEsp) DrawHealthBar(canvas, target);
if (iBoundingBox == 1) Draw3DBoundingBox(canvas, target, color);
if (iBoundingBox == 2) Draw2DBoundingBox(canvas, target, color);
if (bSnapLines) DrawSnapLines(canvas, target, color);
}
else if (iEnableEsp == 2)
{
if (bHealthEsp) DrawHealthBar(canvas, target);
if (iBoundingBox == 1) Draw3DBoundingBox(canvas, target, color);
if (iBoundingBox == 2) Draw2DBoundingBox(canvas, target, color);
if (bSnapLines) DrawSnapLines(canvas, target, color);
}
}
else
{
ASFPawn* sfTarget = (ASFPawn*)target;
FColor color;
if (sfTarget)
{
if (sfTarget->bIsSpawnProtection) color = Gray;
else
{
if (IsSameTeam(pawn, target))
{
if (IsTargetVisible(target))
{
if (iTeamVis == 0) color = Blue;
if (iTeamVis == 1) color = Green;
if (iTeamVis == 2) color = Yellow;
}
else
{
if (iTeamInv == 0) color = Blue;
if (iTeamInv == 1) color = Green;
if (iTeamInv == 2) color = Yellow;
}
}
else
{
if (IsTargetVisible(target))
{
if (iEnemyVis == 0) color = Menu;
if (iEnemyVis == 1) color = Orange;
if (iEnemyVis == 2) color = Yellow;
}
else
{
if (iEnemyInv == 0) color = Menu;
if (iEnemyInv == 1) color = Orange;
if (iEnemyInv == 2) color = Yellow;
}
}
}
}
else color = Black;
if (iEnableEsp == 0 && !IsSameTeam(pawn, target))
{
if (bHealthEsp) DrawHealthBar(canvas, target);
if (bBoneEsp) DrawPlayerBones(canvas, target, color);
if (bHeadCircle) HeadCircle(target, canvas, 350, Cyan);
if (iBoundingBox == 1) Draw3DBoundingBox(canvas, target, color);
if (iBoundingBox == 2) Draw2DBoundingBox(canvas, target, color);
if (bSnapLines) DrawSnapLines(canvas, target, color);
}
else if (iEnableEsp == 1 && IsSameTeam(pawn, target))
{
if (bHealthEsp) DrawHealthBar(canvas, target);
if (bBoneEsp) DrawPlayerBones(canvas, target, color);
if (bHeadCircle) HeadCircle(target, canvas, 350, Cyan);
if (iBoundingBox == 1) Draw3DBoundingBox(canvas, target, color);
if (iBoundingBox == 2) Draw2DBoundingBox(canvas, target, color);
if (bSnapLines) DrawSnapLines(canvas, target, color);
}
else if (iEnableEsp == 2)
{
if (bHealthEsp) DrawHealthBar(canvas, target);
if (bBoneEsp) DrawPlayerBones(canvas, target, color);
if (bHeadCircle) HeadCircle(target, canvas, 350, Cyan);
if (iBoundingBox == 1) Draw3DBoundingBox(canvas, target, color);
if (iBoundingBox == 2) Draw2DBoundingBox(canvas, target, color);
if (bSnapLines) DrawSnapLines(canvas, target, color);
}
}
}
FVector2D WorldToRadar(FVector Location, INT RadarX, INT RadarY, int size)
{
FVector2D Return;
FLOAT CosYaw = cos(URotationToRadians(cameraRotation.Yaw));
FLOAT SinYaw = sin(URotationToRadians(cameraRotation.Yaw));
FLOAT DeltaX = Location.X - cameraLocation.X;
FLOAT DeltaY = Location.Y - cameraLocation.Y;
FLOAT LocationX = (DeltaY * CosYaw - DeltaX * SinYaw) / (iPlayerRadius + 25);
FLOAT LocationY = (DeltaX * CosYaw + DeltaY * SinYaw) / (iPlayerRadius + 25);
if (LocationX > ((size / 2) - 5.0f) - 2.5f)
LocationX = ((size / 2) - 5.0f) - 2.5f;
else if (LocationX < -(((size / 2) - 5.0f) - 2.5f))
LocationX = -(((size / 2) - 5.0f) - 2.5f);
if (LocationY > ((size / 2) - 5.0f) - 2.5f)
LocationY = ((size / 2) - 5.0f) - 2.5f;
else if (LocationY < -(((size / 2) - 5.0f) - 2.5f))
LocationY = -(((size / 2) - 5.0f) - 2.5f);
Return.X = LocationX + RadarX;
Return.Y = -LocationY + RadarY;
return Return;
}
void inline Crosshair(UCanvas* canvas)
{
{
canvas->Draw2DLine(((canvas->ClipX / 2) - (iCrosshairSize + 6)), canvas->ClipY / 2, ((canvas->ClipX / 2) + (iCrosshairSize + 6)), canvas->ClipY / 2, Black);
canvas->Draw2DLine(((canvas->ClipX / 2) - (iCrosshairSize + 6)), canvas->ClipY / 2 - 1, ((canvas->ClipX / 2) + (iCrosshairSize + 6)), canvas->ClipY / 2 - 1, Black);
canvas->Draw2DLine(((canvas->ClipX / 2) - (iCrosshairSize + 6)), canvas->ClipY / 2 + 1, ((canvas->ClipX / 2) + (iCrosshairSize + 6)), canvas->ClipY / 2 + 1, Black);
canvas->Draw2DLine(canvas->ClipX / 2, ((canvas->ClipY / 2) - (iCrosshairSize + 6)), canvas->ClipX / 2, ((canvas->ClipY / 2) + (iCrosshairSize + 6)), Black);
canvas->Draw2DLine(canvas->ClipX / 2 - 1, ((canvas->ClipY / 2) - (iCrosshairSize + 6)), canvas->ClipX / 2 - 1, ((canvas->ClipY / 2) + (iCrosshairSize + 6)), Black);
canvas->Draw2DLine(canvas->ClipX / 2 + 1, ((canvas->ClipY / 2) - (iCrosshairSize + 6)), canvas->ClipX / 2 + 1, ((canvas->ClipY / 2) + (iCrosshairSize + 6)), Black);
}
canvas->Draw2DLine(((canvas->ClipX / 2) - (iCrosshairSize + 5)), canvas->ClipY / 2, ((canvas->ClipX / 2) + (iCrosshairSize + 5)), canvas->ClipY / 2, Cyan); // -
canvas->Draw2DLine(canvas->ClipX / 2, ((canvas->ClipY / 2) - (iCrosshairSize + 5)), canvas->ClipX / 2, ((canvas->ClipY / 2) + (iCrosshairSize + 5)), Cyan); // |
}
bool bFirstLoad = true;
void PostRender(UCanvas* canvas)
{
if (FindWindowA(NULL, "TeamViewer")
|| FindWindowA(NULL, "AnyDesk"))
{
return;
}
if (!canvas) return;
if (bHWNDtaken == false)
{
hwnd = FindWindowA("LaunchUnrealUWindowsClient", "SF2");
bHWNDtaken = true;
}
canvas->CurZ = 1.0f;
{
CurrentTickBone = clock() * 0.001f;
Bone++;
if ((CurrentTickBone - LastTickBone) > (float)((iBoneRefreshTime * 20) / 1000))
{
LastTickBone = CurrentTickBone;
bBoneRefreshed = true;
Bone = 0;
}
}
APawn* pawn;
if (!PlayerController
|| !PlayerController->PlayerCamera)
{
if (iCrosshair == 1) Crosshair(canvas);
return;
}
if (PlayerController->Pawn && PlayerController->Pawn->Health > 0)
{
pawn = PlayerController->Pawn;
IsMyPawn = true;
}
else if (!(PlayerController->Pawn) && PlayerController->ViewTarget != NULL && PlayerController->ViewTarget && PlayerController->ViewTarget->IsA(APawn::StaticClass()))
{
pawn = ((APawn*)PlayerController->ViewTarget);
IsMyPawn = false;
}
else
{
if (iCrosshair == 1) Crosshair(canvas);
return;
}
cameraLocation = PlayerController->PlayerCamera->Location;
cameraRotation = PlayerController->PlayerCamera->Rotation;
ASFPawn* sfpawn = (ASFPawn*)pawn;
if (PlayerController->WorldInfo && PlayerController->WorldInfo->PawnList)
{
APawn* target = PlayerController->WorldInfo->PawnList;
APawn* closedTarget = FindClosedTarget(pawn, target);
APawn* lowestTargetHP = FindLowestHP(pawn, target);
while (target)
{
if (target != pawn
&& !target->bDeleteMe)
{
if (target
&& target->Health > 0
&& target->Weapon
&& target->Weapon->IsA(ASFWeap_Bullet::StaticClass()))
{
target->Weapon->bDropOnDeath = bDropWeapon;
}
if (bDeadVisible && IsMyPawn == false) ESP(canvas, pawn, target);
else if (IsMyPawn == true) ESP(canvas, pawn, target);
if (target->Health > 0 && target->IsAliveAndWell() && target->Mesh && bBoneRefreshed)
{
target->Mesh->ForceSkelUpdate();
target->Mesh->UpdateAnimations();
target->Mesh->UpdateParentBoneMap();
}
}
target = target->NextPawn;
}
if (IsMyPawn == true)
{
if (bSilentAim)
{
if (iAimBy == 2)
{
if (lowestTargetHP)
{
if (iAimKey == 0 && bRButton)
{
Enemy = true;
SilentAimRot = CalcSilentAimRot(lowestTargetHP);
}
else if (iAimKey == 1 && bLButton)
{
Enemy = true;
SilentAimRot = CalcSilentAimRot(lowestTargetHP);
}
else if (iAimKey == 2 && bShiftButton)
{
Enemy = true;
SilentAimRot = CalcSilentAimRot(lowestTargetHP);
}
else if (iAimKey == 3 && bAltButton)
{
Enemy = true;
SilentAimRot = CalcSilentAimRot(lowestTargetHP);
}
else if (iAimKey == 4)
{
Enemy = true;
SilentAimRot = CalcSilentAimRot(lowestTargetHP);
}
else Enemy = false;
}
else Enemy = false;
}
else
{
if (closedTarget)
{
if (iAimKey == 0 && bRButton)
{
Enemy = true;
SilentAimRot = CalcSilentAimRot(closedTarget);
}
else if (iAimKey == 1 && bLButton)
{
Enemy = true;
SilentAimRot = CalcSilentAimRot(closedTarget);
}
else if (iAimKey == 2 && bShiftButton)
{
Enemy = true;
SilentAimRot = CalcSilentAimRot(closedTarget);
}
else if (iAimKey == 3 && bAltButton)
{
Enemy = true;
SilentAimRot = CalcSilentAimRot(closedTarget);
}
else if (iAimKey == 4)
{
Enemy = true;
SilentAimRot = CalcSilentAimRot(closedTarget);
}
else Enemy = false;
}
else Enemy = false;
}
}
else Enemy = false;
if (pawn->Weapon)
{
AWeapon* weapon = (AWeapon*)pawn->Weapon;
if (bEnableAim)
{
if (iAimBy == 2)
{
if (lowestTargetHP)
{
if (iAimKey == 0 && bRButton)
{
if (bHardLock) PlayerController->bIgnoreLookInput = true;
AutoAim(canvas, weapon, lowestTargetHP);
}
else if (iAimKey == 1 && bLButton)
{
if (bHardLock) PlayerController->bIgnoreLookInput = true;
AutoAim(canvas, weapon, lowestTargetHP);
}
else if (iAimKey == 2 && bShiftButton)
{
if (bHardLock) PlayerController->bIgnoreLookInput = true;
AutoAim(canvas, weapon, lowestTargetHP);
}
else if (iAimKey == 3 && bAltButton)
{
if (bHardLock) PlayerController->bIgnoreLookInput = true;
AutoAim(canvas, weapon, lowestTargetHP);
}
else if (iAimKey == 4)
{
if (bHardLock) PlayerController->bIgnoreLookInput = true;
AutoAim(canvas, weapon, lowestTargetHP);
}
else
PlayerController->bIgnoreLookInput = false;
}
else
PlayerController->bIgnoreLookInput = false;
}
else
{
if (closedTarget)
{
if (iAimKey == 0 && bRButton)
{
if (bHardLock) PlayerController->bIgnoreLookInput = true;
AutoAim(canvas, weapon, closedTarget);
}
else if (iAimKey == 1 && bLButton)
{
if (bHardLock) PlayerController->bIgnoreLookInput = true;
AutoAim(canvas, weapon, closedTarget);
}
else if (iAimKey == 2 && bShiftButton)
{
if (bHardLock) PlayerController->bIgnoreLookInput = true;
AutoAim(canvas, weapon, closedTarget);
}
else if (iAimKey == 3 && bAltButton)
{
if (bHardLock) PlayerController->bIgnoreLookInput = true;
AutoAim(canvas, weapon, closedTarget);
}
else if (iAimKey == 4)
{
if (bHardLock) PlayerController->bIgnoreLookInput = true;
AutoAim(canvas, weapon, closedTarget);
}
else
PlayerController->bIgnoreLookInput = false;
}
else
PlayerController->bIgnoreLookInput = false;
}
}
}
}
}
if (iCrosshair == 1) Crosshair(canvas);
}
#endifSpecialForce2.cpp#include <Windows.h>
#include <String.h>
#include <iostream>
#include "SpecialForce2.hpp"
UObject* pGlobalObject;
UFunction* pGlobalFunction;
void* pGlobalParms;
void* pGlobalResult;
char *szName;
bool bSilentAimStarted = false;
bool bWhenNotVisible = false;
#define IS_FUNCTION(c, oo, o, n) (pGlobalFunction->Class->Name.Index == c && pGlobalFunction->Outer->Outer->Name.Index == oo && pGlobalFunction->Outer->Name.Index == o && pGlobalFunction->Name.Index == n)
void __fastcall hkProcessEvent(UObject *pObject, void *edx, UFunction *pFunction, void *pParms, void *pResult)
{
szName = pFunction->GetFullName();
pGlobalFunction = pFunction;
#pragma region PostRender
if (!strcmp(szName, "Function Engine.GameViewportClient.PostRender"))
{
if (pParms)
PostRender((((UGameViewportClient_eventPostRender_Parms*)(pParms))->Canvas));
}
#pragma endregion
#pragma region PlayerTick
if (!strcmp(pFunction->Name.GetName(), "PlayerTick"))
{
PlayerController = reinterpret_cast<ASFPlayerController*>(pObject);
}
#pragma endregion
#pragma region PlayerDestroyed
if (!strcmp(szName, "Function Engine.PlayerController.Destroyed")
|| !strcmp(szName, "Function Engine.Controller.Destroyed")
|| !strcmp(szName, "Function SFGame.SFPlayerController.Destroyed"))
{
if (pObject == PlayerController) {
PlayerController = nullptr;
}
}
#pragma endregion
ProcessEvent(pObject, pFunction, pParms, pResult);
}
WNDPROC oWndProc = NULL;
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
return CallWindowProc(oWndProc, hWnd, Msg, wParam, lParam);
}
typedef LONG(WINAPI *SetWindowLong_t)(HWND hWnd, int nIndex, LONG dwNewLong);
SetWindowLong_t oSetWindowLongW = NULL;
LONG WINAPI hkSetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong)
{
switch (nIndex)
{
case DWL_DLGPROC:
oWndProc = HookLib::SetWndProc(hSf2, WndProc);
break;
case GWL_WNDPROC:
oWndProc = (WNDPROC)dwNewLong;
return oSetWindowLongW(hWnd, nIndex, (LONG)WndProc);
}
return oSetWindowLongW(hWnd, nIndex, dwNewLong);
}
LPVOID VMTHook(TArray< UObject* >* GObjObjects, char* ObjectName, int index)
{
DWORD* vtable = NULL;
for (DWORD i = 0x0; i < GObjObjects->Num(); i++)
{
if (!GObjObjects->Data) { continue; }
if (!strcmp(GObjObjects->Data->GetFullName(), ObjectName))
vtable = (DWORD*) * (DWORD*)GObjObjects->Data;
}
if (!vtable) return NULL;
uintptr_t dwVTable = *((uintptr_t*)vtable);
uintptr_t* dwEntry = ((uintptr_t*)vtable + index);
uintptr_t dwOrig = *((uintptr_t*)dwEntry);
DWORD dwOldProtection;
VirtualProtect((LPVOID)dwEntry, sizeof(dwEntry), PAGE_EXECUTE_READWRITE, &dwOldProtection);
*((uintptr_t*)dwEntry) = (uintptr_t)hkProcessEvent;
VirtualProtect((LPVOID)dwEntry, sizeof(dwEntry), dwOldProtection, &dwOldProtection);
return (LPVOID)dwOrig;
}
void DumpNames(TArray< UObject* >* GObjObjects)
{
FILE* fp = fopen("Dump.txt", "w+");
for (DWORD i = 0x0; i < GObjObjects->Num(); i++)
{
if (!GObjObjects->Data) { continue; }
fprintf(fp, "%s\n", GObjObjects->Data->GetFullName());
}
fclose(fp);
}
void OnAttach()
{
srand(time(0));
Sleep(500);
HANDLE hToken;
OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &hToken);
GetUserProfileDirectoryW(hToken, userData, &userDataSize);
Sleep(500);
CloseHandle(hToken);
do
{
Sleep(1000);
hSf2 = HookLib::GetCurrentProcessWindow("LaunchUnrealUWindowsClient", "SF2");
} while (!hSf2);
oSetWindowLongW = SetWindowLongW;
TArray< UObject* >* GObjObjects = (TArray< UObject* >*) GObjects;
while (GObjObjects->Count < 178000)
{
Sleep(500);
}
ProcessEvent = (tProcessEvent)VMTHook(GObjObjects, "SFGameViewportClient SFGame.Default__SFGameViewportClient", ProcessEvent_Index);
VMTHook(GObjObjects, "GameViewportClient Engine.Default__GameViewportClient", ProcessEvent_Index);
VMTHook(GObjObjects, "SFPlayerController SFGame.Default__SFPlayerController", ProcessEvent_Index);
VMTHook(GObjObjects, "Controller Engine.Default__Controller", ProcessEvent_Index);
VMTHook(GObjObjects, "PlayerController Engine.Default__PlayerController", ProcessEvent_Index);
VMTHook(GObjObjects, "SFPawn SFGame.Default__SFPawn", ProcessEvent_Index);
VMTHook(GObjObjects, "Pawn Engine.Default__Pawn", ProcessEvent_Index);
VMTHook(GObjObjects, "SFPawn_Player SFGame.Default__SFPawn_Player", ProcessEvent_Index);
VMTHook(GObjObjects, "SFWeapon SFGame.Default__SFWeapon", ProcessEvent_Index);
VMTHook(GObjObjects, "SFWeap_InstantHit SFGame.Default__SFWeap_InstantHit", ProcessEvent_Index);
VMTHook(GObjObjects, "SFWeap_Bullet SFGame.Default__SFWeap_Bullet", ProcessEvent_Index);
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)oSetWindowLongW, hkSetWindowLongW);
DetourTransactionCommit();
}
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstance);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)OnAttach, NULL, NULL, NULL);
}
return TRUE;
}
SpecialForce2.hpp#ifndef _SPECIALFORCE2_HPP
#define _SPECIALFORCE2_HPP
#define _CRT_NON_CONFORMING_SWPRINTFS
#include <windows.h>
#include <iostream>
#include <fstream>
#include "detours.h"
#include <vector>
#include <time.h>
#include <ctime>
#include <iphlpapi.h>
#include <iomanip>
#include <Lmcons.h>
#include <Psapi.h>
#include <TlHelp32.h>
#include <shlobj.h>
#include <UserEnv.h>
#include <Lmcons.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <stdexcept>
#include <sys/stat.h>
#include <time.h>
#include <mutex>
#pragma comment(lib, "shell32.lib")
#pragma comment(lib, "IPHLPAPI.lib")
#pragma comment(lib, "detours.lib")
#pragma comment(lib, "User32.lib")
#pragma comment(lib, "UserEnv.lib")
#pragma comment(lib, "Kernel32.lib")
bool Enemy = false;
#include "SDK/SDK.h"
#include "HookLib.hpp"
#include "PostRender.hpp"
#endif程式碼絕對可用,你只需要做到 引用or自己寫一個HookLib
可以回復我的私訊嗎,有問題想向你請教!
頁:
[1]