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

📄 mainform.~pas

📁 纵横天地(开源) Delphi的功能很多``很值得大家学习
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
 EnableControl(Edit10);
 EnableControl(LabeledEdit24);
 EnableControl(SpeedButton7); 
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
var
WuID:Integer;
begin
    if (Trim(Edit1.Text)='') then
    begin
        CheckBox1.Checked :=False;
        StatusBar1.Panels[0].Text :='提示: 请设置血量。。。';
        exit;
    end;
    if (Trim(LabeledEdit5.Text)='') then
    begin
        CheckBox1.Checked :=False;
        StatusBar1.Panels[0].Text :='提示: 请设置延时。。。';
        exit;
    end;
    
    if Pos('调息',Trim(ComboBox1.Text))=0 then
    begin
        WuID:=GetBeiBaoInfo('物品ID',Trim(ComboBox1.Text));
        if WuID<0 then
        begin
          CheckBox1.Checked :=False;
          StatusBar1.Panels[0].Text :='提示: 你的背包里没有此物品。。。';
          exit;
        end;
        YaoPin1ID:=WuID;
    end;

 EnableControl(Edit1);
 EnableControl(LabeledEdit5);
 EnableControl(LabeledEdit7);
 EnableControl(ComboBox1);  
end;

procedure TForm1.CheckBox2Click(Sender: TObject);
var
WuID:Integer;
begin
    if (Trim(Edit2.Text)='') then
    begin
        CheckBox2.Checked :=False;
        StatusBar1.Panels[0].Text :='提示: 请设置蓝量。。。';
        exit;
    end;
    if (Trim(LabeledEdit6.Text)='') then
    begin
        CheckBox2.Checked :=False;
        StatusBar1.Panels[0].Text :='提示: 请设置延时。。。';
        exit;
    end;
    
    if Pos('调息',Trim(ComboBox2.Text))=0 then
    begin
        WuID:=GetBeiBaoInfo('物品ID',Trim(ComboBox2.Text));
        if WuID<0 then
        begin
          CheckBox1.Checked :=False;
          StatusBar1.Panels[0].Text :='提示: 你的背包里没有此物品。。。';
          exit;
        end;
        YaoPin2ID:=WuID;
    end;

    StatusBar1.Panels[0].Text:='';
 EnableControl(Edit2);
 EnableControl(LabeledEdit6);
 EnableControl(LabeledEdit8);
 EnableControl(ComboBox2);
end;

procedure TForm1.CheckBox3Click(Sender: TObject);
var
WuID:Integer;
begin

    if (Trim(Edit3.Text)='') then
    begin
        CheckBox3.Checked :=False;
        StatusBar1.Panels[0].Text :='提示: 请设置生命值。。。';
        exit;
    end;

    if (Trim(ComboBox3.Text)='') then
    begin
        CheckBox3.Checked :=False;
        StatusBar1.Panels[0].Text :='提示: 请选择要使用的药品。。。';
        exit;
    end;
    
    if Pos('调息',Trim(ComboBox3.Text))=0 then
    begin
        WuID:=GetBeiBaoInfo('物品ID',Trim(ComboBox3.Text));
        if WuID<0 then
        begin
          CheckBox3.Checked :=False;
          StatusBar1.Panels[0].Text :='提示: 你的背包里没有此物品。。。';
          exit;
        end;
        YaoPin3ID:=WuID;
    end;
  StatusBar1.Panels[0].Text:='';
 EnableControl(Edit3);
 EnableControl(LabeledEdit9);
 EnableControl(LabeledEdit10);
 EnableControl(ComboBox3);
end;

