📄 directxhook.pas
字号:
setlength(xylist,0);
setlength(xylist2,0);
result:=TIDirect3DDevice8_BeginScene_Original(IDirect3DDevice8_BeginScene.location)(self);
end;
procedure DrawHotkeylist8(const self: IDirect3DDevice8;vp:td3dviewport8);
var position,scale: td3dxvector2;
pdesc: TD3DSurface_Desc;
i: integer;
r: trect;
begin
mysprite._Begin;
if blacktexture.GetLevelDesc(0,pdesc)=0 then
begin
scale.x:=requiredkeylistwidth / pdesc.Width;
scale.y:=requiredkeylistheight / pdesc.Height;
end
else
begin
scale.x:=requiredkeylistwidth;
scale.y:=requiredkeylistheight;
end;
position.x:=vp.Width-requiredkeylistwidth;
position.y:=0;
mysprite.Draw(blacktexture,nil,@scale,nil,0,@position,D3DCOLOR_ARGB(140,255,255,255));
mysprite._End;
//draw the strings in the box
cefont._Begin;
r.Left:=vp.Width-requiredkeylistwidth+1;
r.Top:=0;
r.Bottom:=r.left+16;
r.Right:=vp.Width;
for i:=0 to keylist.Count-1 do
begin
r.Top:=i*16;
r.Bottom:=i*16+(r.left+16);
cefont.DrawTextA(pchar(keylist[i]),length(keylist[i]),r,0,D3DCOLOR_ARGB(240,255,255,255));
end;
cefont._End;
end;
function IDirect3DDevice8_EndScene_Hook(const self:IDirect3DDevice8): HResult; stdcall;
var tm:TD3DMatrix;
vp:Td3dViewport8;
x: idirect3dvertexbuffer8;
s: dword;
t: idirect3dbasetexture8;
bla,bla5: pd3dxvector2;
bla2,bla6,position,scale: td3dxvector2;
bla3: prect;
bla4: trect;
pdesc: TD3DSurface_Desc;
i:integer;
closest: integer;
closestsqr1: single;
closestsqr2: single;
xd,yd: single;
xd2,yd2: integer;
newtick: int64;
tickssincelastdraw: dword;
mssincelastdraw: double;
r: trect;
ts: string;
tempsingle: single;
// xdelta,ydelta: single;
start,stop: integer;
rot,rot2,rot3: td3dxmatrix;
v1,v2,v3: TD3dvector;
begin
s:=gettickcount;
try
imdrawing:=true;
try
dontsetlastvertexshader:=true;
dontsetlastworldmatrix:=true;
dontsetlastprojectionmatrix:=true;
dontsetlastviewmatrix:=true;
self.GetViewport(vp);
mysprite._Begin;
if callibrationmode then
begin
//draw texture string
position.x:=0;
position.y:=0;
mysprite.Draw(texturestringtexture,nil,nil,nil,0,@position,D3DCOLOR_ARGB(127,255,255,255));
if texturepointer>=0 then
begin
texturelistcs.Enter;
lockedtexturelistcs.Enter;
try
position.y:=16;
if texturelist[texturepointer].texturehandle.GetLevelDesc(0,pdesc)=0 then
begin
scale.x:=100 / pdesc.Width;
scale.y:=100 / pdesc.Height;
end
else
begin
scale.x:=1;
scale.y:=1;
end;
mysprite.Draw(texturelist[texturepointer].texturehandle,nil,@scale,nil,0,@position,D3DCOLOR_ARGB(127,255,255,255));
position.y:=116;
if texturelist[texturepointer].locked then
begin
mysprite.Draw(lockedstringtexture,nil,nil,nil,0,@position,D3DCOLOR_ARGB(127,255,255,255));
cefont._Begin;
ts:=format('x=%.1f y=%.1f z=%.1f',[texturelist[texturepointer].xdelta, texturelist[texturepointer].ydelta, texturelist[texturepointer].zdelta]);
r.left:=trunc(position.x)+10;
r.Top:=trunc(position.y)+16;
r.Right:=trunc(position.x)+10+800;
r.Bottom:=trunc(position.y)+16+16;
cefont.DrawTextA(pchar(ts),length(ts),r,0,D3DCOLOR_ARGB(255,0,255,0));
cefont._End;
end
else
begin
mysprite.Draw(unlockedstringtexture,nil,nil,nil,0,@position,D3DCOLOR_ARGB(127,255,255,255));
end;
finally
texturelistcs.Leave;
lockedtexturelistcs.leave;
end;
end;
end;
closest:=0;
closestsqr2:=-1;
if length(xylist)>0 then
closestsqr2:=(abs((vp.Width/2)-(xylist[0].x)))*(abs((vp.height/2)-(xylist[0].y)));
for i:=0 to length(xylist2)-1 do
begin
position.x:=xylist2[i].x-8; //I thought it would be -4....
position.y:=xylist2[i].y-8;
mysprite.Draw(targettexture,nil,nil,nil,0,@position,D3DCOLOR_ARGB(255,255,255,255));
{ ts:=format('(%.3f,%.3f,%.3f)',[xylist2[i].x,xylist2[i].y,xylist2[i].z]);
,
//'Position:('+FloatToStr(xylist2[i].x)+','+FloatToStr(xylist2[i].y)+','+FloatToStr(xylist2[i].z)+')';
cefont._Begin;
r.left:=trunc(position.x)+10;
r.Top:=trunc(position.y);
r.Right:=trunc(position.x)+10+800;
r.Bottom:=trunc(position.y)+16;
cefont.DrawTextA(pchar(ts),length(ts),r,0,D3DCOLOR_ARGB(255,0,255,0));
cefont._End;
}
closestsqr1:=(abs((vp.Width/2)-(xylist2[i].x)))*(abs((vp.height/2)-(xylist2[i].y)));
if closestsqr2>closestsqr1 then
begin
closestsqr2:=closestsqr1;
closest:=i;
end;
end;
if length(xylist)>0 then
begin
//put in xd and yd the distance between the closest object and the screencenter
xd:=xylist[closest].x-(vp.Width/2);
yd:=xylist[closest].y-(vp.height/2);
//-----------------------------------------------------
//extrapolate the speed of the player when there is lag between pressing fire and actually shooting
//Doesn't handle acceleration or decceleration, just if it is using a constant speed (standing still is also a constant speed...)
inc(bbb);
if (bbb mod 4)=0 then //frame 0:get position
begin
oldpos:=xylist[closest]; //store current position
QueryPerformanceCounter(lasttick); //store current time
bbb:=4; //I hate overflows
end;
if (bbb mod 4)=2 then //calculate the new speed(assuming the player is moving with a constant speed)
begin
//frame 2: get new position and new time and use that to calulate the speed
//calculate new speed
QueryPerformanceCounter(newtick);
tickssincelastdraw:=newtick-lasttick;
mssincelastdraw:=tickssincelastdraw*onetick;
xdelta:=xylist[closest].x-oldpos.x;
ydelta:=xylist[closest].y-oldpos.y;
//delta now contains the location differences since 3 frames ago
//delta devided by the time since the oldpos and the newpos is the position change per milisecond
//positionchange per milisecond multiplied by the ammount of milliseconds you want to be in fron
if usefpslag then
begin
fpslag:=mssincelastdraw/2; //there where 2 draws since the start of the measurement
xdelta:=(xdelta/mssincelastdraw)*(lag+lagfrommemory+fpslag);
ydelta:=(ydelta/mssincelastdraw)*(lag+lagfrommemory+fpslag);
end
else
begin
xdelta:=(xdelta/mssincelastdraw)*(lag+lagfrommemory);
ydelta:=(ydelta/mssincelastdraw)*(lag+lagfrommemory);
end;
end;
if zoom=1 then
begin
position.x:=xylist[closest].x-8+xdelta2;
position.y:=xylist[closest].y-8+ydelta2;
mysprite.draw(movementtexture,nil,nil,nil,0,@position,D3DCOLOR_ARGB(255,255,255,255));
end;
if (bbb mod 4)>=2 then //move the mouse, after recalculating the speed or when it's doing nothing
begin
//modify xd and yd with the predicted location (so move the mouse to the predicted location instead of the current location)
xd:=xd+xdelta;
yd:=yd+ydelta;
//--------------------------------------------------------------
if autoaim then
begin
xd2:=0;
yd2:=0;
if abs(xd)>mousespeedx[40] then
begin
//calculate the size of the movement
//(xd-mousespeedx[40]) = pixels needed to be moved (after a 40)
//(mousespeedx[40]-mousespeedx[35] / 5)=pixels moved for every step
xd2:=40+trunc((abs(xd)-mousespeedx[40])/((mousespeedx[40]-mousespeedx[35]) / 5));
if xd<0 then xd2:=-xd2;
end else
begin
//find the closest in the list
i:=20;
start:=1;
stop:=40;
while (i<stop) and not ((mousespeedx[i]<abs(xd)) and (mousespeedx[i+1]>xd)) do
begin
if mousespeedx[i]<abs(xd) then start:=i else stop:=i;
i:=start+(stop-start) div 2;
end;
if (i=1) and (mousespeedx[i]<xd) then i:=0;
if xd<0 then xd2:=-i else xd2:=i;
end;
//y
if abs(yd)>mousespeedy[40] then
begin
//calculate the size of the movement
//(yd-mousespeedy[40]) = pixels needed to be moved (after a 40)
//(mousespeedy[40]-mousespeedy[35] / 5)=pixels moved for every step
yd2:=40+trunc((abs(yd)-mousespeedy[40])/((mousespeedy[40]-mousespeedy[35]) / 5));
if yd<0 then yd2:=-yd2;
end else
begin
//find the closest in the list
i:=20;
start:=1;
stop:=40;
while (i<stop) and not ((mousespeedy[i]<abs(yd)) and (mousespeedy[i+1]>yd)) do
begin
if mousespeedy[i]<abs(yd) then start:=i else stop:=i;
i:=start+(stop-start) div 2;
end;
if (i=1) and (mousespeedy[i]<yd) then i:=0;
if yd<0 then yd2:=-i else yd2:=i;
end;
cefont._Begin;
r.left:=trunc(vp.Width/2)-20;
r.Top:=trunc(vp.Height/2)+100;
r.Right:=r.left+800;
r.Bottom:=r.top+16;
ts:=format('xd=%.2f xd2=%d',[xd,xd2]);
cefont.DrawTextA(pchar(ts),length(ts),r,0,D3DCOLOR_ARGB(255,255,255,255));
cefont._End;
mouse_event(MOUSEEVENTF_MOVE,xd2,yd2,0,0);
if ((bbb mod 4)=2) and autoshoot then
begin
if not shot then
begin
//if s>=(lastshot+intervalbetweenshots) then
begin
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); //fire
shot:=true;
lastshot:=s;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -