dnf幻影
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls,consttype,IniFiles, ExtCtrls;
type
TForm1 = class(TForm)
TabUserInfo: TTabSheet;
TabSetting: TTabSheet;
tabs_user: TPageControl;
GroupBox1: TGroupBox;
Label1: TLabel;
Label_Name: TLabel;
Label2: TLabel;
Label_Leave: TLabel;
Label3: TLabel;
Label4: TLabel;
Label_Xue: TLabel;
Label_Lan: TLabel;
GroupBox2: TGroupBox;
CheckBoxXue: TCheckBox;
Label5: TLabel;
Edit_limitXue: TEdit;
ComboBox_Xue: TComboBox;
Label6: TLabel;
CheckBoxLan: TCheckBox;
Label7: TLabel;
Edit_limitLan: TEdit;
Label8: TLabel;
ComboBox_Lan: TComboBox;
CheckBox_PackUp: TCheckBox;
ComboBox_PickKey: TComboBox;
Button_autoAttack: TButton;
Button_stopAttick: TButton;
Edit_attackLimit: TEdit;
Label9: TLabel;
ListBox_ItemFilter: TListBox;
Button_listAdd: TButton;
Edit_AddItem: TEdit;
Label10: TLabel;
Button_listDel: TButton;
Label11: TLabel;
Label_exp: TLabel;
CheckBox_useSkill: TCheckBox;
ComboBox_skill: TComboBox;
Button_refresh: TButton;
Button2: TButton;
Edit1: TEdit;
Timer1: TTimer;
Label12: TLabel;
Label_Coordinate: TLabel;
CheckBox_compSkill: TCheckBox;
ListBox_compSkill: TListBox;
Button_addcompski: TButton;
CheckBox_SkillAdd: TCheckBox;
Edit_SkillAddDelay: TEdit;
ComboBox_skilladd: TComboBox;
Edit_skilladdlimit: TEdit;
GroupBox3: TGroupBox;
Label13: TLabel;
Label_BugName: TLabel;
Label15: TLabel;
Label_BugXue: TLabel;
ProgressBar1: TProgressBar;
procedure FormCreate(Sender: TObject);
procedure CheckBoxXueClick(Sender: TObject);
procedure initComboBox;
procedure FormDestroy(Sender: TObject);
procedure CheckBoxLanClick(Sender: TObject);
procedure CheckBox_PackUpClick(Sender: TObject);
procedure Button_autoAttackClick(Sender: TObject);
procedure Button_stopAttickClick(Sender: TObject);
procedure tabs_userChange(Sender: TObject);
procedure ListBox_ItemFilterClick(Sender: TObject);
procedure Button_listAddClick(Sender: TObject);
procedure Button_listDelClick(Sender: TObject);
procedure Button_refreshClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button_addcompskiClick(Sender: TObject);
private
{ Private declarations }
procedure RegHotKey(handle:THandle;aatom:atom;keyName:pchar;key:cardinal);
procedure UnHotKey(handle:THandle;aatom:atom);
procedure GetHotKey(var msg:tmessage);message wm_hotkey;
procedure InitItemFilter;
procedure SaveItemFilter;
procedure InitListBox;
procedure InitLeave;
public
{ Public declarations }
function GetSelectXueID:cardinal;
function GetSelectLanID:cardinal;
Function GetCheckXue:boolean;
end;
var
Form1: TForm1;
hotKey: array[hot_sit..hot_up] of atom; //设置热键数组;
drugsXue:array[0..9] of TDrugs; //血物品信息
drugsLan:array[0..9] of TDrugs; //蓝物品信息
addType:boolean;
itemFilter:ATItemFilter;
leaveArray:array of integer;
pid:cardinal;
skills:ATSkill; //技能ID数组
compSkill:ATSkill;//辅助技能数组
implementation
uses UnitBaseInfo,UnitAutoAdd,UnitAutoAttack,UnitCall,UnitPickUpThread,
UnitSkillSetDlg;
var
//基本信息线程
MyBaseInfo:BaseInfo;
myAutoAdd:AutoAdd;
appPath:pchar; //程序路径
myAutoAttack:AutoAttack;
myPickUpThread:PickUpThread;
PickKey:cardinal;
{$R *.dfm}
procedure TForm1.CheckBoxXueClick(Sender: TObject);
begin
Edit_limitXue.Enabled:=not Edit_limitXue.Enabled;
ComboBox_Xue.Enabled:=not ComboBox_Xue.Enabled;
end;
procedure TForm1.CheckBoxLanClick(Sender: TObject);
begin
Edit_limitLan.Enabled:=not Edit_limitLan.Enabled;
ComboBox_Lan.Enabled:=not ComboBox_Lan.Enabled;
end;
//初始化过滤数组结构
procedure TForm1.initItemFilter;
var
myinifile:Tinifile;
path:pchar;
total:integer;
i,j:integer;
id,name:pchar;
tempid:integer;
tempName:string;
section:string;
begin
j:=0;
path:=pchar(appPath+'setting.ini');
myinifile:=Tinifile.Create(path);
section:='itemfilter';
total:=myinifile.ReadInteger(section,'total',0);
setlength(itemFilter,total);
for i:=0 to total-1 do
begin
id:=pchar('id'+inttostr(i));
name:=pchar('name'+inttostr(i));
tempid:=myinifile.ReadInteger('itemfilter',id,0);
tempName:=myinifile.ReadString('itemfilter',name,'');
if tempName<>'' then
begin
itemFilter[j].id:=tempid;
itemFilter[j].name:=tempName;
j:=j+1;
end;
end;
myinifile.Free;
end;
//保存过滤数组结构
procedure TForm1.SaveItemFilter;
var
myinifile:Tinifile;
path:pchar;
i:integer;
id,name:pchar;
section:string;
tot:string;
begin
path:=pchar('./setting.ini');
myinifile:=Tinifile.Create(path);
section:='itemfilter';
tot:='total';
myinifile.EraseSection(section);
myinifile.WriteInteger(section,tot,length(itemFilter));
if Length(itemFilter)>0 then
begin
for i:=0 to length(itemFilter)-1 do
begin
//if itemFilter[i].name <> nil then
begin
id:=pchar('id'+inttostr(i));
name:=pchar('name'+inttostr(i));
myinifile.WriteInteger(section,id,itemFilter[i].id);
myinifile.WriteString(section,name,itemFilter[i].name);
end;
end;
end;
myinifile.Free;
end;
//初始化listbox
procedure TForm1.InitListBox;
var
i:integer;
begin
for i:=0 to length(itemFilter)-1 do
begin
ListBox_ItemFilter.Items.Add(itemFilter[i].name);
end;
end;
//初始化combobox
procedure TForm1.InitComboBox;
var
myinifile:Tinifile;
path:pchar;
i,j:integer;
id,name:pchar;
tempid:integer;
tempName:string;
begin
j:=0;
path:=pchar(appPath+'setting.ini');
myinifile:=Tinifile.Create(path);
for i:=0 to length(drugsXue)-1 do
begin
id:=pchar('id'+inttostr(i));
name:=pchar('name'+inttostr(i));
tempid:=myinifile.ReadInteger('drugsXue',id,0);
tempName:=myinifile.ReadString('drugsXue',name,'');
if tempName<>'' then
begin
drugsXue[j].ID:=tempid;
drugsXue[j].name:=tempName;
ComboBox_Xue.Items.Add(drugsXue[j].name);
j:=j+1;
end;
end;
j:=0;
for i:=0 to length(drugsXue)-1 do
begin
id:=pchar('id'+inttostr(i));
name:=pchar('name'+inttostr(i));
tempid:=myinifile.ReadInteger('drugsLan',id,0);
tempName:=myinifile.ReadString('drugsLan',name,'');
if tempName<>'' then
begin
drugsLan[j].ID:=tempid;
drugsLan[j].name:=tempName;
ComboBox_Lan.Items.AddObject(drugsLan[j].name,TObject(j));
j:=j+1;
end;
end;
myinifile.Free;
end;
//初始化等级数组
procedure TForm1.InitLeave;
var
myinifile:Tinifile;
path:pchar;
i:integer;
total:integer;
section:string;
begin
path:=pchar('./leave.ini');
section:='leave';
myinifile:=Tinifile.Create(path);
total:=myinifile.ReadInteger(section,'total',0);
setlength(leaveArray,total);
for i:=0 to high(leaveArray) do
begin
leaveArray[i]:=myinifile.ReadInteger(section,inttostr(i),0);
end;
myinifile.Free;
end;
//注册热键过程
procedure TForm1.RegHotKey(handle:THandle;aatom:atom;keyName:pchar;key:cardinal);
begin
aatom:=globaladdatom(keyName);
RegisterHotKey(handle,aatom,0,key);
end;
//卸载热键过程
procedure TForm1.UnHotKey(handle:THandle;aatom:atom);
begin
UnRegisterHotKey(handle,aatom);
globalDeleteatom(aatom);
end;
//热键响应
procedure TForm1.GetHotKey(var msg:tmessage);
begin
if msg.LParamHi=PickKey then //拾取物品
begin
myPickUpThread:=PickUpThread.Create(false);
end;
end;
//返回红药ID
function TForm1.GetSelectXueID:cardinal;
begin
result:=drugsXue[ComboBox_Xue.ItemIndex].ID;
end;
//返回蓝药ID
function TForm1.GetSelectLanID:cardinal;
begin
result:=drugsLan[ComboBox_Lan.ItemIndex].ID;
end;
function TForm1.GetCheckXue:boolean;
begin
result:=CheckBoxXue.Checked;
end;
//窗体创建
procedure TForm1.FormCreate(Sender: TObject);
var
wnd:hwnd;
begin
Wnd := FindWindow(nil,'Element Client');
GetWindowThreadProcessId(wnd,@pid);
appPath:=pchar(ExtractFilePath(Application.ExeName));
initComboBox;
InitLeave;
initItemFilter;
initListBox;
addType:=false;
myBaseInfo:=BaseInfo.Create(false);
myAutoAdd:=AutoAdd.Create(false);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
myBaseInfo.Destroy;
myAutoAdd.Destroy;
SaveItemFilter;
UnHotKey(self.Handle,hotKey[hot_pick]);
end;
procedure TForm1.CheckBox_PackUpClick(Sender: TObject);
begin
pickKey:=HotKeys[ComboBox_PickKey.ItemIndex];
RegHotKey(self.Handle,hotKey[hot_pick],'pickup',PickKey);//拾取物品
end;
procedure TForm1.Button_autoAttackClick(Sender: TObject);
begin
myAutoAttack:=AutoAttack.Create(false);
end;
procedure TForm1.Button_stopAttickClick(Sender: TObject);
begin
myAutoAttack.Terminate;
myAutoAttack.Free;
end;
procedure TForm1.tabs_userChange(Sender: TObject);
begin
if tabs_user.ActivePageIndex=1 then
begin
end;
end;
procedure TForm1.ListBox_ItemFilterClick(Sender: TObject);
begin
Edit_AddItem.Text:=ListBox_ItemFilter.Items.Strings[ListBox_ItemFilter.itemindex];
end;
procedure TForm1.Button_listAddClick(Sender: TObject);
var
i:integer;
begin
ListBox_ItemFilter.Items.Add(Edit_AddItem.Text);
setlength(itemFilter,ListBox_ItemFilter.Items.Count);
for i:=0 to high(itemFilter) do
begin
itemFilter[i].name:=ListBox_ItemFilter.Items.Strings[i];
end;
end;
procedure TForm1.Button_listDelClick(Sender: TObject);
var
i:integer;
begin
ListBox_ItemFilter.Items.Delete(ListBox_ItemFilter.itemindex);
setlength(itemFilter,ListBox_ItemFilter.Items.Count);
for i:=0 to high(itemFilter) do
begin
itemFilter[i].name:=ListBox_ItemFilter.Items.Strings[i];
end;
end;
procedure TForm1.Button_refreshClick(Sender: TObject);
var
myFuncCall:FuncCall;
i:integer;
begin
self.ComboBox_skill.Items.Clear;
self.ComboBox_skilladd.Items.Clear;
self.CheckBox_useSkill.Enabled:=true;
self.ComboBox_skill.Enabled:=true;
myFuncCall.GetSkill(skills);
for i:=0 to high(skills) do
begin
self.ComboBox_skill.Items.Add(skills[i].name);
self.ComboBox_skilladd.Items.Add(skills[i].name);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
myFuncCall:FuncCall;
begin
myFuncCall.test;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Caption:=self.Label_Name.Caption+self.Label_Xue.Caption+'explorer';
Application.Title:=self.Label_Name.Caption+self.Label_Xue.Caption+'explorer';
end;
procedure TForm1.Button_addcompskiClick(Sender: TObject);
begin
SkillSetDlg.show;
SkillSetDlg.InitSkill;
end;
end.