procedure TForm1.CheckBox4Click(Sender: TObject);
var
WuID:Integer;
begin
    if (Trim(Edit4.Text)='') then
    begin
        CheckBox4.Checked :=False;
        StatusBar1.Panels[0].Text :='提示: 请设置魔法值。。。';
        exit;
    end;
    if (Trim(ComboBox4.Text)='') then
    begin
        CheckBox4.Checked :=False;
        StatusBar1.Panels[0].Text :='提示: 请选择要使用的药品。。。';
        exit;
    end;
    
    if Pos('调息',Trim(ComboBox4.Text))=0 then
    begin
        WuID:=GetBeiBaoInfo('物品ID',Trim(ComboBox4.Text));
        if WuID<0 then
        begin
          CheckBox4.Checked :=False;
          StatusBar1.Panels[0].Text :='提示: 你的背包里没有此物品。。。';
          exit;
        end;
        YaoPin4ID:=WuID;
    end;
 StatusBar1.Panels[0].Text:='';
 EnableControl(Edit4);
 EnableControl(LabeledEdit11);
 EnableControl(LabeledEdit12);
 EnableControl(ComboBox4);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  HotKeyId:=GlobalAddAtom('LMHOT') - $C000;
  RegisterHotKey(Form1.Handle,HotKeyId,0, VK_Insert);
  FormH:=Form1.Height;
  FormW:=Form1.Width;
  FindZhTime.Interval := 50;
  FindZhTime.Enabled:=false;
end;

procedure TForm1.FindZhTimeTimer(Sender: TObject);    
var
rPos: TPoint;
begin
  if Boolean(GetCursorPos(rPos)) then
      GetMousePosHwndAndClassName(rPos);
end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    FindZhTime.Enabled:=true;
    Image1.Picture:=Image2.Picture;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    FindZhTime.Enabled:=false;
   Image1.Picture:=Image3.Picture;
end;

procedure InitGameProcess;
begin
  GetWindowThreadProcessId(ZhHwnd,ZhPID);
  if ZhPID<>0 then
  begin
     hProcess:=OpenProcess(PROCESS_ALL_ACCESS, False,ZhPID+1); 
     if (ThreadAddr=Nil) and (ParamAddr=NIL) then
     begin
         ThreadAddr:= VirtualAllocEx(hProcess, nil, MemSize, MEM_COMMIT, PAGE_READWRITE);
         ParamAddr:= VirtualAllocEx(hProcess, nil, 20, MEM_COMMIT, PAGE_READWRITE);
         JiNengAddr:= VirtualAllocEx(hProcess, nil, 40, MEM_COMMIT, PAGE_READWRITE);
         StartHook(ZhHwnd,Application.Handle);
     end;
  end;
end;

Function GetPersonInfo:Boolean;
var
RenBase,DengJi:DWORD;
HpAddr,MpAddr:Integer;
ZhiYe:Byte;
ZhuangTai:Byte;
ZhiYeName:string;
RenName:array[0..14]of char;
begin
    if hProcess<>0 then
    begin
        Result:=True;
        ReadProcessMemory(hProcess, Pointer(GameBase), @RenBase, 4, ByteRead);
        ReadProcessMemory(hProcess, Pointer(RenBase+$114), @ZhiYe, 1, ByteRead);
        case ZhiYe of
           1:ZhiYeName:='天星';
           2:ZhiYeName:='遁甲';
           3:ZhiYeName:='祝由';
           4:ZhiYeName:='玄武';
           5:ZhiYeName:='罗汉';
        end;

        ReadProcessMemory(hProcess, Pointer(RenBase+$118), @DengJi, 4, ByteRead);
        ReadProcessMemory(hProcess, Pointer(RenBase+$145), @ZhuangTai,1, ByteRead);
        ReadProcessMemory(hProcess, Pointer(RenBase+$150), @CurXue, 4, ByteRead);
        ReadProcessMemory(hProcess, Pointer(RenBase+$154), @CurLan, 4, ByteRead);

        ReadProcessMemory(hProcess, Pointer(SaveMaxXueAddr), @MaxXueAddr, 4, ByteRead);
        ReadProcessMemory(hProcess, Pointer(MaxXueAddr+$404), @HpAddr, 4, ByteRead);
        ReadProcessMemory(hProcess, Pointer(HpAddr+$420), @MaxXue, 4, ByteRead);
        ReadProcessMemory(hProcess, Pointer(MaxXueAddr+$408), @MpAddr, 4, ByteRead);
        ReadProcessMemory(hProcess, Pointer(MpAddr+$420), @MaxLan, 4, ByteRead);

        ReadProcessMemory(hProcess, Pointer(SaveNpcListAddr), @ConstNpcListAddr, 4, ByteRead);

        ReadProcessMemory(hProcess, Pointer(RenBase+$AC), @RenName, 15, ByteRead);

        ReadProcessMemory(hProcess, Pointer(RenBase+$108), @RenX, 4, ByteRead);
        ReadProcessMemory(hProcess, Pointer(RenBase+$10C), @RenZ, 4, ByteRead);
        ReadProcessMemory(hProcess, Pointer(RenBase+$110), @RenY, 4, ByteRead);

        Form1.Caption :='当前玩家: '+RenName+'['+ZhiYeName+']';
        Form1.LabeledEdit1.Text :=RenName;
        Form1.LabeledEdit2.Text :=InttoStr(DengJi);
        Form1.LabeledEdit3.Text :=InttoStr(CurXue)+'/'+InttoStr(MaxXue);
        Form1.LabeledEdit4.Text :=InttoStr(CurLan)+'/'+InttoStr(MaxLan);
    end;
end;


Function  BuyYaoPinFun:Integer;
var
YaoPinNum:Integer;
BuyNum:Integer;
begin
    Result:=-1;
    if Form1.CheckBox1.Checked then
    begin
        if Pos('调息',Trim(Form1.ComboBox1.Text))=0  then
        begin
           YaoPinNum:=GetBeiBaoInfo('物品数目',Trim(Form1.ComboBox1.Text));
           if YaoPinNum>=0 then
           begin
               BuyNum:=StrtoInt(Form1.LabeledEdit7.Text)- YaoPinNum;
               if BuyNum>0 then
                  Call.Buy(YaoPin1ID,BuyNum);
           end
           else
              Call.Buy(YaoPin1ID,StrtoInt(Form1.LabeledEdit7.Text));
        end;
    end;

    if Form1.CheckBox2.Checked then
    begin
        if Pos('调息',Trim(Form1.ComboBox2.Text))=0  then
        begin
           YaoPinNum:=GetBeiBaoInfo('物品数目',Trim(Form1.ComboBox2.Text));
           if YaoPinNum>=0 then
           begin
               BuyNum:=StrtoInt(Form1.LabeledEdit8.Text)- YaoPinNum;
               if BuyNum>0 then
                  Call.Buy(YaoPin2ID,BuyNum);
           end
           else
              Call.Buy(YaoPin2ID,StrtoInt(Form1.LabeledEdit8.Text));
        end;
    end;
    
    if Form1.CheckBox3.Checked then
    begin
        if Pos('调息',Trim(Form1.ComboBox3.Text))=0  then
        begin
           YaoPinNum:=GetBeiBaoInfo('物品数目',Trim(Form1.ComboBox3.Text));
           if YaoPinNum>=0 then
           begin
               BuyNum:=StrtoInt(Form1.LabeledEdit10.Text)- YaoPinNum;
               if BuyNum>0 then
                  Call.Buy(YaoPin3ID,BuyNum);
           end
           else
              Call.Buy(YaoPin3ID,StrtoInt(Form1.LabeledEdit10.Text));
        end;
    end;

    if Form1.CheckBox4.Checked then
    begin
        if Pos('调息',Trim(Form1.ComboBox4.Text))=0  then
        begin
           YaoPinNum:=GetBeiBaoInfo('物品数目',Trim(Form1.ComboBox4.Text));
           if YaoPinNum>=0 then
           begin
               BuyNum:=StrtoInt(Form1.LabeledEdit11.Text)- YaoPinNum;
               if BuyNum>0 then
                  Call.Buy(YaoPin4ID,BuyNum);
           end
           else
              Call.Buy(YaoPin4ID,StrtoInt(Form1.LabeledEdit11.Text));
        end;
    end;
Result:=BuyFinish;            
end;


