⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directx9hook.pas

📁 冒险岛吸怪源码UCE的制作材料 用于冒险岛游戏的外挂
💻 PAS
📖 第 1 页 / 共 5 页
字号:
                //the mouse has been moved and this is a updated scene
                //newpos-oldpos = change
                mousecallibrationhorizontal40point:=position.x-mousecallibrationpreviouspos.x;
                mouse_event(MOUSEEVENTF_MOVE,dword(-40),0,0,0); //move back and wait for next frame
                inc(mousecallibrationmode);
              end;

              23:
              begin
                //mouse should be back at starting pos so:
                //move the mouse up 40 points in the vertical direction
                mousecallibrationpreviouspos.x:=position.x;
                mousecallibrationpreviouspos.y:=position.y;
                mouse_event(MOUSEEVENTF_MOVE	,0,40,0,0); //move back and wait for next frame
                inc(mousecallibrationmode);
              end;

              24:
              begin
                //the mouse has been moved and this is a updated scene
                //newpos-oldpos = change
                mousecallibrationvertical40point:=position.y-mousecallibrationpreviouspos.y;
                mouse_event(MOUSEEVENTF_MOVE	,0,dword(-40),0,0); //move back and wait for next frame

                mousespeedx[1]:=abs(mousecallibrationhorizontal1point);
                mousespeedx[2]:=abs(mousecallibrationhorizontal2point);
                mousespeedx[5]:=abs(mousecallibrationhorizontal5point);
                mousespeedx[10]:=abs(mousecallibrationhorizontal10point);
                mousespeedx[20]:=abs(mousecallibrationhorizontal20point);
                mousespeedx[40]:=abs(mousecallibrationhorizontal40point);
                mousespeedx[3]:=mousespeedx[1]+mousespeedx[2];
                mousespeedx[4]:=mousespeedx[3]+((mousespeedx[5]-mousespeedx[2]) / 3);

                tempsingle:=(mousespeedx[10]-mousespeedx[5])/5;
                for i:=6 to 9 do
                  mousespeedx[i]:=mousespeedx[5]+(i-5)*tempsingle;

                tempsingle:=(mousespeedx[20]-mousespeedx[10])/10;
                for i:=11 to 19 do
                  mousespeedx[i]:=mousespeedx[10]+(i-10)*tempsingle;

                tempsingle:=(mousespeedx[40]-mousespeedx[20])/20;
                for i:=21 to 39 do
                  mousespeedx[i]:=mousespeedx[20]+(i-20)*tempsingle;

                //y
                mousespeedy[1]:=abs(mousecallibrationvertical1point);
                mousespeedy[2]:=abs(mousecallibrationvertical2point);
                mousespeedy[5]:=abs(mousecallibrationvertical5point);
                mousespeedy[10]:=abs(mousecallibrationvertical10point);
                mousespeedy[20]:=abs(mousecallibrationvertical20point);
                mousespeedy[40]:=abs(mousecallibrationvertical40point);
                mousespeedy[3]:=mousespeedy[1]+mousespeedy[2];
                mousespeedy[4]:=mousespeedy[3]+((mousespeedy[5]-mousespeedy[2]) / 3);

                tempsingle:=(mousespeedy[10]-mousespeedy[5])/5;
                for i:=6 to 9 do
                  mousespeedy[i]:=mousespeedy[5]+(i-5)*tempsingle;

                tempsingle:=(mousespeedy[20]-mousespeedy[10])/10;
                for i:=11 to 19 do
                  mousespeedy[i]:=mousespeedy[10]+(i-10)*tempsingle;

                tempsingle:=(mousespeedy[40]-mousespeedy[20])/20;
                for i:=21 to 39 do
                  mousespeedy[i]:=mousespeedy[20]+(i-20)*tempsingle;

                mousecallibrationactive:=false;
                //tell ce the callibration results
                keys.mousecallibrationhorizontal1point:=mousespeedx[1];
                keys.mousecallibrationhorizontal2point:=mousespeedx[2];
                keys.mousecallibrationhorizontal5point:=mousespeedx[5];
                keys.mousecallibrationhorizontal10point:=mousespeedx[10];
                keys.mousecallibrationhorizontal20point:=mousespeedx[20];
                keys.mousecallibrationhorizontal40point:=mousespeedx[40];

                keys.mousecallibrationvertical1point:=mousespeedy[1];
                keys.mousecallibrationvertical2point:=mousespeedy[2];
                keys.mousecallibrationvertical5point:=mousespeedy[5];
                keys.mousecallibrationvertical10point:=mousespeedy[10];
                keys.mousecallibrationvertical20point:=mousespeedy[20];
                keys.mousecallibrationvertical40point:=mousespeedy[40];

                if keys.cewindow<>0 then
                  postmessage(keys.cewindow,wm_user+1,0,0); //the callibration values have been changed
              end;

              25:
              begin

                r.left:=trunc(vp.Width/2)+10;
                r.Top:=trunc(vp.Height/2)-16;
                r.Right:=r.left+800;
                r.Bottom:=r.top+16;
                tempstring:=format('mousespeedx[1]=%.2f',[mousespeedx[1]]);
                cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,0,255,0));

                r.Top:=r.top+16;
                r.Bottom:=r.Bottom+16;
                tempstring:=format('mousespeedx[2]=%.2f',[mousespeedx[2]]);
                cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,0,255,0));

                r.Top:=r.top+16;
                r.Bottom:=r.Bottom+16;
                tempstring:=format('mousespeedx[5]=%.2f',[mousespeedx[5]]);
                cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,0,255,0));

                r.Top:=r.top+16;
                r.Bottom:=r.Bottom+16;
                tempstring:=format('mousespeedx[10]=%.2f',[mousespeedx[10]]);
                cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,0,255,0));

                r.Top:=r.top+16;
                r.Bottom:=r.Bottom+16;
                tempstring:=format('mousespeedx[20]=%.2f',[mousespeedx[20]]);
                cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,0,255,0));

                r.Top:=r.top+16;
                r.Bottom:=r.Bottom+16;
                tempstring:=format('mousespeedx[40]=%.2f',[mousespeedx[40]]);
                cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,0,255,0));


                mousecallibrationactive:=false;
                inc(mousecallibrationmode);
              end;

              else mousecallibrationactive:=false;


            end;
          end;


        end;
        
      finally
        mysprite._End;
      end;

      curtime:=gettickcount;
      if curtime<(autoaimtimer+2000) then
      begin
        r.left:=0;
        r.Top:=20;
        r.Right:=400;
        r.Bottom:=70;

        if autoaim then
          cefont.DrawTextA(nil,'Autoaim enabled',15,r,0,D3DCOLOR_ARGB(255,255,255,255))
        else
          cefont.DrawTextA(nil,'Autoaim disabled',16,r,0,D3DCOLOR_ARGB(255,255,255,255));

      end;

      if curtime<(lagtimer+2000) then
      begin
        r.left:=0;
        r.Top:=20;
        r.Right:=500;
        r.Bottom:=70;
        if usefpslag then
          tempstring:='UserLag='+IntToStr(lag)+' Computedlag='+IntToStr(lagfrommemory)+' FPSlag='+format('%.2f',[fpslag])+' Totallag='+format('%.2f',[lag+lagfrommemory+fpslag])
        else
          tempstring:='UserLag='+IntToStr(lag)+' Computedlag='+IntToStr(lagfrommemory)+'Totallag='+IntToStr(lag+lagfrommemory);

        cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,255,0,0));
      end;


      if showloading then
      begin
        r.left:=0;
        r.Top:=36;
        r.Right:=500;
        r.Bottom:=86;
        tempstring:='Loading aimsettings file '+aimsettings+' (stage:'+IntToStr(LoadPhase)+'/2 pos:'+IntToStr(currentposition)+'/'+inttostr(maxposition);
        cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,255,0,255));
      end
      else if curtime<(loadedtimer+2000) then
      begin
        r.left:=0;
        r.Top:=36;
        r.Right:=400;
        r.Bottom:=86;
        tempstring:='Loaded aimsettings '+aimsettings;
        cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,255,0,255));
      end;

      if showsaving then
      begin
        r.left:=0;
        r.Top:=36;
        r.Right:=400;
        r.Bottom:=86;
        tempstring:='Saving aimsettings file '+aimsettings;
        cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,255,0,255));
      end
      else if curtime<(savedtimer+2000) then
      begin
        r.left:=0;
        r.Top:=36;
        r.Right:=400;
        r.Bottom:=86;
        tempstring:='Saved aimsettings '+aimsettings;
        cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,255,0,255));
      end;

      if curtime<(aimsettingstimer+2000) then
      begin
        r.left:=0;
        r.Top:=200;
        r.Right:=400;
        r.Bottom:=216;
        tempstring:='Current aimsettingfile='+aimsettings;
        cefont.DrawTextA(nil,pchar(tempstring),length(tempstring),r,0,D3DCOLOR_ARGB(255,255,0,0));
      end;

      if showkeylist then DrawHotkeylist9(self,vp);


    finally
      dontsetlastworldmatrix:=false;
      dontsetlastprojectionmatrix:=false;
      dontsetlastviewmatrix:=false;
    end;
    fixhook(self);

    if worldmatrixset then self.SetTransform(D3DTS_WORLD,lastworldmatrix);
    if projectionmatrixset then self.SetTransform(D3DTS_Projection,lastprojectionmatrix);
    if viewmatrixset then self.SetTransform(D3DTS_VIEW,lastviewmatrix);
  except

  end;

  imdrawing:=false;
  result:=TIDirect3DDevice9_EndScene_Original(IDirect3DDevice9_EndScene.location)(self);
