var
monid,Goods,Goods1:PDWORD;
i:DWord;
goodsName:PAnsiChar;
strName:string;
begin
if self.CheckBox9.Checked then
for i:=0 to 80 do
begin
Goods:=Pointer(PGameBase);
Goods:=Pointer(Goods^+I*4);
monid:=Pointer(Goods^+$20); //+80怪物ID
Goods1:=Pointer(Goods^+$90); //+90怪物与人的距离 浮点
GoodsName:=Pointer(Goods^+$10B); //读出了名字
GoodsName:=Pointer(Goods^);
StrName:=(GoodsName);
if strName<>Edit1.Text then continue ; //这里简单的设置下
pickgoods55(monid^); //pickgoods55();ID攻击
end;
end;
var
monid,Goods,Goods1:PDWORD;
i:DWord;
goodsName:PAnsiChar;
strName:string;
begin
if self.CheckBox9.Checked then
for i:=0 to 80 do
begin
Goods:=Pointer(PGameBase);
Goods:=Pointer(Goods^+I*4);
monid:=Pointer(Goods^+$20); //+80怪物ID
Goods1:=Pointer(Goods^+$90); //+90怪物与人的距离 浮点 主要在这里Goods1 的值是遍历所有怪物与人物的距离 ***
GoodsName:=Pointer(Goods^+$10B); //取出怪物了名字
StrName:=(GoodsName); //字符转换
if strName<>Edit1.Text then continue ; //在Edit1里输入怪物名字就可以遍历出怪物对应名字的怪物ID(但打怪不是按最近打起)
pickgoods55(monid^); //pickgoods55();pickgoods55 是用怪物ID的技能攻击 里面的monid^是怪物ID
end;
end;
假设没有就这样写也可以打怪,但打怪,不是按最近的距离打怪,我想想 遍历Goods1的值最小 用排序遍历指向最近的怪物ID,就想我制定的GoodsName转换名字可以遍历出怪物的ID
procedure TForm1.BitBtn1Click(Sender: TObject);
var
str : String;
temp: String;
num: array of Integer;
i,j,k: Integer;
n,m,l: Integer;
begin
str:= Trim(Edit1.Text);
Setlength(num,length(Edit1.Text));
i:=1;
j:=1; //字符串从1开始
while (i<Length(str)) do
begin
While((str[i]<>#32)And(str[i]<>#0)) do //字符串可以用数组索引
begin
temp:=temp+str[i];
i:=i+1;
end;
num[j]:=StrToInt(temp);
i:=i+1;
j:=j+1;
temp:='';
end;
//执行冒泡排序
n:= j;
For l:=1 to n-1 do
begin
k:= n - l;
For j:=1 to k do
begin
If (num[j] < num[j+1]) then
begin
m:= num[j];
num[j]:= num[j+1];
num[j+1]:= m;
end;
end;
end;
Edit1.Text:= '';
For l:= n-1 Downto 1 do
Edit1.Text:= Edit1.Text + IntToStr(num[l]) + ' ';