Function ConstNpcList(DoType,FindNpcName:string):Boolean;   //此NPC列表不随游戏中的NPC位置改变
var
i:Integer;        
Num,PianYi:Integer;
TempX,TempY,TempZ:single;
ListAddr,NpcListAddr,FirstAddr,EndAddr,CurNpcAddr,FirstNpcAddr:Integer;
NpcName:array[0..14]of char;
TempNpcName:string;
NpcJobName:array[0..14]of char;   //NPC 职业名字
TempNpcJobName:string;
begin
    Result:=False;
    if DoType='刷新' then                   
    begin
        Form1.ComboBox5.Items.Clear;
    end;

    if DoType='测试' then
    begin
        Form1.ListBox5.Clear;
    end;
    
    ListAddr:=ConstNpcListAddr+$418;
    ReadProcessMemory(hProcess, Pointer(ListAddr+$4), @FirstAddr, 4, ByteRead);
    ReadProcessMemory(hProcess, Pointer(ListAddr+$8), @EndAddr, 4, ByteRead);
    Num:=(EndAddr-FirstAddr) div $13C;
    For i:= 0 to Num-1 do
    begin
        FillChar(NpcName,15,0);
        FillChar(NpcJobName,15,0);
        asm
            pushad
              mov eax,i
              imul eax,eax,$13C
              add eax,FirstAddr
              mov CurNpcAddr,eax
            popad
        end;

        ReadProcessMemory(hProcess, Pointer(CurNpcAddr+$14), @NpcJobName, 15, ByteRead);
        TempNpcJobName:=NpcJobName;
        ReadProcessMemory(hProcess, Pointer(CurNpcAddr+$24), @NpcName, 15, ByteRead);
        TempNpcName:=NpcName;

        if DoType='测试' then
        begin
            Form1.ListBox5.Items.Add(TempNpcName+'  职业:'+TempNpcJobName);
            Continue;
        end;

        if DoType='刷新' then
        begin
           if (Pos('仓库',TempNpcJobName)<>0) or (Pos('药店',TempNpcJobName)<>0)
              or (Pos('杂货商',TempNpcJobName)<>0) then
           begin
               Form1.ComboBox5.Items.Add(TempNpcName);
           end;
           Continue;
        end;

        if DoType='回城' then
        begin
            if Pos(FindNpcName, Trim(TempNpcName))<>0 then
            begin
                ReadProcessMemory(hProcess, Pointer(CurNpcAddr+$128), @TempX, 4, ByteRead);
                ReadProcessMemory(hProcess, Pointer(CurNpcAddr+$12C), @TempZ, 4, ByteRead);
                ReadProcessMemory(hProcess, Pointer(CurNpcAddr+$130), @TempY, 4, ByteRead);
                GoCityX :=Round(TempX);GoCityY :=Round(TempY);
                Result:=True;
                Form1.LabeledEdit25.Text :=TempNpcJobName;
                exit;
            end;
            Continue;
        end;
    end;
end;

Function SleepFun(TimeM:Integer;FirstTickCount:Integer):Boolean;
var
NowT:Integer;
begin
  Result:=False;
  NowT:=GetTickCount;
  if (NowT- FirstTickCount>=TimeM*1000) then
  begin
     Result:=True;
  end;
end;


Function DingDianProc:Boolean;
const
{$j+}FirstTime:Integer=0{$j-};
var
DingDianTime:Integer;
begin
    Result:=False;
    DingDianTime:=StrtoInt(Trim(Form1.LabeledEdit14.Text));
    if FirstTime=0 then
       FirstTime:=GetTickCount;
    if SleepFun(DingDianTime,FirstTime) then
    begin
         Result:=True;
        if IsXunLuStop(DingDianX,DingDianY) then
        begin
           FirstTime:=0;
        end;
    end;
end;

Function IsXunLuStop(MuDiX,MuDiY:Integer):Boolean;
var
TempRenX,TempRenY,x,y,JuLi:Integer;
RenBase:Integer;
IsRun:Byte;
begin
     Result:=False;
     TempRenX:=Round(RenX);TempRenY:=Round(RenY);
     x:=TempRenX-MuDiX;y:=TempRenY-MuDiY;
     JuLi:=Trunc(sqrt(x*x+y*y));
     if JuLi<=1 then
     begin
         Result:=True;
     end
     else

⌨️ 快捷键说明

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