end;

function IDirect3DDevice9_SetTransform_Hook(const self: IDirect3DDevice9; State : TD3DTransformStateType; const Matrix : TD3DMatrix) : HResult; stdcall;
var Matrix2,Matrix3,Matrix4: TD3DMatrix;
    i: integer;
    tempf1,tempf2,tempf3,tempf4: single;
begin
  //same math as in directx8 (look it up there...)
  matrix2:=Matrix;

  if (zoom<>1) and (state=D3DTS_PROJECTION) then  //zoom stuff
  begin
    if (Matrix2._23=1) then
    begin
      Matrix3:=Matrix;

      tempf1:=arccot(Matrix2._11)*2; //=fov
      tempf2:=Matrix2._11/Matrix2._00; //=aspect

      //zn (near)
      tempf3:=Matrix2._32;
      tempf3:=tempf3 / Matrix2._22;
      tempf3:=-tempf3; //tempf3= zn

      tempf3:=tempf3;//*0.1;  //increase tempf3 to look through nearby objects

      tempf4:=Matrix2._22;
      tempf4:=tempf4*tempf3;
      tempf4:=-tempf4;
      tempf4:=tempf4/tempf3+1;

      //Matrix2._22:=0.1;//500000/(500000-tempf3);
      //Matrix2._32:=-0.1;//-tempf3*500000/(500000-tempf3);

      Matrix2._11:=cot(tempf1/2/zoom);  //devide this with a higher value to zoom in
      Matrix2._00:=Matrix2._11/tempf2;
    end;
  end;

  result:=TIDirect3DDevice9_SetTransform_original(IDirect3DDevice9_SetTransform.location)(self,State,Matrix2);

  if state=D3DTS_VIEW then
  begin
    if not dontsetlastviewmatrix then
    begin
      lastviewmatrix:=Matrix;
      viewmatrixset:=true;
    end;
  end;

  if state=D3DTS_WORLD then
  begin
    if not dontsetlastworldmatrix then
    begin
      lastworldmatrix:=Matrix;
      worldmatrixset:=true;
    end;
  end;

  if state=D3dts_projection then
  begin
    lastprojectionmatrix2:=Matrix2;
    if not dontsetlastprojectionmatrix then
    begin
      lastprojectionmatrix:=Matrix;
      projectionmatrixset:=true;
    end;
  end;
end;

function IDirect3DDevice9_GetTransform_Hook(const self: IDirect3DDevice9; State : TD3DTransformStateType; out Matrix : TD3DMatrix) : HResult; stdcall;
begin
  result:=D3D_OK;

  if state=D3DTS_VIEW then
  begin
    if not dontsetlastviewmatrix then
    begin
      Matrix:=lastviewmatrix;
      exit;
    end;
  end;

  if state=D3DTS_WORLD then
  begin
    if not dontsetlastworldmatrix then
    begin
      Matrix:=lastworldmatrix;
      exit;
    end;
  end;

  if state=D3dts_projection then
  begin
    if not dontsetlastprojectionmatrix then
    be

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -