📄 loopattack.pas
字号:
unit LoopAttack;
{---------无影开发小组敬告:-------------------}
{ 外挂研究无罪,开放源码有理! }
{ 希望以此献给各位想研究外挂的朋友一窥外挂之容 }
{ 本代码只供研究之用,不得用于非法用途 }
interface
uses Windows,Dialogs,SendPack,UnitState,PackStruct,
GameCode,Move;
var
TagMstId : dword; //正在攻击的怪物id
TagMstPos : PosPoint; //正在攻击的怪物坐标
TagMstDir : Integer; //怪物正在攻击角色的方向
AtkStopFlag : boolean=false;//强制停止攻击标志 true为强制停止
AtkLastFlag : boolean=false;//攻击正在进行标志 true为正在运行
HpMinAdd : Integer=0;
MpMinAdd : Integer=0;
HpAddPotion : string='小包子';
MpAddPotion : string='小仙丹';
//-----------------------------------------------------------
function LADisPack1(Text:PChar):Integer;
function LADisPack2(Text:PChar):Integer;
procedure MovDisPack(Text:PChar);
procedure StopAtk;
function LoopAtk():Integer;
function UseItem(ItemName:string):Integer;
procedure UseMagic1(MstPos:PosPoint;MstId:DWORD);
//-----------------------------------------------------------
implementation
function LADisPack1(Text:PChar):Integer;
//判断攻击的怪物是否在周围决定是否攻击
var
PtrP :^PackHeaderA;
AtPoint : PosPoint;
begin
PtrP:=@Text[0];
AtPoint.X:=ptrp^.w1;
AtPoint.Y:=ptrp^.w2;
//DBGOut('AP.x=%d,AP.y=%d',[AtPoint.X,AtPoint.Y]);
LADisPack1:=0;
if TagMstId=ptrp^.dwFlag then
TagMstDir:=PtrP^.w3;
if IsRoundPoint(AtPoint)=false then
begin
exit;
end;
if AtkLastFlag=false then
begin
//AtkLastFlag:=true;
TagMstId:=PtrP^.dwFlag;
TagMstPos.X:=AtPoint.X;
TagMstPos.Y:=AtPoint.Y;
LADisPack1:=1;
end;
//OutputDebugString('will attack');
//DBGOut('FL Flag=%d',[FailCnt]);
end;
function LADisPack2(Text:PChar):Integer;
//判断目标怪物是否与当前相等并从mstlist里去掉
var
ptrp:^PackHeaderA;
n : Integer;
begin
LADisPack2:=0;
ptrp:=@Text[0];
n:=MstList1.FindMstbyId(ptrp.dwFlag);
DBGOut('n=%d,ptrp.dwFlag=%d',[n,ptrp.dwFlag]);
if n<>-1 then
begin
MstList1.DelMst(n);
end;
if ptrp.dwFlag=TagMstId then
begin
LADisPack2:=1;
DBGOut('dwFlag=%d,TagMstId=%d',[ptrp.dwFlag,TagMstId]);
end;
end;
procedure MovDisPack(Text:PChar);
var
ptrp:^PackHeaderA;
n : Integer;
npos: PosPoint;
begin
ptrp:=@text[0];
n:=MstList1.FindMstbyId(ptrp.dwFlag);
if n<>-1 then//改变怪物表中移动的怪物坐标
begin
npos.X:=ptrp.w1;
npos.Y:=ptrp.w2;
MstList1.EditMstPos(ptrp.dwFlag,npos);
end;
if ptrp.dwFlag=TagMstId then
begin //改变被攻击怪物坐标
TagMstPos.X:=ptrp.w1;
TagMstPos.Y:=ptrp.w2;
end;
end;
procedure StopAtk;
begin
AtkStopFlag:=true;
end;
function LoopAtk():Integer;
var
Pack : PackHeaderA;
Delay : Integer;
dir : Integer;
p2 : PackHeaderB;
begin
if PatrolLast=true then
LoopAtk:=3
else
LoopAtk:=0;
//刷新位置
RefreshPos;
//定义转向包
AtkLastFlag:=true;
dir:=GetToDir(CharPos,TagMstPos);
P2.X:=CharPos.X;
p2.Y:=CharPos.Y;
P2.wcmd:=$0bc2;
p2.w1:=0;
p2.w2:=dir;
p2.w3:=0;
Delay:=1000;
//转向
SendMyPack(PChar(@p2),12);
Sleep(600);
SendMyPack(PChar(@p2),12);
AtkStopFlag:=false;
//DBGOut('1',[]);
//DBGOut('2',[]);
//定义攻击包
Pack.dwFlag:=TagMstId;
Pack.wcmd:=$0bc6;
Pack.w1:=0;
Pack.w2:=dir;
Pack.w3:=0;
///DBGOut('3',[]);
//进入攻击循环
while (AtkStopFlag=false) and (FailCnt<5) do
begin
sleep(delay);
if FailCnt>0 then
begin
sleep(delay);
delay:=delay+100;
end;
//DBGOut('4',[]);
dir:=GetAntiDir(TagMstDir);
Pack.w2:=dir;
SendMyPack(PChar(@Pack),12);
//DBGOut('Enter wait',[]);
//Sleep(delay);
WaitForSingleObject(HSignal,INFINITE);
//DBGOut('Atk:CPX=%d,CPY=%d,MPX=%d,MPY=%d,dir=%d',[CharPos.X,CharPos.Y,TagMstPos.X,TagMstPos.Y,dir]);
end;
//DBGOut('5',[]);
AtkLastFlag:=false;
FailCnt:=0;
if PatrolLast=true then
begin
LoopAtk:=3;
DBGOut('LoopAtk:=3',[]);
end
else
LoopAtk:=0;
DBGOut('Stop Atk',[]);
end;
function UseItem(ItemName:string):Integer;
//使用道具
var
ItemIndex : Integer;
ItemBuf : THPMPInfo;
UsePack : PackHeaderA;
begin
UseItem:=0;
ItemIndex:=ItemBox1.FindItem(ItemName);
if ItemIndex=-1 then
begin
//ShowMessage('无此道具!');
DBGOut('UseItem:无此道具',[]);
exit;
end;
ItemBox1.GetItem(ItemIndex,@ItemBuf);
UsePack.dwFlag:=ItemBuf.ID;
UsePack.wcmd:=$03ee;
UsePack.w1:=0;
UsePack.w2:=0;
Usepack.w3:=0;
//ItemBox1.RemoveItem(ItemBuf.ID); //这个被放到解析EE03包时候作
UseItem:=1;
SendMyPack(PChar(@UsePack),12);
end;
procedure UseMagic1(MstPos:PosPoint;MstId:DWORD);
var
Pack : PackHeaderB;
begin
DBGOut('magic1:x=%d,y=%d,MID=%d',[MstPos.X,MstPos.Y,MstId]);
Pack.X :=MstPos.X;
Pack.Y :=MstPos.Y;
Pack.wcmd:=$0bc9;
Pack.w1 :=Word(MstId and $ffff);
Pack.w2 :=$1;
Pack.w3 :=Word(MstId shr 16);
SendMyPack(@Pack,12);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -