📄 attackthreads.pas
字号:
unit AttackThreads;
interface
uses
Windows, Messages, SysUtils, Variants, Classes;
type
TAttackThreads = class(TThread)
private
FStartAddress:Dword;
FActorMemList:TStrings;
FActorList:TList;
procedure GetActorMemlist(StartAddress:Dword);
procedure GetActorList;
function GetAttackMoster:TActor;
procedure GetItemBag;
protected
procedure Execute; override;
public
constructor Create;
end;
implementation
procedure SendPack(Addres:Integer;Len:Integer);
begin
asm
pushad
push Len
push Addres
call dword ptr ds:[$5A7FD0]
popad
end;
end;
procedure GameAttack(ID:integer);
var Address:Pointer;
begin
RID:=CharSelf.Address;
Address:=Pointer($00475840);
asm
pushad
mov edx,ID
mov eax,esi
mov dword ptr ds:[esi+$434],2
mov dword ptr ds:[esi+$43C],0
mov dword ptr ds:[esi+$440],edx
Call Address
popad
end;
end;
procedure Gamemove(X,Y:integer);
var Address:Pointer;
begin
Address:=Pointer($00475570);
asm
pushad;
mov edi,y;
mov ebx,x;
mov eax,RID;
call address;
popad;
end;
end;
constructor TAttackThreads.Create;
begin
FreeOnTerminate:=True;
FActorMemList:=TStringList.Create;
FActorList:=TList.Create;
AttackMonster.ID:=0;
inherited Create(False);
end;
procedure TAttackThreads.GetActorMemlist(StartAddress:Dword);
var
t:dword;
Address:Dword;
begin
FActorMemList.Clear;
Address:=Dword(Pointer(StartAddress+$14)^);
if Address=0 then exit;
repeat
asm
Pushad
mov esi,address
test esi,esi
je @Z
@Fck:mov eax,dword ptr ds:[esi]
cmp eax,$564C34
jnz @Fnext
mov eax,dword ptr ds:[esi+$10]
test eax,$2000000
je @Fnext
test eax,$20010000
jnz @Fnext
test byte ptr ds:[esi+$18],4
jnz @Fnext
mov eax,dword ptr ds:[esi+$11C]
cmp eax,8
je @Fnext
cmp eax,1
je @Fnext
jmp @Fend
@Fnext:mov esi,dword ptr ds:[esi+$118]
test esi,esi
jnz @Fck
test esi,esi
je @Z
@Fend:mov t,esi
mov esi,dword ptr ds:[esi+$118]
@Z:mov address,esi
popad
end;
FActorMemList.Add(IntToStr(t));
until Address=0;
end;
procedure TAttackThreads.GetActorList;
var
i,j:integer;
Address:Dword;
Actor:PActor;
ActorName:Char;
begin
for i:=0 to FActorList.Count-1 do
begin
Dispose(FActorList.Items[i]);
end;
FActorList.Clear;
if FActorMemList.Count>=0 then
begin
Address:=StrToInt(FActorMemList[0]);
CharSelf.Address:=Address;
CharSelf.ID:=integer(Pointer(Address+$1C)^);
CharSelf.X:=word(Pointer(Address+$26)^);
CharSelf.Y:=word(Pointer(Address+$2A)^);
CharSelf.Name:='';
for j:=0 to 15 do
begin
ActorName:=char(Pointer(Address+$1B4+j)^);
CharSelf.Name:=CharSelf.Name+ActorName;
end;
CharSelf.Name:=Trim(CharSelf.Name);
CharSelf.ActorType:=Word(Pointer(Address+$C)^);
CharSelf.HP:=integer(Pointer(Address+$288)^);
CharSelf.MaxHP:=integer(Pointer(Address+$28C)^);
CharSelf.MP:=integer(Pointer(Address+$290)^);
CharSelf.MaxMP:=integer(Pointer(Address+$294)^);
CharSelf.Weight:=integer(Pointer(Address+$2A0)^);
CharSelf.MaxWeight:=integer(Pointer(Address+$2A4)^);
FActorMemList.Delete(0);
end;
for i:=0 to FActorMemList.Count-1 do
begin
New(Actor);
Address:=StrToInt(FActorMemList[i]);
Actor.ID:=integer(Pointer(Address+$1C)^);
Actor.X:=word(Pointer(Address+$26)^);
Actor.Y:=word(Pointer(Address+$2A)^);
Actor.Name:='';
for j:=0 to 15 do
begin
ActorName:=char(Pointer(Address+$1B4+j)^);
if ord(ActorName)=0 then Break;
Actor.Name:=Actor.Name+ActorName;
end;
Actor.Name:=Trim(Actor.Name);
Actor.ActorType:=Word(Pointer(Address+$C)^);
Actor.HP:=integer(Pointer(Address+$288)^);
FActorList.Add(Actor);
end;
end;
function TAttackThreads.GetAttackMoster:TActor;
var
nearway,way,i:integer;
Actor:PActor;
ActorName:String;
begin
NearWay:=0;
Result.ID:=0;
for i:=0 to FActorList.Count-1 do
begin
New(Actor);
Actor:=FActorList.Items[i];
ActorName:=Actor.Name;
if Pos(Trim(ActorName),CanAttackMon)>0 then
begin
way:=Abs(CharSelf.X-Actor.X)+Abs(CharSelf.Y-Actor.Y);
if (Way<nearway) or (nearway=0) then
begin
nearway:=way;
Result:=Actor^;
end;
end;
end;
end;
procedure TAttackThreads.GetItemBag;
Var
ItemBagAddress:Dword;
ItemAddress:Dword;
Item:Pitem;
i:integer;
begin
for i:=0 to ItemBag.Count-1 do
begin
Dispose(ItemBag.Items[i]);
end;
ItemBag.Clear;
ItemBagAddress:=Dword(Pointer(CharSelf.Address+$308)^);
ItemAddress:=0;
while (ItemAddress<>$CDCDCDCD) and (ItemBag.Count<40) do
begin
New(Item);
ItemAddress:=Dword(Pointer(ItemBagAddress)^);
ItemBagAddress:=ItemBagAddress+4;
if ItemAddress<>$CDCDCDCD then
begin
Item.Id1:=integer(Pointer(ItemAddress+$3)^);
Item.Id2:=integer(Pointer(ItemAddress+$7)^);
Item.Name:='';
for i:=0 to 15 do
begin
if ord(char(Pointer(ItemAddress+$10+i)^))=0 then break;
Item.Name:=Item.Name+char(Pointer(ItemAddress+$10+i)^);;
end;
ItemBag.Add(Item);
end;
end;
end;
procedure TAttackThreads.Execute;
begin
while true do
begin
Sleep(1);
FStartAddress:=Dword(Pointer($005BB000)^);
if FStartAddress<>0 then
begin
GetActorMemlist(FStartAddress);
GetActorList;
GetItemBag;
AttackMonster.ID:=0;
AttackMonster:=GetAttackMoster;
end
else
begin
AttackMonster.ID:=0;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -