• 4620阅读
  • 1回复

千年脱机(delphi源码) [复制链接]

上一主题 下一主题
离线啊冲
 

只看楼主 倒序阅读 使用道具 楼主  发表于: 2013-09-07
— 本帖被 啊冲 从 Delphi 移动到本区(2013-10-28) —
{ $HDR$}
{**********************************************************************}
{ Unit archived using Team Coherence                                   }
{ Team Coherence is Copyright 2002 by Quality Software Components      }
{                                                                      }
{ For further information / comments, visit our WEB site at            }
{ http://www.TeamCoherence.com                                         }
{**********************************************************************}
{}
{ $Log:  23294: mainform.pas
{
{   Rev 1.1    25/10/2004 22:50:26  ANeillans    Version: 9.0.17
{ Verified
}
{
{   Rev 1.0    12/09/2003 22:27:10  ANeillans
{ Initial Checkin
}
{
  Demo Name:  Telnet Client
  Created By: Unknown
          On: 27/10/2002

  Notes:
    Telnet Client Demo.

  Version History:
    None

  Tested:
   Indy 9:
     D5:     Untested
     D6:     Untested
     D7:     25th Oct 2004 by Andy Neillans
}
unit mainform;

interface

uses
  Windows, Messages,  Controls, Forms, Dialogs, ComCtrls, StdCtrls,
  SysUtils, Classes,  gamecode,  ExtCtrls,datamanage,gamepacket,
  jpeg,myfun,  Buttons, Menus, RVStyle, RVScroll, RichView,MapInfo,
  Graphics, inifiles, OBThread,  RzTray, IdTCPServer,
  IdBaseComponent, IdComponent, Grids, ScktComp;//D7ScktComp;


type
  Tmainfrm = class(TForm)
    Timer1: TTimer;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    answer: TTimer;
    Timer2: TTimer;
    crcrun: TTimer;
    Timer3: TTimer;
    GroupBox1: TGroupBox;
    baseskill: TPageControl;
    goodsshow: TTabSheet;
    TabSheet9: TTabSheet;
    TabSheet8: TTabSheet;
    TabSheet10: TTabSheet;
    TabSheet11: TTabSheet;
    TabSheet12: TTabSheet;
    TabSheet13: TTabSheet;
    TabSheet16: TTabSheet;
    GroupBox2: TGroupBox;
    goodsview: TListView;
    baseView: TListView;
    onegestView: TListView;
    twogestView: TListView;
    threegestView: TListView;
    palmwindView: TListView;
    skillView: TListView;
    listView9: TListView;
    basicattribe: TListView;
    PageControl1: TPageControl;
    TabSheet2: TTabSheet;
    ListView2: TListView;
    Image1: TImage;
    Bevel1: TBevel;
    TabSheet3: TTabSheet;
    GroupBox3: TGroupBox;
    yuanqi0: TEdit;
    yuanqi1: TEdit;
    Label4: TLabel;
    neigong0: TEdit;
    neigong1: TEdit;
    Label5: TLabel;
    waigong0: TEdit;
    waigong1: TEdit;
    Label6: TLabel;
    wugong0: TEdit;
    wugong1: TEdit;
    Label7: TLabel;
    life0: TEdit;
    life1: TEdit;
    Label8: TLabel;
    lowerlife0: TEdit;
    lowerlife1: TEdit;
    Label9: TLabel;
    CheckBox1: TCheckBox;
    Edit2: TEdit;
    Label10: TLabel;
    Shape1: TShape;
    TabSheet4: TTabSheet;
    Button2: TButton;
    Memo1: TMemo;
    LabeledEdit1: TLabeledEdit;
    CheckBox4: TCheckBox;
    lblServer: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    CheckBox2: TCheckBox;
    myserver1: TComboBox;
    Edit3: TEdit;
    Edit4: TEdit;
    ComboBox1: TComboBox;
    Label15: TLabel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    savesd: TListBox;
    TabSheet5: TTabSheet;
    Label16: TLabel;
    TabSheet6: TTabSheet;
    RVStyle1: TRVStyle;
    GroupBox5: TGroupBox;
    skilledit5: TEdit;
    skilledit4: TEdit;
    skilledit3: TEdit;
    skilledit1: TEdit;
    skilledit2: TEdit;
    datum1: TEdit;
    datum2: TEdit;
    datum3: TEdit;
    datum4: TEdit;
    datumnum1: TEdit;
    datumnum2: TEdit;
    datumnum3: TEdit;
    datumnum4: TEdit;
    cyclenum: TEdit;
    GroupBox6: TGroupBox;
    CheckBox5: TCheckBox;
    CheckBox6: TCheckBox;
    Label18: TLabel;
    ComboBox3: TComboBox;
    ListBox1: TListBox;
    Edit5: TEdit;
    Button3: TButton;
    facebox1: TComboBox;
    Button4: TButton;
    Edit10: TEdit;
    ComboBox4: TComboBox;
    Edit12: TEdit;
    CheckBox7: TCheckBox;
    Timer4: TTimer;
    GroupBox7: TGroupBox;
    Label19: TLabel;
    CheckBox8: TCheckBox;
    CheckBox9: TCheckBox;
    ComboBox5: TComboBox;
    ListBox2: TListBox;
    Edit14: TEdit;
    Button6: TButton;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    N6: TMenuItem;
    PopupMenu2: TPopupMenu;
    N7: TMenuItem;
    N8: TMenuItem;
    N9: TMenuItem;
    N10: TMenuItem;
    N11: TMenuItem;
    N12: TMenuItem;
    N21: TMenuItem;
    N31: TMenuItem;
    N41: TMenuItem;
    N13: TMenuItem;
    PageControl2: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet7: TTabSheet;
    RichView1: TRichView;
    MainMenu1: TMainMenu;
    Edit1: TEdit;
    CheckBox10: TCheckBox;
    StatusBar1: TStatusBar;
    GroupBox4: TGroupBox;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    usegest1: TEdit;
    usegest2: TEdit;
    usegest3: TEdit;
    CheckBox3: TCheckBox;
    Edit6: TEdit;
    CheckBox11: TCheckBox;
    Edit13: TEdit;
    Button1: TButton;
    Button5: TButton;
    RichView2: TRichView;
    PopupMenu3: TPopupMenu;
    N15: TMenuItem;
    goodsget: TComboBox;
    ComboBox7: TComboBox;
    CheckBox15: TCheckBox;
    N16: TMenuItem;
    TabSheet14: TTabSheet;
    RichView3: TRichView;
    TabSheet15: TTabSheet;
    RichView4: TRichView;
    datum5: TEdit;
    ComboBox8: TComboBox;
    Edit11: TEdit;
    CheckBox16: TCheckBox;
    N51: TMenuItem;
    N17: TMenuItem;
    Label17: TLabel;
    Panel2: TPanel;
    tradelist: TListBox;
    sellername: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit7: TEdit;
    Panel1: TPanel;
    Edit15: TEdit;
    CheckBox12: TCheckBox;
    ComboBox6: TComboBox;
    CheckBox14: TCheckBox;
    TabSheet17: TTabSheet;
    Panel3: TPanel;
    ListView1: TListView;
    Label20: TLabel;
    ComboBox9: TComboBox;
    LabeledEdit2: TLabeledEdit;
    LabeledEdit3: TLabeledEdit;
    Button7: TButton;
    Button8: TButton;
    CheckBox17: TCheckBox;
    Edit16: TEdit;
    CheckBox18: TCheckBox;
    Panel4: TPanel;
    Edit17: TEdit;
    CheckBox19: TCheckBox;
    OBThread1: TOBThread;
    OBThread2: TOBThread;
    Bevel2: TBevel;
    CheckBox13: TCheckBox;
    others: TCheckBox;
    zhitiao: TCheckBox;
    menpai: TCheckBox;
    nahan: TCheckBox;
    gonggao: TCheckBox;
    Panel5: TPanel;
    ComboBox2: TComboBox;
    Label3: TLabel;
    RzTrayIcon1: TRzTrayIcon;
    IdTCPServer: TIdTCPServer;
    Edit18: TEdit;
    CheckBox20: TCheckBox;
    CheckBox21: TCheckBox;
    Button9: TButton;
    OBThread3: TOBThread;
    ClientSocket1: TClientSocket;
    OBThread4: TOBThread;
    fblist: TListBox;
    CheckBox22: TCheckBox;
    OBThread5: TOBThread;
    CheckBox23: TCheckBox;
    gooddrug: TLabeledEdit;
    N19: TMenuItem;
    Edit19: TEdit;
    CheckBox24: TCheckBox;
    ComboBox10: TComboBox;
    N14: TMenuItem;
    N18: TMenuItem;
    N20: TMenuItem;

    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure crcrunTimer(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure Timer3Timer(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure basicattribeMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure goodsviewClick(Sender: TObject);
    procedure onegestViewClick(Sender: TObject);
    procedure baseViewClick(Sender: TObject);
    procedure twogestViewClick(Sender: TObject);
    procedure palmwindViewClick(Sender: TObject);
    procedure threegestViewClick(Sender: TObject);
    procedure goodsviewDblClick(Sender: TObject);
    procedure onegestViewDblClick(Sender: TObject);
    procedure baseViewDblClick(Sender: TObject);
    procedure twogestViewDblClick(Sender: TObject);
    procedure palmwindViewDblClick(Sender: TObject);
    procedure threegestViewDblClick(Sender: TObject);
    procedure CheckBox4Click(Sender: TObject);
    procedure ListView2Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure ComboBox2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ComboBox2KeyPress(Sender: TObject; var Key: Char);
    procedure Button3Click(Sender: TObject);
    procedure skillViewClick(Sender: TObject);
    procedure CheckBox6Click(Sender: TObject);
    procedure ListBox1DblClick(Sender: TObject);
    procedure ComboBox3Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Timer4Timer(Sender: TObject);
    procedure ListBox2DblClick(Sender: TObject);
    procedure answerTimer(Sender: TObject);
    procedure CheckBox8Click(Sender: TObject);
    procedure CheckBox5Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure N4Click(Sender: TObject);
    procedure N5Click(Sender: TObject);
    procedure N6Click(Sender: TObject);
    procedure N7Click(Sender: TObject);
    procedure N8Click(Sender: TObject);
    procedure N9Click(Sender: TObject);
    procedure N12Click(Sender: TObject);
    procedure N21Click(Sender: TObject);
    procedure N31Click(Sender: TObject);
    procedure N41Click(Sender: TObject);
    procedure N13Click(Sender: TObject);
    
    procedure CheckBox11Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure CheckBox12Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure myserver1Change(Sender: TObject);
    procedure Edit3Change(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure ComboBox4Change(Sender: TObject);
    procedure yuanqi0Change(Sender: TObject);
    procedure yuanqi1Change(Sender: TObject);
    procedure neigong0Change(Sender: TObject);
    procedure neigong1Change(Sender: TObject);
    procedure waigong0Change(Sender: TObject);
    procedure waigong1Change(Sender: TObject);
    procedure wugong0Change(Sender: TObject);
    procedure wugong1Change(Sender: TObject);
    procedure life0Change(Sender: TObject);
    procedure life1Change(Sender: TObject);
    procedure lowerlife0Change(Sender: TObject);
    procedure lowerlife1Change(Sender: TObject);
    procedure usegest1Change(Sender: TObject);
    procedure usegest2Change(Sender: TObject);
    procedure usegest3Change(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure ListView2DblClick(Sender: TObject);
    procedure CheckBox15Click(Sender: TObject);
    procedure N16Click(Sender: TObject);
    procedure CheckBox7Click(Sender: TObject);
    procedure CheckBox16Click(Sender: TObject);
    procedure N17Click(Sender: TObject);
    procedure N51Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure CheckBox17Click(Sender: TObject);
    procedure OBThread1Execute(Sender: TObject; params: Pointer);
    procedure OBThread2Execute(Sender: TObject; params: Pointer);
    procedure RzTrayIcon1LButtonDblClick(Sender: TObject);
    procedure IdTCPServerConnect(AThread: TIdPeerThread);
    procedure IdTCPServerDisconnect(AThread: TIdPeerThread);
    procedure IdTCPServerExecute(AThread: TIdPeerThread);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure CheckBox20Click(Sender: TObject);
    procedure CheckBox21Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    
    procedure OBThread3Execute(Sender: TObject; params: Pointer);
    procedure CheckBox18Click(Sender: TObject);
    procedure ClientSocket1Connect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
    procedure ClientSocket1Disconnect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;
      ErrorEvent: TErrorEvent; var ErrorCode: Integer);
    procedure OBThread4Execute(Sender: TObject; params: Pointer);
    procedure OBThread5Execute(Sender: TObject; params: Pointer);
    procedure gooddrugChange(Sender: TObject);
    procedure N19Click(Sender: TObject);
private
    FirstFlag:Boolean;
    INIPath:String;
     function ReadmainfrmIni():boolean;   //读取配置信息
     procedure WriteIniStr(FileName:String;section:string;Ident:string;StringValue:string);//写系统信息
     procedure WriteIniinteger(FileName:String;section:string;Ident:string;Value:integer);//写系统信息
    { Private declarations }
  public
    { Public declarations }
  end;

function seize:string;
function gameconnect:string;

var
     mainfrm : Tmainfrm;
  answerstop : bool;
    answerok : bool;
  clientwork : integer;
        str1 : string;
      saynum : integer;
    filepath : string;
    mapx,mapy: integer;
   renwushuju: string;
    clientack: string; //发给客户端的数据1
   clientack1: string; //发给客户端的数据2
   serveraddr: tstringlist;
       testi : integer;
   clientexe : string;
  ackmonster : bool;
clientconnect: bool;
clienttoserver:bool;
           pt: TIdPeerThread; //发给客户端的连接
          MI : TMapInfor;      //地图信息
      runeat : bool;   //吃药还是坐心法补
   //        pt:TIdPeerThread; //连接服务器得连接
    //武功检测的2行
    geststr1,geststr2,geststr3:integer;
    gestset1,gestset2,gestset3,i:integer;
implementation


{$R *.DFM}
//读取配置文件
function Tmainfrm.ReadmainfrmIni():boolean;
var ti:TiniFile;
begin
  ti:=TIniFile.Create(INIPath+'backup.ini');
  myserver1.ItemIndex:=ti.ReadInteger('setting','server',0);//服务器设定
  edit3.Text:=ti.ReadString('setting','accounts',''); //帐号设定
  combobox1.ItemIndex:=ti.ReadInteger('setting','part',0);//角色选择
  combobox4.ItemIndex:=ti.ReadInteger('setting','edition',0);//版本选择

  yuanqi0.Text:=ti.ReadString('eating','yuanqi','');
  yuanqi1.Text:=ti.ReadString('eating','yuanqi1','');

  neigong0.Text:=ti.ReadString('eating','neigong','');
  neigong1.Text:=ti.ReadString('eating','neigong1','');

  waigong0.Text:=ti.ReadString('eating','waigong','');
  waigong1.Text:=ti.ReadString('eating','waigong1','');

  wugong0.Text:=ti.ReadString('eating','wugong','');
  wugong1.Text:=ti.ReadString('eating','wugong1','');

  life0.Text:=ti.ReadString('eating','life','');
  life1.Text:=ti.ReadString('eating','life1','');

  lowerlife0.Text:=ti.ReadString('eating','lowerlife','');
  lowerlife1.Text:=ti.ReadString('eating','lowerlife1','');

  edit2.Text:=ti.ReadString('eating','timer','');

  gooddrug.Text:=ti.ReadString('eating','gooddrug','');//大药的读取设定

  usegest1.Text:=ti.ReadString('gest','kongfu','');
  usegest2.Text:=ti.ReadString('gest','recovery','');
  usegest3.Text:=ti.ReadString('gest','wind','');

  clientexe:=ti.ReadString('exe','client','');

end;

procedure Tmainfrm.WriteIniStr(FileName:String;Section:string;Ident:string;StringValue:string);
var ti:TiniFile;
begin
  ti:=TIniFile.Create(FileName);
  ti.writestring(section,Ident,StringValue);
  ti.Free;
end;

procedure Tmainfrm.WriteIniinteger(FileName:String;Section:string;Ident:string;Value:integer);
var ti:TiniFile;
begin
  ti:=TIniFile.Create(FileName);
  ti.WriteInteger(section,Ident,Value);
  ti.Free;
end;

function sendfb(fbstr:string):string;
begin
if mainfrm.clientsocket1.Socket.Connected then
try
    mainfrm.clientsocket1.Socket.SendText(fbstr);
  except
end;
end;

//发送帐号密码
function lianjie:string;
begin
     sendfb(sendname(mainfrm.edit3.text,mainfrm.edit4.text));
end;

function discover(goodsstr:string):string;      //清除显示showgoods list 里面得
var i:integer;
begin
            for i:=0 to mainfrm.ListView2.Items.Count-1 do
       begin
          if pos(goodsstr,mainfrm.ListView2.Items.Item.SubItems.text )>0 then
             begin
             mainfrm.ListView2.Items.Item.Delete;
             exit;
             end;
        end;
end;




function doanything:string;
var      i,j:integer;
       px,py:real;
zhitiaohufu:string;
          ts:TStringList;
    saylimit:string;
  sfgetgoods:integer;
     hthread:thandle;
    threadid:dword;
        self:TObject;
begin
case numbertest of
  2: begin
        if clientconnect=true then
          begin
             lianjie;
             mainfrm.Timer1.Enabled:=true;
             clientconnect:=false;
          end
          else
         if pos('此密码不适用',queren1)>0 then
          begin
            mainfrm.OBThread3.Execute(self);
          end;
         if pos('未储值使用者无法进行游戏。',queren1)>0 then
          begin
            mainfrm.OBThread3.Execute(self);
          end;
         if pos('已解除连线',queren1)=1 then
             begin
               mainfrm.OBThread3.Execute(self);
             end;
         if pos('【TIMEOUT】请再试一次',queren1)=1 then
            begin
              mainfrm.RichView1.Addnl('['+TimeToStr(now)+'] '+queren1,2,0);
              mainfrm.RichView1.Format;
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
             end
     else
             begin
             mainfrm.RichView1.AddNL('['+TimeToStr(now)+'] '+queren1,2,0);
             mainfrm.RichView1.Format;
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
             end;
      end;

   3: begin                   //返回的人物
      mainfrm.RichView1.AddNL('['+TimeToStr(now)+'] '+renwu,1,0);
      mainfrm.RichView1.Format;
      ts := TStringList.Create ;
      ts.clear;
      ts.Delimiter:= ',' ;
      ts.DelimitedText:=renwu;
      mainfrm.basicattribe.Items.Item[0].caption:='呢称';
      mainfrm.basicattribe.Items.Item[0].SubItems.clear;
      mainfrm.basicattribe.Items.Item[0].SubItems.add(copy(ts.Strings[strtoint(mainfrm.ComboBox1.text)-1],0,pos(':',ts.Strings[strtoint(mainfrm.ComboBox1.text)-1])-1));
      ts.Clear;
      application.Title:=mainfrm.basicattribe.Items.Item[0].SubItems[0];
      mainfrm.RzTrayIcon1.Hint:=application.Title;
      mainfrm.CheckBox3.Enabled:=true;
      sleep(1000);
      sendfb(xuanrenwu(renwu,mainfrm.ComboBox1.Text));
      if mainfrm.checkbox5.Checked=true then
      hthread:=CreateThread(nil,0,@seize,nil,0,ThreadID);
      end;
      
  4: begin
       i:=0;
       saylimit:=copy(goods1,1,1);
       if saylimit='[' then i:=1;
       if saylimit='<' then i:=2;
       if saylimit='{' then i:=3;
       case i of
        1:if mainfrm.nahan.Checked=false then
             begin
               mainfrm.RichView1.AddNL('['+TimeToStr(now)+'] '+goods1,1,0);
               mainfrm.RichView1.Format;
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
             end;
        2:if mainfrm.menpai.Checked=false then
             begin
               mainfrm.RichView3.AddNL('['+TimeToStr(now)+'] '+goods1,2,0);
               mainfrm.RichView3.Format;
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview3.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
             end;
        3:if mainfrm.menpai.Checked=false then
             begin
               mainfrm.RichView1.AddNL('['+TimeToStr(now)+'] '+goods1,2,0);
               mainfrm.RichView1.Format;
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
             end;
          else
        begin
         if mainfrm.others.Checked=false then
            begin
               mainfrm.RichView1.AddNL('['+TimeToStr(now)+'] '+goods1,3,0);
               mainfrm.RichView1.Format;
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
            end;
        end;
        end;
      end;

    5: begin                              //三功 活力等
          mainfrm.basicattribe.Items.Item[1].Caption:='年龄';
          mainfrm.basicattribe.Items.Item[1].SubItems.clear;
          mainfrm.basicattribe.Items.Item[1].SubItems.add(agenow);
          mainfrm.basicattribe.Items.Item[5].Caption:='元气';
          mainfrm.basicattribe.Items.Item[5].SubItems.clear;
          mainfrm.basicattribe.Items.Item[5].SubItems.add(yuanqi);
          mainfrm.basicattribe.Items.Item[6].Caption:='内功';
          mainfrm.basicattribe.Items.Item[6].SubItems.clear;
          mainfrm.basicattribe.Items.Item[6].SubItems.add(neigong);
          mainfrm.basicattribe.Items.Item[7].Caption:='外功';
          mainfrm.basicattribe.Items.Item[7].SubItems.clear;
          mainfrm.basicattribe.Items.Item[7].SubItems.add(waigong);
          mainfrm.basicattribe.Items.Item[8].Caption:='武功';
          mainfrm.basicattribe.Items.Item[8].SubItems.clear;
          mainfrm.basicattribe.Items.Item[8].SubItems.add(wugong);
          mainfrm.basicattribe.Items.Item[9].Caption:='活力';
          mainfrm.basicattribe.Items.Item[9].SubItems.clear;
          mainfrm.basicattribe.Items.Item[9].SubItems.add(life);
     end;

6:  begin    //物品栏显示
      if mainfrm.goodsview.Items.Count-1 <goods42 then
         mainfrm.goodsview.Items.Add;
         mainfrm.goodsview.items.item[goods42].caption:=goods4;
         mainfrm.goodsview.Items.Item[goods42].SubItems.clear;
         mainfrm.goodsview.Items.Item[goods42].SubItems.Add(goods41);
     end;

7:  begin        //一层武功显示
       if mainfrm.onegestView.Items.Count-1<gongfu1 then
          mainfrm.onegestView.Items.Add;
         mainfrm.onegestview.items.item[gongfu1].caption:=gongfu;
         if gongfulevel='0' then gongfulevel:='';
         mainfrm.onegestview.Items.Item[gongfu1].SubItems.clear;
         mainfrm.onegestview.Items.Item[gongfu1].SubItems.Add(gongfulevel);
      end;

     //人物装备
  8:  begin
         mainfrm.listview9.items.item[equipnum].caption:=equipdata;
      end;

  9: begin           //地图信息
       mainfrm.statusbar1.Panels[4].Text:=mapdata;
       mainfrm.ListView2.Clear;
       ExtractFilePath(filepath);
       mainfrm.statusbar1.Panels[2].Text:=makex;
       mainfrm.statusbar1.Panels[3].Text:=makey;
    if fileexists(filepath+'jpg/'+ copy(mapdata,0,pos('.',mapdata)-1)+'.jpg') then
       begin
       //读取显示地图jpeg文件
       mainfrm.Image1.Picture.LoadFromFile(filepath+'jpg/'+ copy(mapdata,0,pos('.',mapdata)-1)+'.jpg');
       mainfrm.Image1.Visible:=true;
       end;
      //读取地图消息
    if MI.LoadMap (filepath+'map/'+mapdata) = False then
         begin
           mainfrm.RichView1.AddNL('['+TimeToStr(now)+'] '+'加载地图文件失败!!!',3,0);
           mainfrm.RichView1.Format;
           end
       else
        begin
        mapx:=MI.GetMapWidth;
        mapy:=MI.GetMapHeight;
        px:=strtoint(makex)/mapx * mainfrm.image1.Width;
        py:=strtoint(makey)/mapy * mainfrm.image1.Height;
        mainfrm.Shape1.Left:=Trunc(px)+mainfrm.Image1.Left;
        mainfrm.shape1.top:=Trunc(py);
        mainfrm.Shape1.Visible:=true;
       end;
      //设定吃药类可以点击
      mainfrm.CheckBox1.Enabled:=true;
      mainfrm.checkbox3.Enabled:=true;
      mainfrm.CheckBox18.Enabled:=true;
      end;

10: begin       //出现NPC 或MONSTER
        mainfrm.ListView2.Items.Add;
        if (mainfrm.combobox4.itemindex=0) or(mainfrm.combobox4.itemindex=2)or (mainfrm.ComboBox4.ItemIndex=3) then
        mainfrm.ListView2.Items.Item[mainfrm.ListView2.Items.Count-1].Caption:=monster
        else
        mainfrm.ListView2.Items.Item[mainfrm.ListView2.Items.Count-1].Caption:=monsterTW;
        mainfrm.ListView2.Items.Item[mainfrm.ListView2.Items.Count-1].SubItems.clear;
        mainfrm.ListView2.Items.Item[mainfrm.ListView2.Items.Count-1].SubItems.add('');
        mainfrm.ListView2.Items.Item[mainfrm.ListView2.Items.Count-1].SubItems.add(monster1);
        for i:=0 to mainfrm.ListBox2.Count-1 do
          begin
            if mainfrm.ComboBox4.ItemIndex<>1 then
            begin
            if monster=mainfrm.ListBox2.Items.Strings then
               mainfrm.ComboBox5.Items.Add(monster1);
            end;
            if mainfrm.ComboBox4.ItemIndex=1 then
            begin
            if monstertw=mainfrm.ListBox2.Items.Strings then
               mainfrm.ComboBox5.Items.Add(monster1);
            end;

          end;
     end;

11: begin              //从showgoods list里面删除死了得NPC
       discover(npcdie1);
       for i:=0 to mainfrm.ComboBox5.Items.Count-1 do
         begin
           if mainfrm.ComboBox5.Items.Strings=npcdie1 then
              mainfrm.ComboBox5.Items.Delete(i);
         end;
     end;

//聊天类
12: if  mainfrm.others.Checked=false then
         begin
              mainfrm.RichView4.AddNL('['+TimeToStr(now)+'] '+goods2,4,0); // mainfrm.RichEdit1.Lines.Add('['+TimeToStr(now)+'] '+goods2);
              mainfrm.RichView4.Format;
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview4.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
            //  SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
         end;

//战斗移动的坐标
{ 15: begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(selfx);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(selfy);
        px:=(selfx/mapx) * mainfrm.image1.Width;
        py:=(selfy/mapy) * mainfrm.image1.Height;
        mainfrm.Shape1.Left:=Trunc(px)+mainfrm.Image1.Left;
        mainfrm.shape1.top:=Trunc(py);

     end;  }

     //人物遇到障碍返回的坐标?
16: begin
     mainfrm.StatusBar1.Panels[2].Text:=inttostr(selfx);
     mainfrm.StatusBar1.Panels[3].Text:=inttostr(selfy);
     end;

22: begin
       if (mainfrm.CheckBox2.Checked=true)and(ackmonster=true) then   //判断条件 武功设定好了就自动反击
          sendfb(attackmonster(npcattack));
     end;

23: begin
        mainfrm.basicattribe.Items.Item[2].Caption:='浩然';
        mainfrm.basicattribe.Items.Item[2].SubItems.clear;
        mainfrm.basicattribe.Items.Item[2].SubItems.add(inttostr(haoran));
     if mainfrm.basicattribe.Items.Item[10].Caption='' then
        mainfrm.basicattribe.Items.Item[10].Caption:='技能值';
        mainfrm.basicattribe.Items.item[10].SubItems.clear;
        mainfrm.basicattribe.Items.Item[10].SubItems.add(inttostr(jinengzhi));
     end;

//怪物的血值显示
27: begin
       for i:=0 to mainfrm.ListView2.Items.Count-1 do
       begin
         if pos(monstername,mainfrm.ListView2.Items.Item.SubItems.Text)>0 then
         mainfrm.ListView2.Items.Item.SubItems.Strings[0]:= monsterlife1;
       end;
     end;

28: begin                                          //地图出现某物品
       mainfrm.ListView2.Items.Add;
       mainfrm.ListView2.Items[mainfrm.ListView2.Items.Count-1].Caption:=goods3;
       mainfrm.ListView2.Items[mainfrm.ListView2.Items.Count-1].SubItems.clear;
       mainfrm.ListView2.Items[mainfrm.ListView2.Items.Count-1].SubItems.add(goods31x+':'+goods31y);
       mainfrm.ListView2.Items[mainfrm.ListView2.Items.Count-1].SubItems.add(goods31);
       ts := TStringList.Create ;
       ts.Clear;
       ts.DelimitedText:=goods3;
      // mainfrm.Memo1.Lines.Add(goodsset);   测试掉落物品的代码比如是门石 跳点 还是物品
    if (mainfrm.CheckBox5.Checked=true)and ((goodsset='0102')or (goodsset='0802')) then //and(abs(strtoint(goods31x)-strtoint(makex))<3)and(abs(strtoint(goods31y)-strtoint(makey))<3) then
        begin
        sfgetgoods:=1;
        for j:=0 to ts.Count-1 do
        begin
        for i:=0 to mainfrm.ListBox1.Items.Count-1 do
         begin
          if mainfrm.checkbox6.Checked=true then
              begin
               if copy(ts.Strings[j],1,length(mainfrm.ListBox1.Items.Strings))=mainfrm.ListBox1.Items.Strings then
                  begin
                  sfgetgoods:=2;
                  end;
              end;

          if mainfrm.checkbox6.Checked=false then
              begin
               if copy(ts.Strings[j],1,length(mainfrm.ListBox1.Items.Strings))=mainfrm.ListBox1.Items.Strings then
                  begin  mainfrm.goodsget.Items.Add(goods31); sendfb(clickmonster(goods31)); end;
              end;
         end;
          if (sfgetgoods=1)and (mainfrm.CheckBox6.Checked=true) then begin mainfrm.goodsget.Items.Add(goods31);sendfb(clickmonster(goods31));end;
         end;
        end;
        ts.Destroy;
//这里加个参数试看
     end;

30: begin                                 //物品消失 从showgoods list里面删除
       discover(disgoods1);
       for i:=0 to mainfrm.goodsget.Items.Count-1 do
       begin
         if mainfrm.goodsget.Items.Strings=disgoods1 then
            begin mainfrm.goodsget.Items.Delete(i);exit; end;
       end;
     end;

32: begin  mainfrm.statusbar1.Panels[1].Text:=usegongfu1; end;        //使用得武功

34: begin         //基本武功类
       if mainfrm.baseView.Items.Count-1<basicskillnum then
          mainfrm.baseView.Items.Add;
         mainfrm.baseview.items.item[basicskillnum].caption:=basic1;
         if basiclevel='0' then basiclevel:='';
         mainfrm.baseview.Items.Item[basicskillnum].SubItems.clear;
         mainfrm.baseview.Items.Item[basicskillnum].SubItems.Add(basiclevel);
    end;

47: begin
     mainfrm.listview2.items.add;
     mainfrm.ListView2.Items[mainfrm.ListView2.Items.Count-1].Caption:=balkname;
     mainfrm.listview2.Items[mainfrm.listview2.Items.Count-1].caption:=balkname;  //障碍显示 由于障碍显示问题暂定名字为此
     mainfrm.listview2.Items[mainfrm.listview2.Items.Count-1].SubItems.Add(balksite);    //设定活力段为空
     mainfrm.listview2.Items[mainfrm.listview2.Items.Count-1].SubItems.Add(balknum); //设定代码段值
    //将障碍也加入显示
        for i:=0 to mainfrm.ListBox2.Count-1 do
          begin
//            if mainfrm.ComboBox4.ItemIndex<>1 then
//            begin
            if balkname=mainfrm.ListBox2.Items.Strings then
               mainfrm.ComboBox5.Items.Add(balknum);
//           end;
{            if mainfrm.ComboBox4.ItemIndex=1 then
            begin
            if monstertw=mainfrm.ListBox2.Items.Strings then
               mainfrm.ComboBox5.Items.Add(monster1);
            end;
                }
          end;
     end;

48: discover(balkdis1);                    //清楚障碍得数据

//公告栏
50: begin
     mainfrm.RichView1.AddNL('['+TimeToStr(now)+'] '+'公告部分',2,0);
     mainfrm.RichView1.Format;
     sleep(300);
     sendfb('(BENJNNNNNNN\N>^wNEVNSzuNyhBKP`bFty=TXPUrSANNNVWNNN>tsKwNU?XwNNNN)');
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
//     mainfrm.speedbutton3.visible:=true;
     mainfrm.CheckBox21.Visible:=true;
     end;

  //祝福类公告
54: begin
       if mainfrm.gonggao.Checked=false then
        begin
          mainfrm.RichView1.AddNL('['+TimeToStr(now)+'] '+happly1,2,0);
          mainfrm.RichView1.Format;
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
//          SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
        end;
     end;

61: begin                                            //2层武功
       if mainfrm.twogestView.Items.Count-1<twogestnum then
         mainfrm.twogestView.Items.Add;
         mainfrm.twogestview.items.item[twogestnum].caption:=twogestskill;
         if twogestlevel='0' then twogestlevel:='';
         mainfrm.twogestview.Items.Item[twogestnum].SubItems.clear;
         mainfrm.twogestview.Items.Item[twogestnum].SubItems.Add(twogestlevel);
     end;

     //人物镜子
62: begin
     mainfrm.basicattribe.items.item[3].caption:='镜界';
     mainfrm.basicattribe.items.item[3].subitems.clear;   //先清除原来得镜子值
     mainfrm.basicattribe.items.item[3].subitems.add(gestglassname); //添加镜子值
     end;

//交易商传来的消息
67: begin
      ts := TStringList.Create ;
      mainfrm.tradelist.Items.Clear;
      ts.Delimiter:= ',' ;
      ts.DelimitedText:=trademenustr;
      for i:=0 to ts.Count-1 do
      begin
       mainfrm.tradelist.Items.Add(copy(ts.Strings,0,pos(':',ts.Strings)-1));
      end;
     end;

//技能类别名字
68: begin
       mainfrm.basicattribe.Items.Item[10].Caption:=makeskillstr;
     end;

70: begin                                           //技能物品
       if mainfrm.skillview.Items.Count-1 <techgoodsnum then
         mainfrm.skillView.Items.Add;
         mainfrm.skillview.items.item[techgoodsnum].caption:=techgoodsname;
         if techgoodslevel='0' then techgoodslevel:='';
         mainfrm.skillview.Items.Item[techgoodsnum].SubItems.clear;
         mainfrm.skillview.Items.Item[techgoodsnum].SubItems.Add(techgoodslevel);
       case techgoodsnum of
        0 : mainfrm.skilledit1.Text:=techgoodsname+':'+techgoodslevel;
        1 : mainfrm.skilledit2.Text:=techgoodsname+':'+techgoodslevel;
        2 : mainfrm.skilledit3.Text:=techgoodsname+':'+techgoodslevel;
        3 : mainfrm.skilledit4.Text:=techgoodsname+':'+techgoodslevel;
        4 : mainfrm.skilledit5.Text:=techgoodsname+':'+techgoodslevel;
       end;
     end;

76: begin                                           //掌风
       if mainfrm.palmwindView.Items.Count-1 <palmwindnum then
         mainfrm.palmwindView.Items.Add;
         mainfrm.palmwindview.items.item[palmwindnum].caption:=palmwindskill;
         if palmwindlevel='0' then palmwindlevel:='';
         mainfrm.palmwindview.Items.Item[palmwindnum].SubItems.clear;
         mainfrm.palmwindview.Items.Item[palmwindnum].SubItems.Add(palmwindlevel);
     end;

83:if mainfrm.zhitiao.Checked=false then
    begin
       mainfrm.richview2.AddNL('['+TimeToStr(now)+'] '+zhitia,5,0);     //纸条信息
       mainfrm.RichView2.Format;
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview3.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
   if (mainfrm.checkbox10.Checked=true)and(pos('>',zhitia)<>0 ) then
       sendfb(sayanswer('@纸条 '+copy(zhitia,0,pos('>',zhitia)-1)+' '+mainfrm.edit1.Text));
   if mainfrm.CheckBox22.Checked=true then mainfrm.PageControl2.ActivePageIndex:=1;

     end;

     //物品消耗部分
84: if mainfrm.others.Checked=false then
      begin
       mainfrm.RichView1.AddNL('['+TimeToStr(now)+'] '+item1,5,0);
       mainfrm.RichView1.Format;
            if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
      end;

86: begin                                           //三层
      if mainfrm.threegestview.Items.Count-1 <threegestnum then
         mainfrm.threegestview.Items.Add;
         mainfrm.threegestview.items.item[threegestnum].caption:=threegestskill;
         if threegestlevel='0' then threegestlevel:='';
         mainfrm.threegestview.Items.Item[threegestnum].SubItems.clear;
         mainfrm.threegestview.Items.Item[threegestnum].SubItems.Add(threegestlevel);
     end;

  87: begin
      mainfrm.basicattribe.Items.Item[4].Caption:='真气';
      mainfrm.basicattribe.Items.Item[4].SubItems.clear;
      mainfrm.basicattribe.Items.Item[4].SubItems.add(realgasnum);
      end;

  //ip以及端口重新设定
  253: begin
           answerstop :=true;
           answerok:=true;
           mainfrm.RichView1.AddNL('['+TimeToStr(now)+'] '+'连接到帐号游戏服务器',2,0);
           mainfrm.RichView1.Format;
        if mainfrm.ClientSocket1.Active=true then mainfrm.ClientSocket1.Active:=false;
            mainfrm.clientsocket1.Host:=ipresetaddr;
            mainfrm.clientsocket1.Port:=ipresetport;
              try
                mainfrm.clientsocket1.Active:=true;
              except
              end;
        if mainfrm.checkbox13.Checked=true then
               begin
                 SendMessage(mainfrm.richview1.Handle,WM_VSCROLL, SB_PAGEDOWN,0) ;
               end;
          mainfrm.SpeedButton1.Visible:=true;
          mainfrm.SpeedButton2.Visible:=false;
       end;
   end;//对应case
end;

procedure myrecv (buf:pchar; len:integer);
var
  i,onelen ,outlen:integer;
  packet_Header :pchar;
begin
  i      := 0;
  onelen := 0;
  packet_header := buf;
  while i < len do
    begin
      if buf = '(' then
        begin
        onelen := 1;
        packet_header := @buf ;
        end;
      if buf = ')' then
        begin
            numbertest:=0;
            gamepacketrecv(packet_header,onelen);
            doanything;
        end;
      inc (onelen);
      inc (i);
    end;
end;

procedure Tmainfrm.Timer1Timer(Sender: TObject);
var i:integer;px,py:real;eatset1:integer;
begin
if clienttoserver=false then
begin
   sendfb('(luNVNNNNNNNxNTANNNNN@p^jNyWKNNSkPpV\AmYxUuNN)');
  // sendfb('(luNVNNNNNNNxNTANNNNNNNNNNNNNNNNNNNNNNNNNNNNN)');
   px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.Width;
   py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height;
   mainfrm.Shape1.Left:=Trunc(px)+mainfrm.Image1.Left;
   mainfrm.shape1.top:=Trunc(py);
end;
//吃大药设定
if checkbox23.Checked=true then
   begin
    //检测药的位置
     for i:=0 to mainfrm.goodsview.Items.Count-1 do
         begin
           if (mainfrm.lowerlife0.Text<>'') and (mainfrm.lowerlife1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=gooddrug.text then eatset1:=i; end;
         end;
     //发送吃药命令    
     sendfb(leftclickshow1(1,eatset1));
   end;
   //武功检测
if (checkbox3.Checked=true)then
   begin
   for i:=0 to baseview.Items.Count-1 do
   begin
    if pos(usegest1.Text,baseview.Items.Item.Caption)<>0 then begin geststr1:=4;gestset1:=i; end;
    if pos(usegest2.Text,baseview.Items.Item.Caption)<>0 then begin geststr2:=4;gestset2:=i; end;
    if pos(usegest3.Text,baseview.Items.Item.Caption)<>0 then begin geststr3:=4;gestset3:=i; end;
   end;
   //一层武功
   for i:=0 to onegestview.Items.Count-1 do
   begin
    if pos(usegest1.Text,onegestview.Items.Item.Caption)<>0 then begin geststr1:=5;gestset1:=i; end;
    if pos(usegest2.Text,onegestview.Items.Item.Caption)<>0 then begin geststr2:=5;gestset2:=i; end;
    if pos(usegest3.Text,onegestview.Items.Item.Caption)<>0 then begin geststr3:=5;gestset3:=i; end;
   end;
    //二层武功
   for i:=0 to twogestview.Items.Count-1 do
   begin
    if pos(usegest1.Text,twogestview.Items.Item.Caption)<>0 then begin geststr1:=15;gestset1:=i; end;
    if pos(usegest2.Text,twogestview.Items.Item.Caption)<>0 then begin geststr2:=15;gestset2:=i; end;
    if pos(usegest3.Text,twogestview.Items.Item.Caption)<>0 then begin geststr3:=15;gestset3:=i; end;
   end;
    //掌风
   for i:=0 to palmwindview.Items.Count-1 do
   begin
    if pos(usegest1.Text,palmwindview.Items.Item.Caption)<>0 then begin geststr1:=24;gestset1:=i; end;
    if pos(usegest3.Text,palmwindview.Items.Item.Caption)<>0 then begin geststr2:=24;gestset2:=i; end;
    if pos(usegest3.Text,palmwindview.Items.Item.Caption)<>0 then begin geststr3:=24;gestset3:=i; end;
   end;
    //三层
   for i:=0 to threegestview.Items.Count-1 do
   begin
    if pos(usegest1.Text,threegestview.Items.Item.Caption)<>0 then begin geststr1:=28;gestset1:=i; end;
    if pos(usegest2.Text,threegestview.Items.Item.Caption)<>0 then begin geststr2:=28;gestset2:=i; end;
    if pos(usegest3.Text,threegestview.Items.Item.Caption)<>0 then begin geststr3:=28;gestset3:=i; end;
   end;
     //检测使用的武功
   if  (usegest1.Text<>'')and (pos(usegest1.Text,statusbar1.Panels[1].text)=0) then sendfb(leftclickshow1(geststr1,gestset1));
    sleep(300);
   if  (usegest2.Text<>'')and (pos(usegest2.Text,statusbar1.Panels[1].text)=0) then sendfb(leftclickshow1(geststr2,gestset2));
    sleep(300);
   if  (usegest3.Text<>'')and (pos(usegest3.Text,statusbar1.Panels[1].text)=0) then sendfb(leftclickshow1(geststr3,gestset3));
    end;
end;


procedure Tmainfrm.FormCreate(Sender: TObject);
var i:integer;
begin
//    fblist.Clear;
    MI := TMapInfor.Create;
    ackmonster:=true;

    FirstFlag:=true;
    clientwork:=0;
    answerok:=false;
    richview1.Clear;
    clientconnect:=true;
    richview1.AddNL('欢迎使用千年脱机(qq:497735182)',3,1);
//   richview1.AddNL('http://www.freespaces.com/xunmeng110/jianyi/jianyi.zip',3,1);
    RichView1.Format;
    scaled := true;
    str1:='';
    INIPath:=extractFilePath(ParamStr(0));
    pagecontrol1.ActivePageIndex:=0;
    pagecontrol2.ActivePageIndex:=0;
    baseskill.ActivePageIndex:=0;
    ExtractFilePath(filepath);
    if FileExists(filepath+'item.txt') then
    mainfrm.ComboBox3.Items.LoadFromFile(filepath+'item.txt');
    if FileExists(filepath+'wp.txt') then
    mainfrm.listbox1.Items.LoadFromFile(filepath+'wp.txt');
    if FileExists(filepath+'monster.txt') then
    mainfrm.listbox2.Items.LoadFromFile(filepath+'monster.txt');
    if FileExists(filepath+'addr.txt') then
    begin
    serveraddr := TStringList.Create ;
    serveraddr.loadfromfile(filepath+'addr.txt');
    end;
    for i:=0 to serveraddr.Count-1 do
    begin
    myserver1.items.add(copy(serveraddr.strings,pos(',',serveraddr.strings)+6,length(serveraddr.strings)-(pos(',',serveraddr.strings)+5)));
    end;
    myserver1.ItemIndex:=0;

    if FileExists(filepath+'sheding.txt') then
    mainfrm.savesd.Items.LoadFromFile(filepath+'sheding.txt');
end;



//定时检测连线状况
procedure Tmainfrm.Timer2Timer(Sender: TObject);
var i,listnum:integer;
begin
if mainfrm.CheckBox15.Checked=true then
  begin
    if mainfrm.clientsocket1.Socket.Connected then
     begin
       statusbar1.Panels[0].Text:='在线中..';
       if richview1.LineCount-1>400 then richview1.Clear;
       if richview2.LineCount-1>400 then richview2.Clear;
       if richview3.LineCount-1>400 then richview3.Clear;
       if richview4.LineCount-1>400 then richview4.Clear;
     end
  else
    begin
         speedbutton2.visible:=true;
         speedbutton1.visible:=false;
         answerok :=false;
         statusbar1.Panels[0].Text:='连接中断';
         timer1.Enabled:=false;
         speedButton2Click(self);
         checkbox21.Visible:=false;
        // speedbutton5.Visible:=false;
    end;
  end;

  if mainfrm.CheckBox19.Checked=true then
     begin
       for i:=0 to mainfrm.goodsview.Items.Count-1 do
       begin
       if  pos(mainfrm.Edit17.Text,mainfrm.goodsview.Items.Item.Caption)>0 then
           begin
           listnum:=i;
           //mainfrm.ComboBox2.Text:=inttostr(i);
           break;
           end;
       end;
       for i:=0 to mainfrm.listView9.Items.Count-1 do
         begin
          if pos(mainfrm.Edit17.Text,mainfrm.listView9.Items.Item.Caption)=0 then
             begin sendfb(leftclickshow1(1,listnum));
                   //  mainfrm.ComboBox2.Text:=leftclickshow1(1,listnum);
             end;
         end;

     end;
end;

procedure Tmainfrm.Button6Click(Sender: TObject);    //添加怪物名字
var i:integer;px,py:real;
begin
  if edit14.text<>'' then listbox2.Items.Add(edit14.Text);
  if mainfrm.clientsocket1.Socket.Connected then
   for i:=0 to listview2.Items.Count-1 do
     begin
       if edit14.Text=listview2.Items.Item.Caption then
          combobox5.Items.Add(listview2.Items.Item.SubItems[1]);
     end;
end;

function eatdrug:string;           //吃药设定
var i:integer; eatset1,eatset2,eatset3,eatset4,eatset5,eatset6:integer;
    neigongeat,waigongeat,wugongeat:bool;
    neigongnum1,neigongnum2,waigongnum1,waigongnum2,wugongnum1,wugongnum2:integer;
begin
neigongeat:=false;
waigongeat:=false;
wugongeat:=false;
repeat
   begin
    eatset1:=30;eatset2:=30;eatset3:=30;eatset4:=30;eatset5:=30;eatset6:=30;//位置初始化
      //   eatdrugtime.Interval:=strtoint(edit2.Text); //定义时间
if (mainfrm.checkbox1.Checked=true) and (mainfrm.clientsocket1.Socket.Connected) then
       begin
       //先获取物品得位置
         for i:=0 to mainfrm.goodsview.Items.Count-1 do
         begin
           if (mainfrm.lowerlife0.Text<>'') and (mainfrm.lowerlife1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.lowerlife1.text then eatset1:=i; end;
           if (mainfrm.life0.Text<>'') and (mainfrm.life1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.life1.text then eatset2:=i; end;
           if (mainfrm.neigong0.Text<>'') and (mainfrm.neigong1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.neigong1.text then eatset3:=i; end;
           if (mainfrm.waigong0.Text<>'') and (mainfrm.waigong1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.waigong1.text then eatset4:=i; end;
           if (mainfrm.wugong0.Text<>'') and (mainfrm.wugong1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.wugong1.text then eatset5:=i; end;
           if (mainfrm.yuanqi0.Text<>'') and (mainfrm.yuanqi1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.yuanqi1.text then eatset6:=i; end;
         end;
         //判断值 然后吃药

neigongnum1:=strtoint(copy(neigong,0,pos('/',neigong)-1));
neigongnum2:=strtoint(copy(neigong,pos('/',neigong)+1,length(neigong)));
waigongnum1:=strtoint(copy(waigong,0,pos('/',waigong)-1));
waigongnum2:=strtoint(copy(waigong,pos('/',waigong)+1,length(waigong)));
wugongnum1:=strtoint(copy(wugong,0,pos('/',wugong)-1));
wugongnum2:=strtoint(copy(wugong,pos('/',wugong)+1,length(wugong)));

case mainfrm.CheckBox18.Checked of
false :  begin
         if (eatset1<>30) and (strtoint(mainfrm.lowerlife0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[9].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[9].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset1)); end;
         if (eatset2<>30) and (strtoint(mainfrm.life0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[9].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[9].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset2)); end;
         if (eatset3<>30) and (strtoint(mainfrm.neigong0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[6].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[6].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset3)); end;
         if (eatset4<>30) and (strtoint(mainfrm.waigong0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[7].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[7].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset4)); end;
         if (eatset5<>30) and (strtoint(mainfrm.wugong0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[8].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[8].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset5)); end;
         if (eatset6<>30) and (strtoint(mainfrm.yuanqi0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[5].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[5].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset6)); end;
         end;
true :  begin

         //判断值 是否补满或空
        if (neigongnum1<>0) and (waigongnum1<>0) and (wugongnum1<>0) then
         begin
         if  ((neigongnum2 div neigongnum1)>=10)  then neigongeat:=true;
         if  (neigongnum2 = neigongnum1)  then neigongeat:=false;
         if  ((waigongnum2 div waigongnum1)>=10)  then waigongeat:=true;
         if  (waigongnum2 = waigongnum1)   then waigongeat:=false;
         if  ((wugongnum2  div wugongnum1 )>=10)  then wugongeat:=true;
         if  (wugongnum2  = wugongnum1 )   then wugongeat:=false;
         end
           else
           begin
         if neigongnum1=0 then neigongeat:=true;
         if waigongnum1=0 then waigongeat:=true;
         if wugongnum1=0 then wugongeat:=true;
           end;
         if (eatset1<>30) and (strtoint(mainfrm.lowerlife0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[9].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[9].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset1)); end;
         if (eatset2<>30) and (strtoint(mainfrm.life0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[9].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[9].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset2)); end;

         if neigongeat=true then sendfb(leftclickshow1(1,eatset3));
         if waigongeat=true then sendfb(leftclickshow1(1,eatset4));
         if wugongeat =true then sendfb(leftclickshow1(1,eatset5));
         if (eatset6<>30) and (strtoint(mainfrm.yuanqi0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[5].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[5].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset6)); end;
        end; //对应true的begin

        end;  //对应case的
       end;
       sleep(strtoint(mainfrm.Edit2.Text));
   end;
  until mainfrm.checkbox1.Checked=false;
end;

//循环点走路找怪
procedure Tmainfrm.crcrunTimer(Sender: TObject);
var i,sitxy:integer;manx,many:integer;
begin
    manx:=abs(strtoint(StatusBar1.Panels[2].Text)-strtoint(listview1.Items.Item[0].SubItems[0]));
    many:=abs(strtoint(StatusBar1.Panels[3].Text)-strtoint(listview1.Items.Item[0].SubItems[1]));
if (manx<3) and (many<3) then
   begin
//设定循环
   for i:=0 to listview1.Items.Count-1 do
     begin
      repeat
        begin
          manx:=abs(strtoint(StatusBar1.Panels[2].Text)-strtoint(listview1.Items.Item[i+1].SubItems[0]));
          many:=abs(strtoint(StatusBar1.Panels[3].Text)-strtoint(listview1.Items.Item[i+1].SubItems[1]));
          //设定走路开步法
          if pos('无名步法',StatusBar1.Panels[1].Text)=0 then    sendfb(leftclickshow1(4,7));
           //设定走路
          sendfb(movexy(strtoint(listview1.Items.Item.Caption),strtoint(StatusBar1.Panels[2].Text),strtoint(StatusBar1.Panels[3].Text)));
//   memo1.lines.Add(inttostr(2));
           //  sleep(200);
case strtoint(listview1.Items.Item.Caption) of
0 : begin
       mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
       end;
1 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
     end;
2 : begin
       mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
     end;
3 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
     end;
4 : begin
       mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
     end;
5 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
     end;
6 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
     end;
7 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
     end;
end;
end;//case的end;
  if clientsocket1.Active=false then exit;
      until (manx<3) and (many<3) ;
  if clientsocket1.Active=false then exit;
     end;
   end;
end;

//吃药开始与停设定
procedure Tmainfrm.CheckBox1Click(Sender: TObject);
var
    hthread:thandle;
    threadid:dword;
begin
   if CheckBox1.checked =true then
   OBThread1.Execute(self);
//   hthread:=CreateThread(nil,0,@eatdrug,nil,0,ThreadID);
end;


//刷屏用
function sayspeaking:string;
begin
repeat
begin
if  (saynum<=mainfrm.memo1.Lines.Count-1)and (mainfrm.clientsocket1.Socket.Connected) then
   begin
   sendfb(sayanswer(mainfrm.memo1.Lines.Strings[saynum]));
   saynum:=saynum+1;
   if saynum>mainfrm.Memo1.Lines.Count-1 then saynum:=0;
   end;
   sleep(strtoint(mainfrm.LabeledEdit1.Text));
end;
until mainfrm.checkbox4.Checked=false;
end;

//原来用来刷屏的
procedure Tmainfrm.Timer3Timer(Sender: TObject);
begin
{ if  checkbox4.Checked=true then
      timer3.Interval:=strtoint(LabeledEdit1.Text);
begin
  if  (saynum<=memo1.Lines.Count-1)and (clientsocket1.Active=true) then
   begin
   sendfb(sayanswer(memo1.Lines.Strings[saynum]));
   saynum:=saynum+1;
   end
   else
   saynum:=0;
end;
if checkbox4.Checked=false then timer3.Enabled:=false;    }
end;


procedure Tmainfrm.Button2Click(Sender: TObject);
begin
    opendialog1.Filter:='文本文件|*.txt';
    if opendialog1.Execute then
    if opendialog1.FileName<>'' then
       memo1.lines.LoadFromFile(opendialog1.FileName);

//   edit3.Text:=clickmenu(edit2.text);
//   edit2.text:=pchar(edit2.text)[0];
  //   edit2.text:=chr(length(pchar(edit2.text)));
//     edit3.Text:=draggoodsnum(strtoint(edit2.text),strtoint(edit4.text),strtoint(edit6.text))  ;
//    idtelnetdemo.Write(edit3.text);
     //   edit2.text:=chartoascii(pchar(edit2.text),length(pchar(edit2.text)));
end;

function runxy:string;stdcall;
var i,px,py:real;
begin
mainfrm.button4.Enabled:=false;
// mainfrm.Timer1.Enabled:=false;
i:=0 ;
while (i<=strtoint(mainfrm.edit10.text))and (mainfrm.clientsocket1.Socket.Connected) do
begin
sendfb(movexy(strtoint(mainfrm.facebox1.Text),strtoint(mainfrm.statusbar1.Panels[2].Text),strtoint(mainfrm.statusbar1.Panels[3].Text)));
case strtoint(mainfrm.facebox1.Text) of
0 : begin
       mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
       end;
1 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
2 : begin
       mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
3 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
4 : begin
       mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
5 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
6 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
7 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
end;
i:=i+1;
end;
mainfrm.button4.enabled:=true;
// mainfrm.Timer1.Enabled:=true;
end;

procedure Tmainfrm.Button4Click(Sender: TObject);

var
    hthread:thandle;
    threadid:dword;

begin
//  hthread:=CreateThread(nil,0,@runxy,nil,0,ThreadID);
  //判断次数 设定循环 拖放物品 点制造
//  timer4.Interval:=strtoint(edit13.text);
  testi:=0 ;
  if pos('无名步法',mainfrm.StatusBar1.Panels[1].Text)=0 then
     begin sendfb(leftclickshow1(4,7)); end;
     timer4.Enabled:=true;

end;



procedure Tmainfrm.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var mousex,mousey:integer;
    px,py:real ;
begin
// if cs1.Socket.Connected then
//  begin
    MouseX := x;
    MouseY := y;
    px:=MouseX / mainfrm.image1.width *mapx ;
    py:=MouseY /mainfrm.image1.Height *mapy;
    Label16.Caption := '地图坐标:'+inttostr(trunc(px))+':'+inttostr(trunc(py));//IntToStr (x) + ',' + IntToStr (y);
//   end;
end;


procedure Tmainfrm.basicattribeMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if basicattribe.Selected<>nil then
    if button =mbleft then
    begin
      if basicattribe.ItemIndex=3 then
           sendfb('(UuNuNENNNNNFN>AANNNNNNNNNNNNNNNN)');
    end;
    if button =mbright then
    begin
       if basicattribe.ItemIndex=3 then
           sendfb('(UuNbNNNNNNNFN>AANNNNNNN>NNNNNNNN)');
    end;      

end;

procedure Tmainfrm.goodsviewClick(Sender: TObject);
begin
  if goodsview.Selected<>nil then
       sendfb(leftclickshow2(1,goodsview.ItemIndex));
end;

procedure Tmainfrm.onegestViewClick(Sender: TObject);
begin
  if onegestView.Selected<>nil then
       sendfb(leftclickshow2(5,onegestView.ItemIndex));

end;

procedure Tmainfrm.baseViewClick(Sender: TObject);
begin
   if baseView.Selected<>nil then
       sendfb(leftclickshow2(4,baseView.ItemIndex));

end;

procedure Tmainfrm.twogestViewClick(Sender: TObject);
begin
   if twogestView.Selected<>nil then
       sendfb(leftclickshow2(15,twogestView.ItemIndex));

end;

procedure Tmainfrm.palmwindViewClick(Sender: TObject);
begin
   if palmwindView.Selected<>nil then
       sendfb(leftclickshow2(24,palmwindView.ItemIndex));

end;

procedure Tmainfrm.threegestViewClick(Sender: TObject);
begin
   if threegestView.Selected<>nil then
       sendfb(leftclickshow2(28,threegestView.ItemIndex));

end;

procedure Tmainfrm.goodsviewDblClick(Sender: TObject);
begin
   if goodsview.Selected<>nil then
       sendfb(leftclickshow1(1,goodsview.ItemIndex));

end;

procedure Tmainfrm.onegestViewDblClick(Sender: TObject);
begin
   if onegestView.Selected<>nil then
       sendfb(leftclickshow1(5,onegestView.ItemIndex));

end;

procedure Tmainfrm.baseViewDblClick(Sender: TObject);
begin
     if baseView.Selected<>nil then
       sendfb(leftclickshow1(4,baseView.ItemIndex));

end;

procedure Tmainfrm.twogestViewDblClick(Sender: TObject);
begin
   if twogestView.Selected<>nil then
       sendfb(leftclickshow1(15,twogestView.ItemIndex));

end;

procedure Tmainfrm.palmwindViewDblClick(Sender: TObject);
begin
   if palmwindView.Selected<>nil then
       sendfb(leftclickshow1(24,palmwindView.ItemIndex));

end;

procedure Tmainfrm.threegestViewDblClick(Sender: TObject);
begin
   if threegestView.Selected<>nil then
       sendfb(leftclickshow1(28,threegestView.ItemIndex));

end;

procedure Tmainfrm.CheckBox4Click(Sender: TObject);
var
    hthread:thandle;
    threadid:dword;
begin
   saynum:=0;
   if CheckBox4.checked =true then
   hthread:=CreateThread(nil,0,@sayspeaking,nil,0,ThreadID);
end;


procedure Tmainfrm.ListView2Click(Sender: TObject);
begin
    if listview2.Selected<>nil then
       sendfb(clickmonster(listview2.Items.Item[listview2.itemindex].SubItems.Strings[1]));

end;
//扔东西设定
procedure Tmainfrm.N16Click(Sender: TObject);
var flapnum:integer;
begin
  sendfb(flap(strtoint(statusbar1.Panels[2].Text)+2,strtoint(statusbar1.Panels[3].Text)+2,goodsview.ItemIndex));
  sleep(300);
  flapnum:=strtoint(inputbox('扔东西','请输入数量','1'));
  sendfb(flapgoodsnum(goodsview.ItemIndex,flapnum));
end;

procedure Tmainfrm.SpeedButton1Click(Sender: TObject);
begin
      goodsget.Items.Clear;
  speedbutton2.visible :=True;
  speedbutton1.visible :=True;
        timer1.Enabled :=false;
       mainfrm.clientsocket1.Socket.Close;
end;

procedure Tmainfrm.ComboBox2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if key=38 then
   begin
   ComboBox2.Text:='@纸条 ';
   ComboBox2.SelStart:=7;
   end;
end;

procedure Tmainfrm.ComboBox2KeyPress(Sender: TObject; var Key: Char);
var i,saynum:integer;
begin
  saynum:=2;
if (mainfrm.clientsocket1.Socket.Connected) and (combobox2.Text<>'') and (key=#13) then
   begin
     sendfb(sayanswer(combobox2.Text));
   for i:=0 to combobox2.Items.Count-1 do
   begin
     if combobox2.Items.Strings=combobox2.Text then
        saynum:=1;
   end;
    if saynum=2 then combobox2.items.Add(combobox2.Text);
    combobox2.Text:='';
   // combobox2.Focused;
   end;
end;

//做技能部分
function ceshi:string;stdcall;
var i,j,z,cishu,datumsit1,datumsit2,datumsit3,datumsit4,datumsit5:integer;
    sellercode:string; sellplace:integer;  goodswhere:integer;
    flapnum:integer;//被抛弃物品的位置设定
begin
   sendfb('(SANFNNNNNNNSNTu>NNNN)');   //点击出技能框
   //判断技能物品的位置
   datumsit1:=0;
   datumsit2:=0;
   datumsit3:=0;
   datumsit4:=0;

for i:=0 to mainfrm.goodsview.Items.Count-1 do
  begin
  if mainfrm.datum1.Text=mainfrm.goodsview.Items.Item.Caption then  datumsit1:=i;
  if mainfrm.datum2.Text=mainfrm.goodsview.Items.Item.Caption then  datumsit2:=i;
  if mainfrm.datum3.Text=mainfrm.goodsview.Items.Item.Caption then  datumsit3:=i;
  if mainfrm.datum4.Text=mainfrm.goodsview.Items.Item.Caption then  datumsit4:=i;
  if mainfrm.datum5.Text=mainfrm.goodsview.Items.Item.Caption then  datumsit5:=i;
  end;
cishu:=strtoint(mainfrm.cyclenum.Text)-1 ;
//技能运转
for i:=0 to cishu  do
  begin
   if (mainfrm.clientsocket1.Socket.Connected)and (mainfrm.checkbox11.checked=true)  then
   begin
     //先做清空设定
      if (mainfrm.skilledit1.Text<>'') then begin sendfb(dragset(19,1,0,0));
      sleep(strtoint(mainfrm.edit18.text));          end;
      if (mainfrm.skilledit2.Text<>'') then begin sendfb(dragset(19,1,1,0));
      sleep(strtoint(mainfrm.edit18.text));          end;
      if (mainfrm.skilledit3.Text<>'') then begin sendfb(dragset(19,1,2,0));
      sleep(strtoint(mainfrm.edit18.text));          end;
      if (mainfrm.skilledit4.Text<>'') then begin sendfb(dragset(19,1,3,0));
      sleep(strtoint(mainfrm.edit18.text));          end;
      if (mainfrm.skilledit5.Text<>'') then begin sendfb(dragset(19,1,4,0));
      sleep(strtoint(mainfrm.edit18.text));          end;

//放入物品到技能框
  //   一次放入4样物品
      sendfb(makeskilldrag(datumsit1,datumsit2,datumsit3,datumsit4,
         strtoint(mainfrm.datumnum1.text),strtoint(mainfrm.datumnum2.text),
         strtoint(mainfrm.datumnum3.text),strtoint(mainfrm.datumnum4.text)));
     {//第一格
      sleep(strtoint(mainfrm.edit18.text));
      if mainfrm.datum1.Text<>'' then       begin
      sendfb(dragset(1,19,datumsit1,0)); //19指技能框
      sleep(strtoint(mainfrm.edit18.text));
      sendfb(draggoodsnum1(datumsit1,0,strtoint(mainfrm.datumnum1.text)));
      end;
      //第2格
      if mainfrm.datum2.Text<>'' then
      begin
      sleep(strtoint(mainfrm.edit18.text));
      sendfb(dragset(1,19,datumsit2,1)); //19指技能框
      sleep(strtoint(mainfrm.edit18.text));
      sendfb(draggoodsnum1(datumsit2,0,strtoint(mainfrm.datumnum2.text)));
      end;
      //第三格
      if mainfrm.datum3.Text<>'' then
      begin
      sleep(strtoint(mainfrm.edit18.text));
      sendfb(dragset(1,19,datumsit3,2)); //19指技能框
      sleep(strtoint(mainfrm.edit18.text));
      sendfb(draggoodsnum1(datumsit3,0,strtoint(mainfrm.datumnum3.text)));
//      sleep(500);
      end;
      //第4格
      if mainfrm.datum4.Text<>'' then
      begin
      sleep(strtoint(mainfrm.edit18.text));
      sendfb(dragset(1,19,datumsit4,3)); //19指技能框
      sleep(strtoint(mainfrm.edit18.text));
      sendfb(draggoodsnum1(datumsit4,0,strtoint(mainfrm.datumnum4.text)));
      end;        }
      //第5格
      if mainfrm.datum5.Text<>'' then
      begin
      sleep(strtoint(mainfrm.edit18.text));
      sendfb(dragset(1,19,datumsit5,4)); //19指技能框
      sleep(strtoint(mainfrm.edit18.text));
      sendfb(draggoodsnum1(datumsit5,0,1));
      end;
     //点确定
      sleep(300);
      sendfb('(SANKNNNNNNNSNTtNNNNN)');  //点此为制造开始
      sleep(strtoint(mainfrm.edit18.text));
      mainfrm.cyclenum.Text:=inttostr(strtoint(mainfrm.cyclenum.Text)-1);
      if mainfrm.skilledit5.Text<>'' then
      sendfb(dragset(19,1,4,0));   //将物品放入物品栏
      sleep(300);
    end;

//技能物品抛弃  
if (mainfrm.CheckBox16.Checked=true)and(mainfrm.clientsocket1.Socket.Connected) then
   begin
   flapnum:=100;
    sleep(strtoint(mainfrm.edit18.text));
     for  z:=0 to mainfrm.goodsview.Items.Count-1 do
       begin
        if pos(mainfrm.edit11.text,mainfrm.goodsview.Items.Item[z].Caption)<>0 then
           flapnum:=z;
       end;
       //抛弃方向
     case mainfrm.combobox8.ItemIndex of
     0:  sendfb(flap(strtoint(mainfrm.statusbar1.Panels[2].Text),strtoint(mainfrm.statusbar1.Panels[3].Text)-2,flapnum));
     1:  sendfb(flap(strtoint(mainfrm.statusbar1.Panels[2].Text)+2,strtoint(mainfrm.statusbar1.Panels[3].Text)-2,flapnum));
     2:  sendfb(flap(strtoint(mainfrm.statusbar1.Panels[2].Text)+2,strtoint(mainfrm.statusbar1.Panels[3].Text),flapnum));
     3:  sendfb(flap(strtoint(mainfrm.statusbar1.Panels[2].Text)+2,strtoint(mainfrm.statusbar1.Panels[3].Text)+2,flapnum));
     4:  sendfb(flap(strtoint(mainfrm.statusbar1.Panels[2].Text),strtoint(mainfrm.statusbar1.Panels[3].Text)+2,flapnum));
     5:  sendfb(flap(strtoint(mainfrm.statusbar1.Panels[2].Text)-2,strtoint(mainfrm.statusbar1.Panels[3].Text)+2,flapnum));
     6:  sendfb(flap(strtoint(mainfrm.statusbar1.Panels[2].Text)-2,strtoint(mainfrm.statusbar1.Panels[3].Text),flapnum));
     7:  sendfb(flap(strtoint(mainfrm.statusbar1.Panels[2].Text)-2,strtoint(mainfrm.statusbar1.Panels[3].Text)-2,flapnum));
      end;//此处对应case
      sleep(strtoint(mainfrm.edit18.text));
      sendfb(flapgoodsnum(flapnum,1));  //发送数量命令
    end;

//卖给NPC
if (mainfrm.CheckBox7.Checked=true)and(mainfrm.clientsocket1.Socket.Connected) then
  begin
    sellplace:=100;
    goodswhere:=100;
    for j:=0 to mainfrm.ListView2.Items.Count-1 do
    begin
      if pos(mainfrm.combobox7.Text,mainfrm.ListView2.Items.item[j].Caption)<>0 then
      begin
        sellercode:=mainfrm.ListView2.Items.item[j].SubItems.Strings[1];
      end;
    end;
   if sellercode<>'' then
     begin
      //发送点击NPC商人的命令
      sendfb(clickmonster(sellercode));
      sleep(strtoint(mainfrm.edit18.text));
      //点击菜单里的buy 就是卖
      sendfb(clicknpcmenu('salebuy'));
      sleep(strtoint(mainfrm.edit18.text));
      //交易菜单里的物品位置
      //寻找物品在物品栏位置
      for j:=0 to mainfrm.goodsview.Items.Count-1 do
      begin
        if pos(mainfrm.edit12.Text,mainfrm.goodsview.Items.Item[j].Caption)<>0 then goodswhere:=j;
//           mainfrm.combobox2.text:=inttostr(goodswhere);
      end;
      //拖放物品

       for j:=0 to mainfrm.tradelist.Items.Count-1 do
      begin
        if pos(mainfrm.edit12.Text,mainfrm.tradelist.Items.Strings[j])<>0 then sellplace:=j;
      end;
    if (goodswhere<>100) then     //(sellplace<mainfrm.tradelist.Items.Count)and
       begin
    //  mainfrm.combobox2.text:=dragset(1,23,0,0);
//   mainfrm.combobox2.text:=dragset(1,23,goodswhere,0);
      sendfb(dragset(1,23,goodswhere,0));
  //    sleep(800);
    //  mainfrm.memo1.lines.add(draggoodsnum2(goodswhere,sellplace,1));
//     sendfb(draggoodsnum2(goodswhere,sellplace,1));
      sleep(strtoint(mainfrm.edit18.text));
       end;
     //发送确认标志
      sendfb('(BENoNNNNNNN\N>^yNNVNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN)');
      sleep(strtoint(mainfrm.edit18.text));
    end;
   end;
end;
  mainfrm.checkbox11.Checked:=false;
end;

//卖东西给npc 比如卖肉给老板娘
function tradenpc:string;
var i,j,cishu:integer;
    sellercode:string;
    sellplace:integer;
    goodswhere:integer;
begin
j:=0;
cishu:=strtoint(mainfrm.edit7.Text);
while (j<cishu) and (mainfrm.CheckBox20.Checked=true)and(mainfrm.clientsocket1.Socket.Connected) do   //满足循环次数不为0 和 卖得点击
  begin
    sellplace:=100;
    goodswhere:=100;
    for i:=0 to mainfrm.ListView2.Items.Count-1 do
    begin
      if pos(mainfrm.sellername.Text,mainfrm.ListView2.Items.item.Caption)<>0 then
      begin
        sellercode:=mainfrm.ListView2.Items.item.SubItems.Strings[1];
      end;
    end;

   if sellercode<>'' then
     begin
      //发送点击NPC商人的命令
      sendfb(clickmonster(sellercode));
      sleep(600);
      //点击菜单里的buy 就是卖
      sendfb(clickmenu('buy'));
      sleep(600);
      //交易菜单里的物品位置
      for i:=0 to mainfrm.tradelist.Items.Count-1 do
      begin
        if mainfrm.tradelist.Items.Strings=mainfrm.edit8.Text then sellplace:=i;
      end;
      //寻找物品在物品栏位置
      for i:=0 to mainfrm.goodsview.Items.Count-1 do
      begin
        if mainfrm.goodsview.Items.Item.Caption=mainfrm.edit8.Text then goodswhere:=i;
      end;
      //拖放物品
    if (sellplace<mainfrm.tradelist.Items.Count)and (goodswhere<>100) then
    begin
      sendfb(draggoodsnum(goodswhere,sellplace,strtoint(mainfrm.edit9.text)));
      sleep(600);
    end;
     //发送确认标志
      sendfb('(BENSNANNNNN\N>^bNNVNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN)');
      sleep(1000);
     end;
     j:=j+1;
     mainfrm.Edit7.Text:=inttostr(strtoint(mainfrm.edit7.Text)-1);
   end;

end;

//点卖按钮
procedure Tmainfrm.Button3Click(Sender: TObject);
begin
if edit5.Text<>'' then
  listbox1.Items.Add(edit5.text); //添加名字到物品列表
end;

procedure Tmainfrm.skillViewClick(Sender: TObject);
begin
sendfb(dragset(19,1,skillview.ItemIndex,0));
end;

procedure Tmainfrm.CheckBox6Click(Sender: TObject);
begin
  if checkbox6.Checked=true then label18.Caption:='不拾取列表指定物品';
  if checkbox6.Checked=false then label18.Caption:='拾取里表指定物品';
end;

procedure Tmainfrm.ListBox1DblClick(Sender: TObject);
begin
listbox1.Items.Delete(listbox1.ItemIndex);
end;

procedure Tmainfrm.ComboBox3Click(Sender: TObject);
begin
  listbox1.Items.Add(combobox3.Items.Strings[combobox3.itemindex])
end;

procedure Tmainfrm.FormDestroy(Sender: TObject);
begin

mainfrm.ListBox1.Items.SaveToFile(filepath+'wp.txt');
mainfrm.ListBox2.Items.SaveToFile(filepath+'monster.txt');
end;

procedure Tmainfrm.Timer4Timer(Sender: TObject);
var i,px,py:real;
begin
mainfrm.button4.Enabled:=false;
// mainfrm.Timer1.Enabled:=false;

if (testi<=strtoint(mainfrm.edit10.text))and (mainfrm.clientsocket1.Socket.Connected) then
begin
sendfb(movexy(strtoint(mainfrm.facebox1.Text),strtoint(mainfrm.statusbar1.Panels[2].Text),strtoint(mainfrm.statusbar1.Panels[3].Text)));
case strtoint(mainfrm.facebox1.Text) of
0 : begin
       mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
       end;
1 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
2 : begin
       mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
3 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
4 : begin
       mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
5 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
6 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
7 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
       px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
       py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
       mainfrm.Shape1.Left:=Trunc(px);
       mainfrm.shape1.top:=Trunc(py);
     end;
end;
testi:=testi+1;
end
else
  begin
  timer4.Enabled:=false;
mainfrm.button4.enabled:=true;
end;
// mainfrm.Timer1.Enabled:=true;
end;

procedure Tmainfrm.ListBox2DblClick(Sender: TObject);
var i,j:integer;
begin

   for i:=0 to listview2.Items.Count-1 do
   begin
     if listview2.Items.Item.Caption=listbox2.Items.Strings[listbox2.itemindex] then
       for j:=0 to combobox5.Items.Count-1 do
       begin
        if listview2.Items.Item.SubItems[1]= combobox5.Items.Strings[j] then
           combobox5.Items.Delete(j);
       end;
   end;
   listbox2.Items.Delete(listbox2.ItemIndex);

end;

//远程攻击的实现   加矿区除怪
procedure Tmainfrm.answerTimer(Sender: TObject);
var
  i:integer;killmonster:bool;monstercode:string;
begin
killmonster:=false;
for i:=0 to listview2.Items.Count-1 do
    begin
      if pos(edit19.Text,listview2.Items.Item.Caption)>0 then
         begin
         killmonster:=true;
         monstercode:=listview2.Items.Item.SubItems.Strings[1];
         case combobox10.ItemIndex of
         0:sendfb(sendfb(leftclickshow1(4,5)));
         1:sendfb(sendfb(leftclickshow1(4,15)));
         end;
         end;
    end;
if (mainfrm.clientsocket1.Socket.Connected)and(ackmonster=true)  then
    begin
     if killmonster=false then
      begin
      if combobox5.Items.Count-1>=0 then
      sendfb(attackmonster(combobox5.Items.Strings[random(combobox5.Items.Count-1)]));
      end
      else
      sendfb(attackmonster(monstercode));
    end;

end;

procedure Tmainfrm.CheckBox8Click(Sender: TObject);
begin
  if checkbox8.Checked=true then answer.Enabled:=true
   else answer.Enabled:=false;
end;

procedure Tmainfrm.CheckBox5Click(Sender: TObject);
var
    hthread:thandle;
    threadid:dword;
begin
     if checkbox5.Checked=true then
        hthread:=CreateThread(nil,0,@seize,nil,0,ThreadID);
end;

procedure Tmainfrm.N1Click(Sender: TObject);
begin
yuanqi1.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
end;

procedure Tmainfrm.N2Click(Sender: TObject);
begin
neigong1.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
end;

procedure Tmainfrm.N3Click(Sender: TObject);
begin
waigong1.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
end;

procedure Tmainfrm.N4Click(Sender: TObject);
begin
wugong1.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
end;

procedure Tmainfrm.N5Click(Sender: TObject);
begin
life1.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
end;

procedure Tmainfrm.N6Click(Sender: TObject);
begin
lowerlife1.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
end;

procedure Tmainfrm.N7Click(Sender: TObject);
begin
case mainfrm.PopupMenu2.PopupComponent.Tag of
100 : usegest1.Text:=mainfrm.baseView.Items.Item[mainfrm.baseView.itemindex].Caption;
101 : usegest1.Text:=mainfrm.onegestView.Items.Item[mainfrm.onegestView.itemindex].Caption;
102 : usegest1.Text:=mainfrm.twogestView.Items.Item[mainfrm.twogestView.itemindex].Caption;
103 : usegest1.Text:=mainfrm.palmwindView.Items.Item[mainfrm.palmwindView.itemindex].Caption;
104 : usegest1.Text:=mainfrm.threegestView.Items.Item[mainfrm.threegestView.itemindex].Caption;
end;
end;

procedure Tmainfrm.N8Click(Sender: TObject);
begin
case mainfrm.PopupMenu2.PopupComponent.Tag of
100 : usegest2.Text:=mainfrm.baseView.Items.Item[mainfrm.baseView.itemindex].Caption;
101 : usegest2.Text:=mainfrm.onegestView.Items.Item[mainfrm.onegestView.itemindex].Caption;
102 : usegest2.Text:=mainfrm.twogestView.Items.Item[mainfrm.twogestView.itemindex].Caption;
103 : usegest2.Text:=mainfrm.palmwindView.Items.Item[mainfrm.palmwindView.itemindex].Caption;
104 : usegest2.Text:=mainfrm.threegestView.Items.Item[mainfrm.threegestView.itemindex].Caption;
end;
end;

procedure Tmainfrm.N9Click(Sender: TObject);
begin
case mainfrm.PopupMenu2.PopupComponent.Tag of
100 : usegest3.Text:=mainfrm.baseView.Items.Item[mainfrm.baseView.itemindex].Caption;
101 : usegest3.Text:=mainfrm.onegestView.Items.Item[mainfrm.onegestView.itemindex].Caption;
102 : usegest3.Text:=mainfrm.twogestView.Items.Item[mainfrm.twogestView.itemindex].Caption;
103 : usegest3.Text:=mainfrm.palmwindView.Items.Item[mainfrm.palmwindView.itemindex].Caption;
104 : usegest3.Text:=mainfrm.threegestView.Items.Item[mainfrm.threegestView.itemindex].Caption;
end;
end;

procedure Tmainfrm.N12Click(Sender: TObject);
begin
datum1.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
datumnum1.Text:=inputbox('物品数量','请输入数量','1')
end;

procedure Tmainfrm.N21Click(Sender: TObject);
begin
datum2.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
datumnum2.Text:=inputbox('物品数量','请输入数量','1')
end;

procedure Tmainfrm.N31Click(Sender: TObject);
begin
datum3.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
datumnum3.Text:=inputbox('物品数量','请输入数量','1')
end;

procedure Tmainfrm.N41Click(Sender: TObject);
begin
datum4.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
datumnum4.Text:=inputbox('物品数量','请输入数量','1')
end;

procedure Tmainfrm.N13Click(Sender: TObject);
begin
edit12.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;

end;


procedure Tmainfrm.CheckBox11Click(Sender: TObject);
var
    hthread:thandle;
    threadid:dword;
begin
if checkbox11.checked=true then
    hthread:=CreateThread(nil,0,@ceshi,nil,0,ThreadID);
  //判断次数 设定循环 拖放物品 点制造
end;

procedure Tmainfrm.Button1Click(Sender: TObject);
begin
  sendfb(goodsmima(edit13.text,3));
  edit13.text:='';
end;

procedure Tmainfrm.Button5Click(Sender: TObject);
begin
    sendfb(goodsmima(edit13.text,4));
    edit13.text:='';
end;

function trainrun:string;stdcall;
var i:integer;  px,py:real;neigongnum1,waigongnum1,lifenum1,neigongnum2,waigongnum2,lifenum2:integer;
begin
repeat
//吃药跑路
if mainfrm.checkbox14.Checked=false then
   begin
     if pos('无名步法',mainfrm.StatusBar1.Panels[1].Text)=0 then
     sendfb(leftclickshow1(4,7));
       for i:=0 to strtoint(mainfrm.Edit15.text) do
       begin
         if (mainfrm.clientsocket1.Socket.Connected) then
         sendfb(movexy(2,strtoint(mainfrm.StatusBar1.Panels[2].Text),strtoint(mainfrm.StatusBar1.Panels[3].Text)));
         px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
         py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
         mainfrm.Shape1.Left:=Trunc(px);
         mainfrm.shape1.top:=Trunc(py);
         sleep(800);
         mainfrm.StatusBar1.Panels[2].Text:=inttostr(strtoint(mainfrm.StatusBar1.Panels[2].Text)+1);
       end;
       sleep(600);
if pos('无名步法',mainfrm.StatusBar1.Panels[1].Text)=0 then
     sendfb(leftclickshow1(4,7));
       for i:=0 to strtoint(mainfrm.Edit15.text) do
       begin
         if (mainfrm.clientsocket1.Socket.Connected) then
         sendfb(movexy(6,strtoint(mainfrm.StatusBar1.Panels[2].Text),strtoint(mainfrm.StatusBar1.Panels[3].Text)));
         px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
         py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
         mainfrm.Shape1.Left:=Trunc(px);
         mainfrm.shape1.top:=Trunc(py);
         sleep(800);
         mainfrm.StatusBar1.Panels[2].Text:=inttostr(strtoint(mainfrm.StatusBar1.Panels[2].Text)-1);
       end;
       sleep(600);
     end;

//跑步判断 补心法跑
if mainfrm.CheckBox14.Checked=true then
begin
neigongnum1:=strtoint(copy(neigong,0,pos('/',neigong)-1));
neigongnum2:=strtoint(copy(neigong,pos('/',neigong)+1,length(neigong)));
waigongnum1:=strtoint(copy(waigong,0,pos('/',waigong)-1));
waigongnum2:=strtoint(copy(waigong,pos('/',waigong)+1,length(waigong)));
   lifenum1:=strtoint(copy(life,0,pos('/',life)-1));
   lifenum2:=strtoint(copy(life,pos('/',life)+1,length(life)));
if ((neigongnum2 div neigongnum1)>10) or ((waigongnum2 div waigongnum1)>10) or ((lifenum2 div lifenum1)>10) then runeat:=true;
end;

//判断当前是跑还是打坐 true 是打坐 false 是跑步
  case runeat of
false: begin
if pos('无名步法',mainfrm.StatusBar1.Panels[1].Text)=0 then
     sendfb(leftclickshow1(4,7));
       for i:=0 to strtoint(mainfrm.Edit15.text) do
       begin
         if (mainfrm.clientsocket1.Socket.Connected) then
         sendfb(movexy(2,strtoint(mainfrm.StatusBar1.Panels[2].Text),strtoint(mainfrm.StatusBar1.Panels[3].Text)));
         px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
         py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
         mainfrm.Shape1.Left:=Trunc(px);
         mainfrm.shape1.top:=Trunc(py);
         sleep(800);
         mainfrm.StatusBar1.Panels[2].Text:=inttostr(strtoint(mainfrm.StatusBar1.Panels[2].Text)+1);
       end;
       sleep(600);
if pos('无名步法',mainfrm.StatusBar1.Panels[1].Text)=0 then
     sendfb(leftclickshow1(4,7));
       for i:=0 to strtoint(mainfrm.Edit15.text) do
       begin
         if (mainfrm.clientsocket1.Socket.Connected) then
         sendfb(movexy(6,strtoint(mainfrm.StatusBar1.Panels[2].Text),strtoint(mainfrm.StatusBar1.Panels[3].Text)));
         px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
         py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
         mainfrm.Shape1.Left:=Trunc(px);
         mainfrm.shape1.top:=Trunc(py);
         sleep(800);
         mainfrm.StatusBar1.Panels[2].Text:=inttostr(strtoint(mainfrm.StatusBar1.Panels[2].Text)-1);
       end;
       sleep(600);
     end;
   //心法判断
true:begin
       if pos(mainfrm.ComboBox6.Text,mainfrm.StatusBar1.Panels[1].Text)=0 then
          begin
          if mainfrm.ComboBox6.ItemIndex=0 then   sendfb(leftclickshow1(4,8));
          if mainfrm.ComboBox6.ItemIndex=1 then   sendfb(leftclickshow1(4,18));
          end;
          sleep(3000);
       if ((neigongnum2 div neigongnum1)<=1) and ((waigongnum2 div waigongnum1)<=1) and ((lifenum2 div lifenum1)<=1) then runeat:=false;
      end;
   //心法判断结束
   end;
until mainfrm.checkbox12.checked=false;
end;

//跑步的测试
procedure Tmainfrm.CheckBox12Click(Sender: TObject);
var
    hthread:thandle;
    threadid:dword;
begin
   if CheckBox12.checked =true then
    OBThread2.Execute(self);
//   hthread:=CreateThread(nil,0,@trainrun,nil,0,ThreadID);
end;

procedure Tmainfrm.FormActivate(Sender: TObject);
begin

  if FirstFlag then
  begin
    FirstFlag:=false;
    ReadmainfrmIni();
  end;
    if copy(clientexe,0,pos('.',clientexe)-8)='' then
       begin
          opendialog1.Filter:='千年客户端文件(client.exe)|client.exe';
       if opendialog1.Execute then
          if opendialog1.FileName<>'' then
          begin
          writeinistr(INIPath+'backup.ini','exe','client',opendialog1.Filename);
          clientexe:=opendialog1.FileName;
          end;
          if opendialog1.FileName='' then
            showmessage('你没有选择客户端路径!!!!!!!'+#13+' '+#13+'没选择正确客户端路径程序会出问题'+#13+' '+#13+'请到刷屏页面设定客户端的路径');
       end;

end;

procedure Tmainfrm.myserver1Change(Sender: TObject);
begin
  writeiniinteger(INIPath+'backup.ini','Setting','server',myserver1.itemindex);

end;

procedure Tmainfrm.Edit3Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','Setting','accounts',edit3.text);

end;

procedure Tmainfrm.ComboBox1Change(Sender: TObject);
begin
   writeiniinteger(INIPath+'backup.ini','Setting','part',ComboBox1.itemindex);
end;


procedure Tmainfrm.ComboBox4Change(Sender: TObject);
begin
   writeiniinteger(INIPath+'backup.ini','Setting','edition',combobox4.itemindex);

end;

procedure Tmainfrm.yuanqi0Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','yuanqi',yuanqi0.text);

end;

procedure Tmainfrm.yuanqi1Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','yuanqi1',yuanqi1.text);
end;

procedure Tmainfrm.neigong0Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','neigong',neigong0.text);
end;

procedure Tmainfrm.neigong1Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','neigong1',neigong1.text);
end;

procedure Tmainfrm.waigong0Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','waigong',waigong0.text);
end;

procedure Tmainfrm.waigong1Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','waigong1',waigong1.text);
end;

procedure Tmainfrm.wugong0Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','wugong',wugong0.text);
end;

procedure Tmainfrm.wugong1Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','wugong1',wugong1.text);
end;

procedure Tmainfrm.life0Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','life',life0.text);
end;

procedure Tmainfrm.life1Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','life1',life1.text);
end;

procedure Tmainfrm.lowerlife0Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','lowerlife',lowerlife0.text);
end;

procedure Tmainfrm.lowerlife1Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','lowerlife1',lowerlife1.text);
end;

procedure Tmainfrm.usegest1Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','gest','kongfu',usegest1.text);
end;

procedure Tmainfrm.usegest2Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','gest','recovery',usegest2.text);
end;

procedure Tmainfrm.usegest3Change(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','gest','wind',usegest3.text);
end;

procedure Tmainfrm.Edit2Change(Sender: TObject);
begin
  writeinistr(INIPath+'backup.ini','eating','timer',edit2.text);

end;

//连接按钮
procedure Tmainfrm.SpeedButton2Click(Sender: TObject);
var
  i:integer;
  hthread:thandle;
  threadid:dword;
  serverstr:string;
begin
    clienttoserver:=false;
    clientconnect:=true;//这行用于看是连接成功等
    mainfrm.goodsget.Clear;
    mainfrm.ComboBox5.Clear;
    mainfrm.listview2.Items.Clear;
    mainfrm.basicattribe.Items.clear;
    mainfrm.goodsview.Items.clear;
    mainfrm.onegestView.Items.clear;
    mainfrm.baseView.Items.clear;
    mainfrm.twogestView.Items.clear;
    mainfrm.threegestView.Items.clear;
    mainfrm.palmwindView.Items.clear;
    mainfrm.skillView.Items.clear;
    mainfrm.listView9.Items.clear;
   for i:=0 to 10 do
   begin
     basicattribe.Items.add;
     listview9.Items.Add;
   end;
  speedbutton2.visible:=false;
  speedbutton1.visible:=true;
  serverstr:=serveraddr.strings[myserver1.itemindex];
  clientsocket1.host:=copy(serverstr,0,pos(',',serverstr)-1);
  clientsocket1.Port:=strtoint(copy(serverstr,pos(',',serverstr)+1,4));
  RichView1.AddNL('['+TimeToStr(now)+'] '+'开始连接', 1, 0);
  richview1.Format;
  clientsocket1.Active:=true;
  clientack1:='';

end;

procedure Tmainfrm.ListView2DblClick(Sender: TObject);
begin
   if listview2.Selected<>nil then
      sendfb(attackmonster(listview2.Items.Item[listview2.itemindex].SubItems.Strings[1]));
end;

procedure Tmainfrm.CheckBox15Click(Sender: TObject);
begin
if checkbox15.checked=true then
    mainfrm.timer2.enabled:=true
    else
    mainfrm.timer2.enabled:=false;
end;

//设定技能物品如果卖就停止抛弃
procedure Tmainfrm.CheckBox7Click(Sender: TObject);
begin
  if checkbox7.Checked=true then checkbox16.Checked:=false;
end;

//如果技能物品抛弃那么就取消卖的设定
procedure Tmainfrm.CheckBox16Click(Sender: TObject);
begin
  if checkbox16.Checked=true then checkbox7.Checked:=false;
end;
//设定直接放物品名字到技能抛弃栏
procedure Tmainfrm.N17Click(Sender: TObject);
begin
edit11.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
end;

//成品框物品
procedure Tmainfrm.N51Click(Sender: TObject);
begin
datum5.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;
end;

//删除坐标点
procedure Tmainfrm.Button8Click(Sender: TObject);
begin
  listview1.DeleteSelected ;
end;

//添加坐标点
procedure Tmainfrm.Button7Click(Sender: TObject);
begin
  listview1.Items.Add;
  listview1.Items.Item[listview1.Items.Count-1].Caption:=combobox9.Text;
  listview1.Items.Item[listview1.items.Count-1].SubItems.add(labelededit2.text);
  listview1.Items.Item[listview1.items.Count-1].SubItems.add(labelededit3.text);
end;

//设定循环走路的方法
procedure Tmainfrm.CheckBox17Click(Sender: TObject);
begin
if  checkbox17.Checked=true then
   OBThread5.Execute(self) // crcrun.Enabled:=true
    else
    crcrun.Enabled:=false;
end;

//吃药部分 加补三功功能
procedure Tmainfrm.OBThread1Execute(Sender: TObject; params: Pointer);
var i:integer; eatset1,eatset2,eatset3,eatset4,eatset5,eatset6:integer;
    neigongeat,waigongeat,wugongeat:bool;
    neigongnum1,neigongnum2,waigongnum1,waigongnum2,wugongnum1,wugongnum2:integer;
begin
neigongeat:=false;
waigongeat:=false;
wugongeat:=false;
repeat
   begin
    eatset1:=30;eatset2:=30;eatset3:=30;eatset4:=30;eatset5:=30;eatset6:=30;//位置初始化
      //   eatdrugtime.Interval:=strtoint(edit2.Text); //定义时间
if (mainfrm.checkbox1.Checked=true) then //and (mainfrm.clientsocket1.Socket.Connected) then
                                          //尝试取消连接判断
       begin
       //先获取物品得位置
         for i:=0 to mainfrm.goodsview.Items.Count-1 do
         begin
           if (mainfrm.lowerlife0.Text<>'') and (mainfrm.lowerlife1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.lowerlife1.text then eatset1:=i; end;
           if (mainfrm.life0.Text<>'') and (mainfrm.life1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.life1.text then eatset2:=i; end;
           if (mainfrm.neigong0.Text<>'') and (mainfrm.neigong1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.neigong1.text then eatset3:=i; end;
           if (mainfrm.waigong0.Text<>'') and (mainfrm.waigong1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.waigong1.text then eatset4:=i; end;
           if (mainfrm.wugong0.Text<>'') and (mainfrm.wugong1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.wugong1.text then eatset5:=i; end;
           if (mainfrm.yuanqi0.Text<>'') and (mainfrm.yuanqi1.Text<>'') then
            begin if mainfrm.goodsview.Items.Item.Caption=mainfrm.yuanqi1.text then eatset6:=i; end;
         end;
         //判断值 然后吃药

if wugong<>'' then
begin
neigongnum1:=strtoint(copy(neigong,0,pos('/',neigong)-1));
neigongnum2:=strtoint(copy(neigong,pos('/',neigong)+1,length(neigong)));
waigongnum1:=strtoint(copy(waigong,0,pos('/',waigong)-1));
waigongnum2:=strtoint(copy(waigong,pos('/',waigong)+1,length(waigong)));
wugongnum1:=strtoint(copy(wugong,0,pos('/',wugong)-1));
wugongnum2:=strtoint(copy(wugong,pos('/',wugong)+1,length(wugong)));
end;

case mainfrm.CheckBox18.Checked of
false :  begin
         if (eatset1<30) and (strtoint(mainfrm.lowerlife0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[9].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[9].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset1)); end;
         if (eatset2<>30) and (strtoint(mainfrm.life0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[9].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[9].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset2)); end;
         if (eatset3<30) and (strtoint(mainfrm.neigong0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[6].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[6].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset3)); end;
         if (eatset4<30) and (strtoint(mainfrm.waigong0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[7].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[7].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset4)); end;
         if (eatset5<30) and (strtoint(mainfrm.wugong0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[8].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[8].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset5)); end;
         if (eatset6<30) and (strtoint(mainfrm.yuanqi0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[5].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[5].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset6)); end;
         end;
true :  begin
         //判断值 是否补满或空
//         if (neigongnum1=0) or (waigongnum1=0) or (wugongnum1=0) then begin ackmonster:=false; sendfb('(SANjNNNNNNNSN>F[NNNN)');end;
         if (neigongnum1<>0) and (waigongnum1<>0) and (wugongnum1<>0) then
         begin
         if  ((neigongnum2 div neigongnum1)>=10) then neigongeat:=true;
         if  (neigongnum2 - neigongnum1)<100  then neigongeat:=false;
         if  ((waigongnum2 div waigongnum1)>=10) then waigongeat:=true;
         if  (waigongnum2 - waigongnum1)<100   then waigongeat:=false;
         if  ((wugongnum2  div wugongnum1 )>=10) then wugongeat:=true;
         if  (wugongnum2  - wugongnum1 )<100   then wugongeat:=false;
         end
         else
          begin
            ackmonster:=false;
            if neigongnum1=0 then neigongeat:=true;
            if waigongnum1=0 then waigongeat:=true;
            if wugongnum1 =0 then wugongeat :=true;
          end;

         if (eatset1<30) and (strtoint(mainfrm.lowerlife0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[9].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[9].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset1)); end;
         if (eatset2<30) and (strtoint(mainfrm.life0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[9].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[9].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset2)); end;

         if neigongeat=true then sendfb(leftclickshow1(1,eatset3));
         if waigongeat=true then sendfb(leftclickshow1(1,eatset4));
         if wugongeat =true then sendfb(leftclickshow1(1,eatset5));
         if (eatset6<30) and (strtoint(mainfrm.yuanqi0.Text)>= strtoint(trim(copy(mainfrm.basicattribe.Items.Item[5].SubItems.strings[0],0,pos('/',mainfrm.basicattribe.Items.Item[5].SubItems.strings[0])-1)))) then
             begin   sendfb(leftclickshow1(1,eatset6)); end;
         if (neigongnum1>400) and (waigongnum1>400) and (wugongnum1>400)  then ackmonster:=true;

        end; //对应true的begin

        end;  //对应case的
       end;
       sleep(strtoint(mainfrm.Edit2.Text));
   end;
  until mainfrm.checkbox1.Checked=false;
end;

//跑步法部分 不很好
procedure Tmainfrm.OBThread2Execute(Sender: TObject; params: Pointer);
var i:integer;  px,py:real;neigongnum1,waigongnum1,lifenum1,neigongnum2,waigongnum2,lifenum2:integer;
begin
repeat
//吃药跑路
if mainfrm.checkbox14.Checked=false then
   begin
     if pos('无名步法',mainfrm.StatusBar1.Panels[1].Text)=0 then
     sendfb(leftclickshow1(4,7));
       for i:=0 to strtoint(mainfrm.Edit15.text) do
       begin
         if (mainfrm.clientsocket1.Socket.Connected) then
         sendfb(movexy(2,strtoint(mainfrm.StatusBar1.Panels[2].Text),strtoint(mainfrm.StatusBar1.Panels[3].Text)));
         px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
         py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
         mainfrm.Shape1.Left:=Trunc(px);
         mainfrm.shape1.top:=Trunc(py);
         sleep(800);
         mainfrm.StatusBar1.Panels[2].Text:=inttostr(strtoint(mainfrm.StatusBar1.Panels[2].Text)+1);
       end;
       sleep(600);
if pos('无名步法',mainfrm.StatusBar1.Panels[1].Text)=0 then
     sendfb(leftclickshow1(4,7));
       for i:=0 to strtoint(mainfrm.Edit15.text) do
       begin
         if (mainfrm.clientsocket1.Socket.Connected) then
         sendfb(movexy(6,strtoint(mainfrm.StatusBar1.Panels[2].Text),strtoint(mainfrm.StatusBar1.Panels[3].Text)));
         px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
         py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
         mainfrm.Shape1.Left:=Trunc(px);
         mainfrm.shape1.top:=Trunc(py);
         sleep(800);
         mainfrm.StatusBar1.Panels[2].Text:=inttostr(strtoint(mainfrm.StatusBar1.Panels[2].Text)-1);
       end;
       sleep(600);
     end;

//跑步判断 补心法跑
if mainfrm.CheckBox14.Checked=true then
begin
neigongnum1:=strtoint(copy(neigong,0,pos('/',neigong)-1));
neigongnum2:=strtoint(copy(neigong,pos('/',neigong)+1,length(neigong)));
waigongnum1:=strtoint(copy(waigong,0,pos('/',waigong)-1));
waigongnum2:=strtoint(copy(waigong,pos('/',waigong)+1,length(waigong)));
   lifenum1:=strtoint(copy(life,0,pos('/',life)-1));
   lifenum2:=strtoint(copy(life,pos('/',life)+1,length(life)));
if ((neigongnum2 div neigongnum1)>10) or ((waigongnum2 div waigongnum1)>10) or ((lifenum2 div lifenum1)>10) then runeat:=true;
end;

//判断当前是跑还是打坐 true 是打坐 false 是跑步
  case runeat of
false: begin
if pos('无名步法',mainfrm.StatusBar1.Panels[1].Text)=0 then
     sendfb(leftclickshow1(4,7));
       for i:=0 to strtoint(mainfrm.Edit15.text) do
       begin
         if (mainfrm.clientsocket1.Socket.Connected) then
         sendfb(movexy(2,strtoint(mainfrm.StatusBar1.Panels[2].Text),strtoint(mainfrm.StatusBar1.Panels[3].Text)));
         px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
         py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
         mainfrm.Shape1.Left:=Trunc(px);
         mainfrm.shape1.top:=Trunc(py);
         sleep(800);
         mainfrm.StatusBar1.Panels[2].Text:=inttostr(strtoint(mainfrm.StatusBar1.Panels[2].Text)+1);
       end;
       sleep(600);
if pos('无名步法',mainfrm.StatusBar1.Panels[1].Text)=0 then
     sendfb(leftclickshow1(4,7));
       for i:=0 to strtoint(mainfrm.Edit15.text) do
       begin
         if (mainfrm.clientsocket1.Socket.Connected) then
         sendfb(movexy(6,strtoint(mainfrm.StatusBar1.Panels[2].Text),strtoint(mainfrm.StatusBar1.Panels[3].Text)));
         px:=strtoint(mainfrm.statusbar1.Panels[2].Text)/mapx * mainfrm.image1.width +mainfrm.Image1.Left ;
         py:=strtoint(mainfrm.statusbar1.Panels[3].Text)/mapy * mainfrm.image1.Height ;
         mainfrm.Shape1.Left:=Trunc(px);
         mainfrm.shape1.top:=Trunc(py);
         sleep(800);
         mainfrm.StatusBar1.Panels[2].Text:=inttostr(strtoint(mainfrm.StatusBar1.Panels[2].Text)-1);
       end;
       sleep(600);
     end;
   //心法判断
true:begin
       if pos(mainfrm.ComboBox6.Text,mainfrm.StatusBar1.Panels[1].Text)=0 then
          begin
          if mainfrm.ComboBox6.ItemIndex=0 then   sendfb(leftclickshow1(4,8));
          if mainfrm.ComboBox6.ItemIndex=1 then   sendfb(leftclickshow1(4,18));
          end;
          sleep(3000);
       if ((neigongnum2 div neigongnum1)<=1) and ((waigongnum2 div waigongnum1)<=1) and ((lifenum2 div lifenum1)<=1) then runeat:=false;
      end;
   //心法判断结束
   end;
until mainfrm.checkbox12.checked=false;
end;

//点击托盘按钮 程序还原
procedure Tmainfrm.RzTrayIcon1LButtonDblClick(Sender: TObject);
begin
    application.Restore;
end;

//当客户端连接后 发送数据给客户端
procedure Tmainfrm.IdTCPServerConnect(AThread: TIdPeerThread);
begin
AThread.Connection.WriteLn('(UuNNNNNNNNNFNNw>NNENuz<nrInd;zeN)(SANNNNNNNNNSNNV>NNNN)(SANNNNNNNNNSNNVSNANN)');
//sleep(500);
athread.Connection.WriteLn(clientack);
sleep(200);
if clientack1<>'' then
athread.Connection.WriteLn(clientack1);
//memo1.lines.Add(clientack1);
//mainfrm.timer1.enabled:=false;
mainfrm.fblist.Clear;
clientwork:=1;
pt:=athread;
clienttoserver:=true;
OBThread4.Execute(self);
end;

//客户端连接断开
procedure Tmainfrm.IdTCPServerDisconnect(AThread: TIdPeerThread);
begin
              clienttoserver:=false;
//      mainfrm.timer1.enabled:=true;
                  clientwork:=0;
              mainfrm.fblist.Clear;
                          pt.Data:=nil;
                athread.Data:=nil;
end;

//客户端连接后 客户端发出的数据转发
procedure Tmainfrm.IdTCPServerExecute(AThread: TIdPeerThread);
var
    Command : String;
begin
Command := AThread.Connection.CurrentReadBuffer;
mainfrm.clientsocket1.Socket.SendText(command);
end;

//程序关闭时的处理
procedure Tmainfrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     MI.Free;
  if idtcpserver.active=true then
     idtcpserver.active:=false;
end;

procedure Tmainfrm.CheckBox20Click(Sender: TObject);
var
    hthread:thandle;
    threadid:dword;
begin
if checkbox20.checked=true then
   hthread:=CreateThread(nil,0,@tradenpc,nil,0,ThreadID);
end;

//启动客户端 切屏进入
procedure Tmainfrm.CheckBox21Click(Sender: TObject);
begin
   idtcpserver.active:=checkbox21.checked;
   ChDir(copy(clientexe,0,pos('.',clientexe)-8));
if checkbox21.checked=true then
   winexec(pchar(clientexe),SW_SHOWNORMAL);

end;

//设定客户端路径
procedure Tmainfrm.Button9Click(Sender: TObject);
begin
   opendialog1.Filter:='千年客户端文件(client.exe)|client.exe';
if opendialog1.Execute then
   writeinistr(INIPath+'backup.ini','exe','client',opendialog1.Filename);
   clientexe:=opendialog1.FileName;
end;


//发送数据给客户端
procedure Tmainfrm.OBThread4Execute(Sender: TObject; params: Pointer);
begin
   repeat
     begin
     if pt.Connection.Connected and ((mainfrm.fblist.Items.count-1)>=0) then
        begin
        pt.Connection.WriteLn(mainfrm.fblist.Items.Strings[0]);
     //   sleep(100);
        mainfrm.fblist.Items.Delete(0);
        end;
     end;
   until clientwork=0;//clienttoserver=false;
   checkbox21.Checked:=false;
end;
//物品拾取
function seize:string;
begin
    //拾取设定
   Randomize;//随机初始化 保证不重复
   while (mainfrm.checkbox5.Checked=true) do //and (mainfrm.clientsocket1.Socket.Connected) do
   begin
    if (mainfrm.goodsget.Items.Count-1>=0)then
       sendfb(clickmonster(mainfrm.goodsget.Items.Strings[random(mainfrm.goodsget.Items.Count-1)]));
       sleep(300);
   end;
end;

//连接服务器
function gameconnect:string;
begin
  try
    mainfrm.clientsocket1.active:=true;
    sleep(200);
  except
  end;
end;

//当是未储值时断开连接
procedure Tmainfrm.OBThread3Execute(Sender: TObject; params: Pointer);
begin
  mainfrm.clientsocket1.Socket.close;
end;

procedure Tmainfrm.CheckBox18Click(Sender: TObject);
begin
  if checkbox18.checked=false then
     ackmonster:=true;
end;

//连接到服务器时动作
procedure Tmainfrm.ClientSocket1Connect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
if answerok=true then
  begin
          if mainfrm.combobox4.ItemIndex=0 then    sendfb('(SuNNNNNNNNNUNNw]NNMN)');
          if mainfrm.combobox4.ItemIndex=1 then    sendfb('(SuNNNNNNNNNUNNw]NNwN)'); //TW版得连线信息
          if mainfrm.combobox4.ItemIndex=2 then    sendfb('(SuNNNNNNNNNUNNwCNNMN)');
          if mainfrm.combobox4.itemindex=3 then    sendfb('(SuNNNNNNNNNUNNwCNNMN)');
   answerok:=false;
  end;
  statusbar1.Panels[0].Text:='连线成功';
end;

//外挂接收到服务器的消息部分
procedure Tmainfrm.ClientSocket1Read(Sender: TObject;
  Socket: TCustomWinSocket);
var s,str:string;
begin
    s:=Socket.ReceiveText;
    begin
    str:=s;
    str:=str1+str;
    if length(str)>9000 then clientack:=copy(str,0,pos('(PNNNNNNNNN>g',str)+500)+'(SANNNNNNNNNSNNVSNNNN)(SANNNNNNNNNSNNVVNANN)';
    if (str[length(str)])=')' then
    begin
    myrecv(pchar(str),length(str));
    str1:='';
    if (length(str)<3000)and(pos('(PNNNNNNNNN>g',str)>0) then clientack1:='(SuNNNNNNNNNUNNWAduNN)(SuNNNNNNNNNUNTP\NNNN)'+copy(str,pos('(PNNNNNNNNN>g',str),310)+'(SANNNNNNNNNSNNVSNNNN)(SANNNNNNNNNSNNVVNANN)';
    if (clientwork=1)and (length(str)<2000)  then
       begin
         fblist.items.add(str);
       //else
       // idtcpserver.Active:=false;
       end;
     end
    else
    str1:=str;
  end;
end;

//服务器断开时的设定
procedure Tmainfrm.ClientSocket1Disconnect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
  statusbar1.Panels[0].Text:='连线中断';
  speedbutton1.Visible:=false;
  speedbutton2.Visible:=true;
        shape1.Visible:=false;
            ackmonster:=true;
    checkbox21.Checked:=false;
    checkbox21.Visible:=false;
  if idtcpserver.Active=true then idtcpserver.Active:=false;
end;

//连接服务去出错时的屏蔽弹出
procedure Tmainfrm.ClientSocket1Error(Sender: TObject;
  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
  var ErrorCode: Integer);
begin
  ErrorCode := 0;
  Socket.Close;
end;



procedure Tmainfrm.OBThread5Execute(Sender: TObject; params: Pointer);
var i,sitxy:integer;manx,many:integer;
begin
repeat
    manx:=abs(strtoint(StatusBar1.Panels[2].Text)-strtoint(listview1.Items.Item[0].SubItems[0]));
    many:=abs(strtoint(StatusBar1.Panels[3].Text)-strtoint(listview1.Items.Item[0].SubItems[1]));
if (manx<6) and (many<6) then
   begin
//设定循环
   for i:=0 to listview1.Items.Count-1 do
     begin
      repeat
        begin
          manx:=abs(strtoint(StatusBar1.Panels[2].Text)-strtoint(listview1.Items.Item[i+1].SubItems[0]));
          many:=abs(strtoint(StatusBar1.Panels[3].Text)-strtoint(listview1.Items.Item[i+1].SubItems[1]));
          //设定走路开步法
          if pos('无名步法',StatusBar1.Panels[1].Text)=0 then    sendfb(leftclickshow1(4,7));
           //设定走路
          sendfb(movexy(strtoint(listview1.Items.Item.Caption),strtoint(StatusBar1.Panels[2].Text),strtoint(StatusBar1.Panels[3].Text)));
case strtoint(listview1.Items.Item.Caption) of
0 : mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
1 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
     end;
2 : mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
3 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)+1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
     end;
4 : mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
5 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)+1);
     end;
6 : mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
7 : begin
        mainfrm.statusbar1.Panels[2].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[2].Text)-1);
        mainfrm.statusbar1.Panels[3].Text:=inttostr(strtoint(mainfrm.statusbar1.Panels[3].Text)-1);
     end;
     end;
     sleep(800);
     end;
      until (manx<2) and (many<2) or (checkbox17.Checked=false);
     end;
   end;
   sleep(5000);
until checkbox17.Checked=false;
end;


procedure Tmainfrm.gooddrugChange(Sender: TObject);
begin
   writeinistr(INIPath+'backup.ini','eating','gooddrug',gooddrug.text);
end;

procedure Tmainfrm.N19Click(Sender: TObject);
begin
gooddrug.Text:=mainfrm.goodsview.Items.Item[mainfrm.goodsview.itemindex].Caption;

end;

end.


http://yunpan.cn/QGsc8ApIEwwd5
附件: 千年脱机(delphi源码).7z (675 K) 下载次数:8
善者 慈悲心常在 无怨无恨 以苦为乐
默认压缩密码www.hifyl.com
文件分享密码问题:http://www.hifyl.com/read-htm-tid-4444.html
离线司马良

只看该作者 沙发  发表于: 2016-02-07
快速回复
限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
上一个 下一个