PDA

Просмотр полной версии : Работа с плагинами DLL bot


Name4Me
21.04.2009, 21:20
Пол года пишу бот, Хочу виложить части когда так сказать на разбор полётов, а также для оптимизации кода. Думаю некоторим будет интересно.

Сразу сори так как програмить учился 10 лет назад в техникуме... :)
сначала виложу основние юнити:
unit TItems;

interface
Uses Contnrs,Dialogs,SysUtils;
Type
TItem = class
Public
ID:integer;
OID:integer;
Count:integer;
AugmentationBonus:integer;
end;

TItemList = class(TObjectList)
private
function GetItems(Index: Integer): TItem;
procedure SetItems(Index: Integer; const Value: TItem);
function GetItemsi(Index: Integer): TItem;
procedure SetItemsi(Index: Integer; const Value: TItem);
function GetItemso(Index: Integer): TItem;
procedure SetItemso(Index: Integer; const Value: TItem);
public
procedure AddItem(OID,IID,C,AB:integer);
function IFIID(ID:Integer):Integer;
function IFOID(OID:Integer):Integer;
property Items[Index: Integer]: TItem read GetItems write SetItems; default;
property ItemI[Index: Integer]: TItem read GetItemsi write SetItemsi;
property ItemO[Index: Integer]: TItem read GetItemso write SetItemso;
end;
Var NI:TItem;
implementation
{ TItemList }

procedure TItemList.AddItem(OID, IID, C,AB: integer);
Var NewItem:TItem;
begin
Try
if IFOID(OID)=-1 then Begin
NewItem:=TItem.Create;
NewItem.ID:=IID;
NewItem.OID:=OID;
NewItem.Count:=C;
NewItem.AugmentationBonus:=AB;
Add(NewItem);
End;
except on E : Exception do
ShowMessage('ОШИБКА TItemList.AddItem:'+E.ClassName+' ошибка: '+E.Message);
End;

end;

function TItemList.GetItems(Index: Integer): TItem;
begin
Result := TItem.Create;
Try
if Index<Count then Result := TItem(inherited GetItem(Index));
except on E : Exception do
ShowMessage('ОШИБКА TItemList.GetItems:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
procedure TItemList.SetItems(Index: Integer; const Value: TItem);
begin
Try
inherited SetItem(Index, Value);
except on E : Exception do
ShowMessage('ОШИБКА TItemList.SetItems:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

function TItemList.GetItemsi(Index: Integer): TItem;
begin
Result := NI;
Try
Index:=IFIID(Index);
if Index<>-1 then Result := TItem(inherited GetItem(Index));
except on E : Exception do
ShowMessage('ОШИБКА TItemList.GetItemsi:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

function TItemList.GetItemso(Index: Integer): TItem;
begin
Result := NI;
Try
Index:=IFOID(Index);
if Index<>-1 then Result := TItem(inherited GetItem(Index));
except on E : Exception do
ShowMessage('ОШИБКА TItemList.GetItemso:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

function TItemList.IFIID(ID: Integer): Integer;
var i:integer;
begin
Result:=-1;
Try
i:=0;
while (Result=-1) and (i<Count) do
if items[i].ID=ID then Result:=i else inc(i);
except on E : Exception do
ShowMessage('ОШИБКА TItemList.IFIID:'+E.ClassName+' ошибка: '+E.Message);
End;
end;



function TItemList.IFOID(OID: Integer): Integer;
var i:integer;
begin
Result:=-1;
Try
i:=0;
while (Result=-1) and (i<Count) do
if items[i].OID=OID then Result:=i else inc(i);
except on E : Exception do
ShowMessage('ОШИБКА TItemList.IFOID:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

procedure TItemList.SetItemsi(Index: Integer; const Value: TItem);
begin
Try
Index:=IFIID(Index);
if Index<>-1 then inherited SetItem(Index, Value);
except on E : Exception do
ShowMessage('ОШИБКА TItemList.SetItemsi:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
procedure TItemList.SetItemso(Index: Integer; const Value: TItem);
begin
Try
Index:=IFOID(Index);
if Index<>-1 then inherited SetItem(Index, Value);
except on E : Exception do
ShowMessage('ОШИБКА TItemList.SetItemsi:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

Begin
NI:=TItem.Create;
end.

library AUTOMP;

{$define RELEASE} // для совместимости с релизом пакетхака, при дебуге можно закоментировать

uses
SysUtils,
Windows,
Dialogs,
Classes,
Coding,
IniFiles,
Forms,
AAction in 'AAction.pas',
Unit2 in 'Unit2.pas',
MSBU in 'MSBU.pas',
TItems in 'TItems.pas',
TSkils in 'TSkils.pas',
TNpcs in 'TNpcs.pas',
Other_Func in 'Other_Func.pas',
MsbForm in 'MsbForm.pas' {Form2},
OtherTypes in 'OtherTypes.pas',
TChars in 'TChars.pas',
Augmentation in 'Augmentation.pas';

var {version} {revision}
min_ver_a: array[0..3] of Byte = ( 3,4,1, 46 );
min_ver: Integer absolute min_ver_a; // минимальная поддерживаемая версия программы
fcl:boolean = false;
MD:TMyDelay;
function GetPluginInfo(const ver: Integer): PChar; stdcall;
begin
if ver<min_ver then
Result:='Plugin к программе l2phx'+sLineBreak+
'Для версий 3.4.0+'+sLineBreak+
'У вас старая версия программы! Плагин не сможет корректно с ней работать!'
else
Result:='Plugin к программе l2phx'+sLineBreak+
'Для версий 3.4.0+'+sLineBreak+
'Авто CP HP MP';
end;

function SetStruct(const struct: TPluginStruct): Boolean; stdcall;
begin
ps:=struct;
Result:=True;
end;

procedure OnLoad; stdcall;
var i:integer;
begin
Try
User:=TUserList.Create;
for i := 0 to 9 do User.Add(TUser.create);

except on E : Exception do
ShowMessage('ОШИБКА OnLoad:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

procedure OnPacket(const cnt: Cardinal; const fromServer: Boolean; var pck: TPacket); stdcall;
Var i:integer;
s:string;
begin
Try

if (pck.size<3) or (fcl) or (user[cnt]=nil) then exit;
ppck:=@pck;

with user[cnt] do Begin
inc(Bussi);
//----------------------------------------------------------------------------
if (ps.Threads[cnt].Name<>'') and (not user[cnt].Online) then Begin
user[cnt].Init(ps.Threads[cnt].Name);
Form2.Ncr(cnt);
End;
//----------------------------------------------------------Пакети от клиента---
if not FromServer then Begin
if (pck.id=$D0) and (ps.ReadHEx(pck,3)=68) then Begin//----------------------------------RequestRefine---
SetAgValue(cnt,ps.ReadHEx(pck,3),ps.ReadDEx(pck,5) ,ps.ReadDEx(pck,9),ps.ReadDEx(pck,13),ps.ReadDEx(p ck,17));
End;
if pck.id=$5F then Begin//-----------------------------------------Enchat---
//encid:=ps.ReadDEx(pck,3);
//pck.size:=2;
End;
if pck.id=$49 then Begin
s:=ps.ReadSEx(pck,3);
if pos(s,'ago,pgo,sbgo,pbgo,abgo,sck,asgo,sl,srk,mtck ,mtt,rgo,rstop,rp,gid,np,sbs,ag,ka')<>0 then pck.size:=2; // не пропускаем пакет

if s='ago' then User[cnt].OnAutoAtack:=true;
if s='asgo' then User[cnt].OnAutoAssist:=true;
if s='pgo' then User[cnt].OnAutoPickUp:=true;
if s='sbgo' then User[cnt].OnselfBaf:=true;
if s='pbgo' then User[cnt].OnPartyBaf:=true;
if s='abgo' then User[cnt].OnAutoBaf:=true;
if s='da' then MA.SetAction(0,'0=DLGSEL(talk_select)');
if s='sbs' then User[cnt].OnSBS:=True;
if s='np' then User[cnt].isInMTP:=false;

if s='ag' then Begin
sts(cnt,'D0 44 00'+anti4HEX(IList.Itemi[6369].OID)+anti4HEX(IList.Itemi[8732].OID)+anti4HEX(IList.Itemi[2131].OID)+'19 00 00 00');
End;
if s='mtt' then Begin
User[cnt].OnAutoMTT:=true;
say(cnt,'OnAutoMTT On');
End;
if s='gid' then Begin
say(cnt,'NpcID: '+inttostr(NpcList.Itemi[CurentT.ID].NpcID));
End;
if s='rgo' then User[cnt].RecordTreck:=true;
if s='rp' then Treck.AddPoint(x,y,z);
if s='rstop' then Begin
User[cnt].RecordTreck:=False;
User[cnt].Treck.SaveToFile(GetCurrentDir+'\Treks\'+User[cnt].Name+'.trk');
End;

if s='sck' then Begin
CurentCK.x:=User[cnt].x;
CurentCK.y:=User[cnt].y;
CurentCK.z:=User[cnt].z;
NpcList.SetXYZ(User[cnt].x,User[cnt].y,User[cnt].z,True);
say(cnt,'Центр кача установлен');
End;
if s='mtck' then Begin
with User[cnt].CurentCK do MoveToPoint(cnt,x,y,z);
say(cnt,'Идём к точке кача');
End;
if s='srk' then Begin
if User[cnt].CurentCK.x<>0 then User[cnt].rk:=ras(User[cnt].CurentCK.x,User[cnt].CurentCK.y,User[cnt].x,User[cnt].y);
say(cnt,'Радиус кача - '+inttostr(User[cnt].rk));
End;
if s='sl' then Begin
if CurentT.ID<>0 then Lider.ID:=CurentT.ID;
if Lider.ID<>0 then OnMoveToLiader:=True;
say(cnt,'Лидер выбран');
End;
End;

if(pck.id=$23) and (pos(ps.ReadSEx(pck,3),'sbs,np,mtt,p4,sa,ag,ka')<>0) then Begin
ByPass(cnt,ps.ReadSEx(pck,3));
pck.size:=2; // не пропускаем пакет
End;
//------------------------------------------------------RequestSocialAction---
if(pck.id=$34)then Begin
if ps.ReadDEx(pck,3)=6 then Begin // Yes
pck.size:=2;// не пропускаем пакет
//Form2.Visible:=true;
ShowInfo(cnt);
End;
if ps.ReadDEx(pck,3)=5 then Begin // No
pck.size:=2;// не пропускаем пакет
Form2.Visible:=false;
End;
if ps.ReadDEx(pck,3)=11 then Begin // Aplaus
pck.size:=2;// не пропускаем пакет
End;
End;
//-------------------------------------------------------ValidatePosition---
if pck.id=$59 then
ValidatePosition(cnt,ps.ReadDEx(pck,3),ps.ReadDEx( pck,7),ps.ReadDEx(pck,11));
//--------------------------------------------------------------------------
if pck.id=$0f then StopMoveTT(cnt);//--------------MoveBackwardToLocation---
if pck.id=$48 then StopMoveTT(cnt);//----------------RequestTargetCanceld---
//--------------------------------------------------------------------------
End;
//----------------------------------------------------------------------------
//------------------------------------------------------------------------------
//----------------------------------------------------------Пакети от сервера---
if FromServer then Begin

if (pck.id=$f3) and (ps.ReadDEx(pck,3)=1510) and (ps.ReadSEx(pck,15)='M002') then sts(cnt,'C6E605000001000000'+anti4HEX(User[cnt].ObjectID));
if ((pck.id=$2f) or (pck.id=$27)) and (ObjectID=0) then sts(cnt,'14');
//---------------------------------------------------------------UserInfo---
if pck.id=$32 then Begin
i:=23+(Length(ps.ReadSEx(pck,23))*2)+2;
i:=i+508+(Length(ps.ReadSEx(pck,i+508))*2)+2;
UserInfo(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck,7),p s.ReadDEx(pck,11),ps.ReadDEx(pck,19),ps.ReadDEx(pc k,i+53),ps.ReadSEx(pck,23));
RHID:=ps.ReadDEx(pck,(133+(length(ps.ReadSEx(pck,2 3))*2)));
LHID:=ps.ReadDEx(pck,(137+(length(ps.ReadSEx(pck,2 3))*2)));
End;
//---------------------------------------------------------------CharInfo---
if pck.id=$31 then Begin
i:=23+(Length(ps.ReadSEx(pck,23))*2)+2;
i:=i+272+(Length(ps.ReadSEx(pck,i+272))*2)+2;
CharInfo(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck,7),p s.ReadDEx(pck,11),ps.ReadDEx(pck,19),ps.ReadDEx(pc k,i+41),ps.ReadDEx(pck,i),ps.ReadSEx(pck,23));
//say(cnt,ps.ReadSEx(pck,23)+' - '+inttostr(ps.ReadDEx(pck,i))); 1435
End;
//----------------------------------------------------------------PetInfo---
if (pck.id=$B2) or (pck.id=$B6) then Begin
Pet.stype:=ps.ReadDEx(pck,3);
Pet.ID:=ps.ReadDEx(pck,7);
//if ps.ReadCEx(pck,125)=1 then user[cnt].Pet.isInCombat:=true else user[cnt].Pet.isInCombat:=false;
End;
//--------------------------------------------------------PetStatusUpdate---
if pck.id=$B6 then Begin
Pet.ID:=ps.ReadDEx(pck,7);
i:=23+(Length(ps.ReadSEx(pck,23))*2)+2;
Pet.HP:=ps.ReadDEx(pck,i+8);
Pet.MaxHP:=ps.ReadDEx(pck,i+12);
if (Pet.HP<(Pet.MaxHP-500)) and (Pet.HPC<>0)
and (GetTickCount-Pet.LTU>15000) then Begin
sts(cnt,'94'+anti4HEX(Pet.HPID));
Pet.LTU:=GetTickCount;
End;
//say(cnt,inttostr(user[cnt].Pet.HP)+'\'+inttostr(user[cnt].Pet.MaxHP));
End;
//-----------------------------------------------------PetInventoryUpdate---
if pck.id=$B4 then Begin
for i:=0 to ps.ReadHEx(pck,3)-1 do Begin
if ps.ReadDEx(pck,13+i*58)=1539 then Begin
Pet.HPID:=ps.ReadDEx(pck,9+i*58);
Pet.HPC:=ps.ReadDEx(pck,17+i*58);
End;
if (ps.ReadDEx(pck,13+i*58)=9668) and (ps.ReadDEx(pck,17+i*58)<20) then Begin
say(cnt,inttostr(ps.ReadDEx(pck,17+i*58))+' Мало еди у питомца!!!');
sts(cnt,'56130000000000000000');
End;

End;
End;
//-------------(CID,Invid,id,x,y,z:integer)----------------------DropItem---
if pck.id=$16 then
DropItem(cnt,ps.ReadDEx(pck,11),ps.ReadDEx(pck,7), ps.ReadDEx(pck,15),ps.ReadDEx(pck,19),ps.ReadDEx(p ck,23));
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
if (pck.id=$05) then DropItem(cnt,ps.ReadDEx(pck,7),ps.ReadDEx(pck,3),p s.ReadDEx(pck,11),ps.ReadDEx(pck,15),ps.ReadDEx(pc k,19));
//--------------------------------------------------------------------------

//---------------------------------------------------------------ItemList---
if (pck.id=$11) then //IL(CID,OID,IID,C,n:integer);
for i:=0 to ps.ReadHEx(pck,5)-1 do
IL(cnt,ps.ReadDEx(pck,9+i*72),ps.ReadDEx(pck,13+i* 72),ps.ReadDEx(pck,21+i*72),ps.ReadDEx(pck,39+i*72 ),i);
//--------------------------------------------------------------------------
//--------------------------------------------------------InventoryUpdate---
if (pck.id=$21) Then //InventoryUpdate(CID,CH,OID,IID,C:integer);
for i:=0 to ps.ReadHEx(pck,3)-1 do
InventoryUpdate(cnt,ps.ReadHEx(pck,5+(i*74)),ps.Re adDEx(pck,9+(i*74)),ps.ReadDEx(pck,13+(i*74)),ps.R eadDEx(pck,21+(i*74)),ps.ReadDEx(pck,39+(i*74)));
//--------------------------------------------------------------------------
//----------------------------------------------------------SystemMessage---
if pck.id=$62 then Begin
if (ps.ReadDEx(pck,3)=1405) or ((ps.ReadDEx(pck,3)=48) and (ps.ReadDEx(pck,15)=5592)) then IsCPUse:=false; //---------------------------CP restore---
if (ps.ReadDEx(pck,3)=936) and (ps.ReadDEx(pck,15)=5592) then IsCPUse:=True;

if (ps.ReadDEx(pck,3)=44) then Begin //Крит
//sts(cnt,'5F'+anti4HEX(encid));
End;
if (ps.ReadDEx(pck,3)=46) and (ps.ReadDEx(pck,15)=MCS) then Begin
CurentT.CurseTime:=GetTickCount;
CurentT.isInCurse:=True;
End;
if (ps.ReadDEx(pck,3)=139) and (ps.ReadDEx(pck,31)= MCS) then CurentT.isInCurse:=False;
if (ps.ReadDEx(pck,3)=46) and (ps.ReadDEx(pck,15)= 42) then isInSweep:=False;
if (ps.ReadDEx(pck,3)=612) or (ps.ReadDEx(pck,3)=357) then CurentT.spoiled:=true;

if (ps.ReadDEx(pck,3)=92)and(ps.ReadDEx(pck,15)=20320 ) then IsMPUse:=false;//20320
if (ps.ReadDEx(pck,3)=92)and(ps.ReadDEx(pck,15)=20370 ) then IsMPUse:=false;//20370
if (ps.ReadDEx(pck,3)=92)and(ps.ReadDEx(pck,15)=2037) then IsHPUse:=false; //2037
if (ps.ReadDEx(pck,3)=92)and(ps.ReadDEx(pck,15)=2035) then UseITEm(cnt,1375);
if (ps.ReadDEx(pck,3)=92)and(ps.ReadDEx(pck,15)=2032) then IsHPUse:=false; //2032
if (ps.ReadDEx(pck,3)=92)and(ps.ReadDEx(pck,15)=2031) then IsHPUse:=false; //2031
if (ps.ReadDEx(pck,3)=92)and(ps.ReadDEx(pck,15)=4072) then UnHold(cnt); //2031
if (ps.ReadDEx(pck,3)=22) or (ps.ReadDEx(pck,3)=181) then Begin //(22) цель слишком далеко (181) цель не видно
INKT:=false;
isInCombat:=false;
//sts(cnt,'84',false);//LeaveWorld
if not MD.Active then sts(cnt,'57');//RequestRestart
MD.SLTU(500);
End;
End;
//--------------------------------------------------------------------------
//-----------------------------------------------------------StatusUpdate---
if pck.id=$18 then
for i:=0 to ps.ReadDEx(pck,7)-1 do
StatsUpdate(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck,1 1+i*8),ps.ReadDEx(pck,15+i*8));
//--------------------------------------------------------------------------
//-----------------------------------------------------------PartySpelled---
if pck.id=$F4 then
for i:=0 to ps.ReadDEx(pck,11)-1 do
PartySpelled(cnt,ps.ReadDEx(pck,7),ps.ReadDEx(pck, 15+i*10),ps.ReadDEx(pck,21+i*10));
//--------------------------------------------------------------------------
//----------------------------------------------PartySmallWindowDeleteAll---
if pck.id=$50 then PartyList.Clear;
//-------------------------------------------------PartySmallWindowDelete---
if pck.id=$51 then PartyList.DelChar(ps.ReadDEx(pck,3));
//-------------------------------------------------PartySmallWindowUpdate---
if pck.id=$52 then Begin
i:=Length(ps.ReadSEx(pck,7))*2;
PartySWUpdate(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck ,9+i),ps.ReadDEx(pck,13+i)
,ps.ReadDEx(pck,17+i),ps.ReadDEx(pck,21+i),ps.Read DEx(pck,25+i)
,ps.ReadDEx(pck,29+i),ps.ReadDEx(pck,33+i),ps.Read DEx(pck,37+i),ps.ReadSEx(pck,7));
End;
//--------------------------------------------------------------------------
//-------------------------------------------------ExPartyPetWindowUpdate---
if (pck.id=$FE) and (ps.ReadHEx(pck,3)=25) then Begin
i:=Length(ps.ReadSEx(pck,21))*2;
PartySWUpdate(cnt,ps.ReadDEx(pck,5),0,0
,ps.ReadDEx(pck,23+i),ps.ReadDEx(pck,27+i),ps.Read DEx(pck,31+i)
,ps.ReadDEx(pck,35+i),ps.ReadDEx(pck,39+i),0,ps.Re adSEx(pck,21));
End;
//--------------------------------------------------------------------------
//----------------------------------------------------PartyMemberPosition---
if pck.id=$BA then for i:=0 to ps.ReadDEx(pck,3)-1 do
PartyMemberPosition(cnt,ps.ReadDEx(pck,7+i*16),ps. ReadDEx(pck,11+i*16),ps.ReadDEx(pck,15+i*16),ps.Re adDEx(pck,19+i*16));
//--------------------------------------------------------------------------
//---------------------------------------------------------------SkilList---
if (pck.id=$5f) and (User[cnt].Name<>'') then
for i:=0 to ps.ReadDEx(pck,3)-1 do
if ((ps.ReadDEx(pck,7+(i*13)))=0) and (User[cnt].IgnorList.IndexOfName(inttostr(ps.ReadDEx(pck,15+ (i*13))))=-1) then
User[cnt].SkilList.ADDSkil(sid.Values[inttostr(ps.ReadDEx(pck,15+(i*13)))],ps.ReadDEx(pck,15+(i*13)));
//--------------------------------------------------------------------------
//----------------------------------------------------------MagicSkillUse---
if pck.id=$48 then MagicSkillUse(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck ,7),ps.ReadDEx(pck,11),(ps.ReadDEx(pck,23))); //ps.ReadDEx(pck,19)

//---------------------------------------------------AbnormalStatusUpdate---
if (pck.id=$85)and (Name<>'') then
for i:=0 to ps.ReadHEx(pck,3)-1 do
ASUpdate(cnt,ps.ReadDEx(pck,5+i*10),ps.ReadDEx(pck ,11+i*10));
//--------------------------------------------------------------------------
if pck.id=$49 then Unkast(cnt,ps.ReadDEx(pck,3));//----MagicSkillCanceled---
if pck.id=$54 then Unkast(cnt,ps.ReadDEx(pck,3));//----MagicSkillLaunched---
//--------------------------------------------------------------------------
if pck.id=$B9 then MyT(cnt,ps.ReadDEx(pck,3));//---------MyTargetSelected---
//---------------------------------------------------------TargetSelected---
if pck.id=$23 then TargetSelected(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pc k,7));
//--------------------------------------------------------------------------
if pck.id=$24 then UnTarget(cnt,ps.ReadDEx(pck,3));//------Потеря таргета---

//------------------------------------------------Обработка появления Npc---
if (pck.id=$0C) and (ps.ReadCEx(pck,122)=0) then
NpcInfo(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck,7),ps .ReadDEx(pck,11),ps.ReadCEx(pck,122),ps.ReadDEx(pc k,15),ps.ReadDEx(pck,19),ps.ReadDEx(pck,23));
//---------------------------------------------------------MoveToLocation---
if pck.id=$2F then
MTL(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck,7),ps.Rea dDEx(pck,11),ps.ReadDEx(pck,15));
//-------------------------------------------------------ValidateLocation---
if pck.id=$79 then
MTL(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck,7),ps.Rea dDEx(pck,11),ps.ReadDEx(pck,15));
//-------------------------------------------------------------MoveToPawn---
if pck.id=$72 then
MTL(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck,15),ps.Re adDEx(pck,19),ps.ReadDEx(pck,23),ps.ReadDEx(pck,7) ,true);
//--------------------------------------------------------------------------
if pck.id=$08 then DelObj(cnt,ps.ReadDEx(pck,3));//-------Удаляем обьєкти---
if pck.id=$00 then Die(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck,23));//---Die---
//--------------------------------------------------------------------------
//-----------------------------------------------------------------Attack---
if pck.id=$33 then
Attack(cnt,ps.ReadDEx(pck,3),ps.ReadDEx(pck,7),ps. ReadDEx(pck,16),ps.ReadDEx(pck,20));
//--------------------------------------------------------------------------

//if pck.id=$71 then RR(cnt);//-------------------------------------restart---
if pck.id=$84 then RR(cnt);//--------------------------------------logaut---
//if pck.id=$1f then ActionFailed(cnt);//----------------------ActionFailed---

end;
dec(User[cnt].Bussi);
End;
except on E : Exception do
ShowMessage('ОШИБКА OnPacket:'+inttostr(pck.id)+'--'+inttostr(cnt)+'--'+E.ClassName+' ошибка: '+E.Message);
End;
end;

// Необязательно вызываемая функция. (может отсутствовать в плагине)
// Вызывается при выгрузке плагине
procedure OnFree; stdcall;
var i:integer;
begin
Try
fcl:=true;

//Form2.Free;
//sid.Free;
//itid.Free;
//npid.Free;
for i := 0 to 9 do while User[i].Bussi<>0 do;
//User.Clear;
//User.Destroy;
User.Free;
//
//if User<>nil then
except on E : Exception do
ShowMessage('ОШИБКА OnFree:'+E.ClassName+' ошибка: '+E.Message);
End;
end;


exports
GetPluginInfo,
OnPacket,
OnLoad,
SetStruct,
OnFree;
begin
Try Begin
Form2:=TForm2.Create(application);
//Form2.Visible:=false;
End;
except on E : Exception do
ShowMessage('код 1:ОШИБКА ИНИЦИАЛИЗАЦИИ ДАННЫХ!!! '+E.ClassName+' ошибка: '+E.Message);
End;
end.

Name4Me
22.04.2009, 00:16
unit Unit2;

interface

uses SysUtils,Dialogs,Classes,Windows,Variants;
procedure UserInfo(cid,sx,sy,sz,OID,ClID:integer;Nm:string);
procedure CharInfo(cid,x,y,z,OID,ClasID,ClanID:integer;Nm:st ring);
procedure NpcInfo(CID,OID,NID,isa,inc,X,Y,Z:integer);
procedure ValidatePosition(CID,mx,my,mz:integer);
procedure MTL(CID,OID,sx,sy,sz:integer;TAR:integer=0;f:boole an = false);
procedure AA(CID:integer);
procedure MyT(CID,TID:integer);
procedure TargetSelected(CID,OID,TID:integer);
procedure UnTarget(CID,OID:integer);
procedure ByPass(CID:integer;command:string);
procedure PartySWUpdate(CID,OID,CP,MCP,HP,MHP,MP,MMP,Lvl,CLI D:integer;nm:string);
procedure PartyMemberPosition(CID,OID,x,y,z:integer);
procedure PartySpelled(CID,OID,skid,dur:integer);
procedure ASUpdate(cid,skid,Duration:integer);
procedure MagicSkillUse(cid,OID,TID,skid,delay:integer);
procedure StatsUpdate(cid,OID,id,Value:integer);
//procedure RR(CID:integer);
procedure Attack(CID,ATK,TAR,x,y:integer);
procedure DropItem(CID,Invid,id,x,y,z:integer);
procedure IL(CID,OID,IID,C,AB,n:integer);
procedure InventoryUpdate(CID,CH,OID,IID,C,AB:integer);
procedure DelObj(CID,OID:integer);
procedure Die(CID,OID,sw:integer);
procedure Unkast(CID,OID:integer);
procedure RR(CID:integer);
implementation
uses AAction,msbu,msbform,Other_Func,Augmentation;

//---------------------------------------------------------------Инфа о чарах---
procedure UserInfo(cid,sx,sy,sz,OID,ClID:integer;Nm:string);
begin
Try
//if User[CID]=nil then User[CID]:=TUser.create(Nm);
with User[CID] do Begin
if (ClassID<>ClID) or (Name<>Nm) then begin
Save;
Form2.DN(CID);
say(ClID,'ClassID '+inttostr(ClID));
ClassID:=ClID;
init(Nm);
Form2.Ncr(CID);
end;

ObjectID:=OID;
x:=sx;
y:=sy;
z:=sz;
Name:=nm;
NpcList.SetXYZ(x,y,z);
End;


//ShowInfo(cid);

except on E : Exception do
ShowMessage('ОШИБКА UserInfo:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
//------------------------------------------------------------------------------
//---------------------------------------------------------------Инфа о чарах---
procedure CharInfo(cid,x,y,z,OID,ClasID,ClanID:integer;Nm:st ring);
begin
Try
user[CID].CharList.AddChar(x,y,z,OID,ClasID,ClanID,Nm);
//if (ClasID=116) or(ClasID=97) or (ClasID=16)then Say(cid,'!!!');///ShowCharInfo(cid);
except on E : Exception do
ShowMessage('ОШИБКА CharInfo:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
//------------------------------------------------------------------------------

//----------------------------------------------------Обработка появления Npc---
procedure NpcInfo(CID,OID,NID,isa,inc,X,Y,Z:integer);
var ni:integer;
begin
Try
ni:=nid-1000000;
if npid.Values<>'' then User[cid].NpcList.ADDNpc(OID,ni,isa,X,Y,Z,npid.Values[inttostr(ni)])
else User[cid].NpcList.ADDNpc(OID,ni,isa,X,Y,Z,'NoName');
except on E : Exception do
ShowMessage('ОШИБКА NpcInfo:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//-----------------------------------------------------------ValidatePosition---
procedure ValidatePosition(CID,mx,my,mz:integer);
begin
Try

with User[CID] do begin
x:=mx;
y:=my;
z:=mz; //say(CID,'CID'+inttostr(CID)+'/'+inttostr(User[CID].CID));
NpcList.SetXYZ(mx,my,mz);
if isInMTP and (ras(mx,my,MovePoint.x,MovePoint.y)<180) and not OnSBS then Begin
isInMTP:=false;
//MoveTT(CID);
End;
if (RecordTreck) and (Treck.size=0) then Treck.AddPoint(x,y,z);
if (RecordTreck) and (Treck.size>0) and (ras(x,y,Treck.Point[Treck.size].x,Treck.Point[Treck.size].y)>100) then Begin
Treck.AddPoint(x,y,z);
say(cid,'P['+inttostr(Treck.size)+']');
End;
End;
except on E : Exception do
ShowMessage('ОШИБКА MoveToLocation:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//---------------------------------------------------------Обработка движения---
procedure MTL(CID,OID,sx,sy,sz:integer;TAR:integer=0;f:boole an=false);
begin
Try
with User[CID] do begin
if (OID=Lider.ID) then Begin
Lider.x:=sx;
Lider.y:=sy;
Lider.z:=sz;
{if f and (OID=Lider.ID) then Begin
Lider.isInCombat:=true;
Lider.DTT:=TAR;
End;}

if (not f) or (f and (not isInCombat and not lider.isInCombat)) then move2(CID);
End;
NpcList.MTL(OID,sx,sy,sz);
PartyList.MTL(OID,sx,sy,sz,x,y);
end;
Form2.StUpdate(CID);
except on E : Exception do
ShowMessage('ОШИБКА MoveToLocation:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//-------------------------------------------------------------------------AA---
procedure AA(CID:integer);
begin
Try
with user[CID] do if hp>0 then begin
AutoBotleUse(CID);
if GetTickCount-CurentT.CurseTime>15000 then CurentT.isInCurse:=false;
if (mhs<>0) and (not INKT) then AutoHeal(CID);
if (not INPU) and (not INKT) and(SwepList.Count<>0) and (User[cid].ClassID=55) then Sweep(CID);
if (OnSelfBaf) and (not INPU) and (not INKT) and (not isInHeal) then SelfBaf(CID);
if (OnPartyBaf) and (not INPU) and (not INKT) and (not isInHeal) and (not isInSBaf) then PartyBaf(CID);
if (OnAutoBaf) and (not User[CID].INKT) then AutoBaf(CID);
if (OnAutoPickUp) and (not isInSweep) and (not INKT)and (not INPU) then PickUp(CID);
if (OnAutoAtack) and (not isInSweep) and (not isInMTP) and (not INKT) and (not INPU) then AAtack(CID);
if (OnAutoAssist) and (not isInSweep) and (not isInMTP) and (not INKT)and (not INPU) and (Lider.isInCombat) then AAssist(CID);
if (OnAutoMTT) and (not isInMTP) then MoveTT(CID);
//if (i=0) and (User[cid].CurentCK.x<>0) then STS(cid,'0f'+anti4HEX(User[cid].CurentCK.x)+anti4HEX(User[cid].CurentCK.y)+anti4HEX(User[cid].CurentCK.z)+'00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00');
Form2.StUpdate(CID);
//isInHeal:=false;
//isInSBaf:=false;
if (not MA.Count>0) and (not MA.isComplete) and (not INKT) then DoAction(CID);

end;


except on E : Exception do
ShowMessage('ОШИБКА AA:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//----------------------------------------------------------Получение таргета---
procedure MyT(CID,TID:integer);
begin
Try
User[CID].CurentT.id:=TID;
User[CID].CurentT.selected:=true;
except on E : Exception do
ShowMessage('ОШИБКА MyT:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
//------------------------------------------------------------------------------
//-------------------------------------------------------------TargetSelected---
procedure TargetSelected(CID,OID,TID:integer);
begin
Try

if (User[CID].Online) and (OID=User[CID].Lider.ID) then Begin
User[CID].Lider.DTT:=TID;
End;
except on E : Exception do
ShowMessage('ОШИБКА TargetSelected:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
//------------------------------------------------------------------------------


//-------------------------------------------------------------Потеря таргета---
procedure UnTarget(CID,OID:integer);
begin
Try
with User[CID] do begin
if OID=ObjectID then Begin
CurentT.id:=0;
CurentT.DTT:=0;
CurentT.MaxHP:=0;
CurentT.HP:=0;
CurentT.x:=0;
CurentT.y:=0;
CurentT.selected:=false;
CurentT.isInCurse:=false;
CurentT.spoiled:=false;

isInCombat:=false;
INPU:=false;
//say(CID,'UnTarget');
End;

if OID=Lider.ID then Begin
Lider.isInCombat:=false;
Lider.DTT:=0;
//say(CID,'UnTarget');
End;
end;
except on E : Exception do
ShowMessage('ОШИБКА UnTarget:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
//------------------------------------------------------------------------------

procedure ByPass(CID:integer;command:string);
var i:integer;
Begin
if command='sbs' then User[CID].OnSBS:=True;
if command='np' then User[CID].isInMTP:=false;
if command='p4' then User[CID].CurentPN:=4;
if command='ag' then Augment(CID);
if command='sa' then Begin
for i:= 1 to User[CID].Treck.size do begin
ShowMessage(User[CID].Treck.Point[i].alist);
End;
End;
if command='mtt' then Begin
User[CID].OnAutoMTT:=true;
say(CID,'OnAutoMTT On');
End;
//ShowInfo(CID);
End;
//------------------------------------------------------------------------------
//-----------------------------------------------------PartySmallWindowUpdate---
procedure PartySWUpdate(CID,OID,CP,MCP,HP,MHP,MP,MMP,Lvl,CLI D:integer;nm:string);
var i:integer;
Begin
try
with user[CID].PartyList do begin
i:=IFOID(OID);
if i=-1 then Begin
AddChar(0,0,0,OID,0,0,'');
i:=IFOID(OID);
End;
items[i].CP:=CP;
items[i].MaxCP:=MCP;
items[i].HP:=HP;
items[i].MaxHP:=MHP;
items[i].MP:=MP;
items[i].MaxMP:=MMP;
items[i].Lvl:=Lvl;
items[i].ClassID:=CLID;
items[i].Name:=nm;
items[i].Ch:=false;
Form2.StUpdate(CID);
end;
except on E : Exception do
ShowMessage('ОШИБКА PartySWUpdate:'+E.ClassName+' ошибка: '+E.Message);
End;
End;
//------------------------------------------------------------------------------
//--------------------------------------------------------PartyMemberPosition---
procedure PartyMemberPosition(CID,OID,x,y,z:integer);
var i:integer;
Begin
Try
with user[CID].PartyList do begin
i:=IFOID(OID);
if i=-1 then Begin
AddChar(0,0,0,OID,0,0,'');
i:=IFOID(OID);
End;
items[i].x:=x;
items[i].y:=y;
items[i].z:=z;
items[i].dist:=ras(x,y,user[CID].x,user[CID].y);
End;
except on E : Exception do
ShowMessage('ОШИБКА PartyMemberPosition:'+E.ClassName+' ошибка: '+E.Message);
End;
End;
//------------------------------------------------------------------------------
//---------------------------------------------------------------PartySpelled---
procedure PartySpelled(CID,OID,skid,dur:integer);
var i:integer;
Begin
Try
with user[CID].PartyList do begin
i:=IFOID(OID);
if i=-1 then Begin
AddChar(0,0,0,OID,0,0,'');
i:=IFOID(OID);
End;
items[i].Baffs.SLTU(skid,dur);
end;
except on E : Exception do
ShowMessage('ОШИБКА PartySpelled:'+E.ClassName+' ошибка: '+E.Message);
End;
End;
//------------------------------------------------------------------------------
//-------------------------------------------------------AbnormalStatusUpdate---
procedure ASUpdate(cid,skid,Duration:integer);
Begin
Try
User[cid].Baffs.SLTU(skid,Duration);
if (skid=4072) and (Duration>0) then User[cid].isInHold:=True;

except on E : Exception do
ShowMessage('ОШИБКА ASUpdate:'+User[cid].Name+'//'+E.ClassName+' ошибка: '+E.Message);
End;
End;
//------------------------------------------------------------------------------

//--------------------------------------------------------------MagicSkillUse---
procedure MagicSkillUse(cid,OID,TID,skid,delay:integer);
Begin
Try
with User[cid] do Begin
if (OID=ObjectID) and (SkilList.IFIID(skid)<>-1) then
SkilList.Itemi[skid].SetDelay(delay,GetTickCount);
if (skid<>42) and(OID=Lider.ID) and (TID<>Lider.ID) and (TID<>ObjectID) and (PartyList.IFOID(TID)=-1) then Begin
Lider.isInCombat:=true;
Lider.DTT:=TID;
End;
if (OID=ObjectID) and (TID<>ObjectID) and (skid=MAS) then isInCombat:=true;

End;
except on E : Exception do
ShowMessage('ОШИБКА MagicSkillUse:'+E.ClassName+' ошибка: '+E.Message);
End;
End;

//------------------------------------------------------------------------------



//----------------------------------------------------------------StatsUpdate---
procedure StatsUpdate(cid,OID,id,Value:integer);
begin
Try
with User[cid] do Begin
if OID=ObjectID then case id of
9: HP:=Value;
10: MaxHP:=Value;
33: CP:=Value;
34: MaxCP:=Value;
11: MP:=Value;
12: MaxMP:=Value;
end;
if OID=CurentT.ID then case id of
9: CurentT.HP:=Value;
10: CurentT.MaxHP:=Value;
end;
End;
except on E : Exception do
ShowMessage('ОШИБКА StatsUpdate:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
//------------------------------------------------------------------------------


//----------------------------------------------------обработка пакета атаки!---
procedure Attack(CID,ATK,TAR,x,y:integer);
begin
Try
with user[CID] do begin
if (ATK=ObjectID) then Begin
CurentT.ID:=TAR;
//INAA:=true;
//isInCombat:=true;
if (not CurentT.spoiled) and (ClassID=55) and (CharList.IFOID(TAR)=-1) then sts(cid,'39FE0000000000000000');
if (not CurentT.spoiled) and (ClassID=117) and (CharList.IFOID(TAR)=-1) then sts(cid,'395C0100000000000000');
if (Pet.ID<>0) and (not Pet.isInCombat) then Begin
Pet.isInCombat:=true;
//sts(cid,'56100000000000000000');
if Pet.stype=1 then sts(cid,'56160000000000000000');
End;
End;
if (ATK=user[CID].Lider.ID) then Begin
Lider.isInCombat:=true;
Lider.DTT:=TAR;
End;
if (ATList.IndexOf(inttostr(ATK))=-1) and (NpcList.IFOID(ATK)<>-1) and ((TAR=ObjectID) or (PartyList.IFOID(TAR)<>-1) or (ATK=ObjectID) or (PartyList.IFOID(ATK)<>-1) ) then Begin
ATList.Add(inttostr(ATK));
//if (WeaponOID<>0) and (RHID<>WeaponOID) then UseItem(CID,WeaponOID);
//if (MAS.ID<>0) and (MAS.Active) then MAS.Cust(CID);
//if (MDS.ID<>0) and (MDS.Active) then MDS.Cust(CID);
End;
End;
except on E : Exception do
ShowMessage('ОШИБКА Attack:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
//------------------------------------------------------------------------------

//-------------------------------------------------------------------DropItem---
procedure DropItem(CID,Invid,id,x,y,z:integer);
begin
Try
if ras(x,y,user[CID].x,user[CID].y)<400 then
user[CID].DropList.Add(inttostr(id));
except on E : Exception do
ShowMessage('ОШИБКА DropItem:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------

//-------------------------------------------------------------------ItemList---
procedure IL(CID,OID,IID,C,AB,n:integer);
begin
Try
if n=0 then user[CID].IList.Clear;
user[CID].IList.AddItem(OID,IID,C,AB);
except on E : Exception do
ShowMessage('ОШИБКА IL:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//------------------------------------------------------------InventoryUpdate---
procedure InventoryUpdate(CID,CH,OID,IID,C,AB:integer);
var i:integer;
begin
Try
with user[CID].IList do begin
i:=IFOID(OID);
if i<>-1 Then case ch of
3: Delete(i);
2: user[CID].IList[i].Count:=C;
End;
if ch=1 Then AddItem(OID,IID,C,AB);
if (IID=3949) and (c<=20) and (c>0) and (IFIID(5264)<>-1) then useitem(cid,5264);//Blessed Spiritshot: C Grade
if (IID=3950) and (c<=20) and (c>0) and (IFIID(5265)<>-1) then useitem(cid,5265);//Blessed Spiritshot: B Grade
if (IID=3951) and (c<=20) and (c>0) and (IFIID(5266)<>-1) then useitem(cid,5266);//Blessed Spiritshot: A Grade
if (IID=3952) and (c<=20) and (c>0) and (IFIID(5267)<>-1) then useitem(cid,5267);//Blessed Spiritshot: S Grade
if (IID=1464) and (c<=20) and (c>0) and (IFIID(5255)<>-1) then useitem(cid,5255);//Soulshot: C-grade
if (IID=1465) and (c<=20) and (c>0) and (IFIID(5253)<>-1) then useitem(cid,5253);//Soulshot: B-grade
if (IID=1466) and (c<=20) and (c>0) and (IFIID(5254)<>-1) then useitem(cid,5254);//Soulshot: A-grade
if (IID=1467) and (c<=20) and (c>0) and (IFIID(5255)<>-1) then useitem(cid,5255);//Soulshot: S-grade
end;
except on E : Exception do
ShowMessage('ОШИБКА InventoryUpdate:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------Die---
procedure Die(CID,OID,sw:integer);
begin
Try
with User[cid] do Begin
//DinoIsRaedy:=false;
if (sw=1) and ((ClassID=55) or (ClassID=117))then Begin
if ((CurentT.ID<>OID) or INKT or isInHold) and (ATList.IndexOf(inttostr(OID))<>-1) then SwepList.Add(inttostr(OID));
if (CurentT.ID=OID) and not INKT then Begin
INKT:=True;
SkilList.Itemi[42].Cust(Cid);
End;

End;
NpcList.DelNpc(OID);
if ATList.IndexOf(inttostr(OID))<>-1 then
ATList.Delete(ATList.IndexOf(inttostr(OID)));

if (CurentT.ID=OID) and ((sw<>1) or ((ClassID<>55) or (ClassID<>117))) then Begin
CurentT.isInCurse:=False;
CurentT.spoiled:=False;
Pet.isInCombat:=false;
isInCombat:=false;
INPU:=false;

End;
if Lider.DTT=OID then Begin
Lider.DTT:=0;
Lider.isInCombat:=False;
End;
if (OID=ObjectID) and (OnAutoOFF) then Begin
sts(CID,'7D00000000');
sts(CID,'84',false);//LeaveWorld
End;
End;
except on E : Exception do
ShowMessage('ОШИБКА DelObj:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//---------------------------------------------------------------------DelObj---
procedure DelObj(CID,OID:integer);
begin
Try
with User[CID] do Begin
if DropList.IndexOf(inttostr(OID))<>-1 then Begin
DropList.Delete(DropList.IndexOf(inttostr(OID)));
if CurentPUID=OID then INPU:=false;
End;
CharList.DelChar(OID);
NpcList.DelNpc(OID);
if ATList.IndexOf(inttostr(OID))<>-1 then
ATList.Delete(ATList.IndexOf(inttostr(OID)));
if SwepList.IndexOf(inttostr(OID))<>-1 then
SwepList.Delete(SwepList.IndexOf(inttostr(OID)));
if CurentT.ID=OID then Begin
CurentT.ID:=0;
CurentT.selected:=False;
CurentT.spoiled:=False;
CurentT.isInCurse:=False;
Pet.isInCombat:=false;
isInCombat:=false;
INPU:=false;

End;
End;
except on E : Exception do
ShowMessage('ОШИБКА DelObj:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//---------------------------------------------------------------------Unkast---
procedure Unkast(CID,OID:integer);
begin
Try
if User[CID].ObjectID=OID then Begin
User[CID].INKT:=False;
if not User[CID].OnAutoMTT then User[CID].isInMTP:=False;
End;

except on E : Exception do
ShowMessage('ОШИБКА Unkast:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
//------------------------------------------------------------------------------
procedure RR(CID:integer);
Begin
Try
User[CID].Save;
Form2.DN(CID);
User[CID].Online:=false;
except on E:Exception do
ShowMessage('RR'+E.ClassName+' ошибка: '+E.Message);
end;
end;
end.


[I]Добавлено через 1 минуту
unit TNpcs;

interface
Uses Contnrs,Dialogs,SysUtils,math,Other_Func;
Type
Position = Record
x,y,z:integer;
End;
TNpc = class
Public
ObjectID:integer;
NpcID,IsAttackable:integer;
NpcName:string;
Dist:integer;
x,y,z:integer;
end;

TNpcList = class(TObjectList)
private
us,ct:Position;
centre:boolean;
function GetItems(Index: Integer): TNpc;
procedure SetItems(Index: Integer; const Value: TNpc);
function GetItemsi(Index: Integer): TNpc;
procedure SetItemsi(Index: Integer; const Value: TNpc);
public
pol:Poligon;
function IFOID(OID:Integer):Integer;
function IFIID(IID:Integer):Integer;
function GetMinDist(minr:integer=9999): integer;
Procedure ADDNpc(OID,NID,isa,sx,sy,sz:Integer;Nm:string);
Procedure DelNpc(OID:Integer);
Procedure SetXYZ(sx,sy,sz:Integer;cn:boolean = false);
Procedure MTL(OID,sx,sy,sz:Integer);
property Items: TNpc read GetItems write SetItems; default;
property Itemi[Index: Integer]: TNpc read GetItemsi write SetItemsi;
end;
Function MyNPCSort(el1,el2:TNpc):integer;
implementation

Function MyNPCSort(el1,el2:TNpc):integer;
Begin
Result:=0;
Try
if ((el1.IsAttackable=0) and (el2.IsAttackable=0)) or
((el1.IsAttackable<>0) and (el2.IsAttackable<>0)) then
result:=ComparСeInteger(el1.Dist,el2.Dist);
if ((el1.IsAttackable=0) and (el2.IsAttackable<>0)) then result:=1;
if ((el1.IsAttackable<>0) and (el2.IsAttackable=0)) then result:=-1;
except on E : Exception do
ShowMessage('ОШИБКА MyNPCSort:'+E.ClassName+' ошибка: '+E.Message);
End;
End;

{ TNpcList }

procedure TNpcList.ADDNpc(OID, NID,isa, sx, sy, sz: Integer;Nm:string);
Var MyNpc:TNpc;
i:integer;
Begin
Try
i:=IFOID(OID);
if i=-1 then Begin
MyNpc:=TNpc.create;
MyNpc.ObjectID:=OID;
MyNpc.NpcID:=NID;
MyNpc.IsAttackable:=isa;
MyNpc.x:=sx;
MyNpc.y:=sy;
MyNpc.z:=sz;
MyNpc.NpcName:=nm;
MyNpc.Dist:=Ras(sx,sy,us.x,us.y);
Add(MyNpc);
End
else Begin
items[i].x:=sx;
items[i].y:=sy;
items[i].z:=sz;
items[i].Dist:=Ras(sx,sy,us.x,us.y);
End;
except on E : Exception do
ShowMessage('ОШИБКА TTNpcList.ADDNpc:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

procedure TNpcList.DelNpc(OID: Integer);
var i:integer;
begin
Try
i:=IFOID(OID);
if i<>-1 then Delete(i);
except on E : Exception do
ShowMessage('ОШИБКА TNpcList.DelNpc:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

function TNpcList.GetItems(Index: Integer): TNpc;
begin
Result:=nil;
Try
if (Index>-1)and(Index<Count) then Result := TNpc(inherited GetItem(Index));
except on E : Exception do
ShowMessage('ОШИБКА TNpcList.GetItems:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

function TNpcList.GetItemsi(Index: Integer): TNpc;
begin
Result := TNpc.Create;
Try
Index:=IFOID(Index);
if (Index>-1)and(Index<Count) then Result := TNpc(inherited GetItem(Index));
except on E : Exception do
ShowMessage('ОШИБКА TNpcList.GetItemsi:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

function TNpcList.IFIID(IID: Integer): Integer;
Var i:integer;
begin
Result:=-1;
Try
i:=0;
while (Result=-1) and (i<Count) do
if items[i].NpcID=IID then Result:=i else inc(i);
except on E : Exception do
ShowMessage('ОШИБКА TNpcList.IFIID:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

function TNpcList.IFOID(OID: Integer): Integer;
Var i:integer;
begin
Result:=-1;
Try
i:=0;
while (Result=-1) and (i<Count) do
if items[i].ObjectID=OID then Result:=i else inc(i);
except on E : Exception do
ShowMessage('ОШИБКА TNpcList.IFOID:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

procedure TNpcList.MTL(OID, sx, sy, sz: Integer);
begin
Try
with itemi[OID] do if ObjectID<>0 then begin
x:=sx;
y:=sy;
z:=sz;
Dist:=Ras(sx,sy,us.x,us.y);
end;
except on E : Exception do
ShowMessage('ОШИБКА TNpcList.MTL:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

procedure TNpcList.SetItems(Index: Integer; const Value: TNpc);
begin
Try
if (Index>-1)and(Index<Count) then inherited SetItem(Index, Value);
except on E : Exception do
ShowMessage('ОШИБКА TNpcList.SetItems:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

procedure TNpcList.SetItemsi(Index: Integer; const Value: TNpc);
begin
Try
Index:=IFOID(Index);
if (Index>-1)and(Index<Count) then inherited SetItem(Index, Value);
except on E : Exception do
ShowMessage('ОШИБКА TNpcList.SetItemsi:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

procedure TNpcList.SetXYZ(sx, sy, sz: Integer;cn:boolean = false);
var i:integer;
begin
Try
if not cn then Begin
us.x:=sx;
us.y:=sy;
us.z:=sz;
for i := 0 to Count - 1 do items[i].Dist:=Ras(items[i].x,items[i].y,us.x,us.y);
End else Begin
ct.x:=sx;
ct.y:=sy;
ct.z:=sz;
Centre:=true;
End;
except on E : Exception do
ShowMessage('ОШИБКА TNpcList.SetXYZ:'+E.ClassName+' ошибка: '+E.Message);
End;
end;
function TNpcList.GetMinDist(minr:integer=9999): integer;
var i:integer;
begin
Result:=0;
i:=0;
Try
sort(@MyNPCSort);
if count>0 Then while (result=0) and (i<Count-1) do with items[i] do begin
if (not centre) and (IsAttackable=1)
and (Dist<minr) and (abs(us.z-z)<=300) then Result:=ObjectID;
if centre and (IsAttackable=1)
and (Ras(x,y,ct.x,ct.y)<minr) and (abs(ct.z-z)<=300) then Result:=ObjectID;
inc(i);
end;
except on E : Exception do
ShowMessage('ОШИБКА TNpcList.SortByDist:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

end.


[I]Добавлено через 1 минуту
unit TSkils;

interface
Uses Windows,Dialogs,SysUtils,ExtCtrls,Contnrs;
Type
TSkil = class(TObject)
private
function Getp: Boolean;
Public
ReuseDelay:DWORD;
ID:integer;
Name: String;
Duration:integer;
LastTimeUsed:DWORD;
Procedure SetDelay(Delay,LTU:integer);
function Cust(CID:integer):Boolean;
property isActive:Boolean read Getp;
end;

TSkilList = class(TObjectList)
private
function GetItems(Index: Integer): TSkil;
procedure SetItems(Index: Integer; const Value: TSkil);
function GetItemsi(Index: Integer): TSkil;
procedure SetItemsi(Index: Integer; const Value: TSkil);
public
function IFIID(ID:Integer):Integer;
function IFName(Nm:String):Integer;
Procedure ADDSkil(SkilName:string;ID:Integer);
property Items: TSkil read GetItems write SetItems; default;
property Itemi[Index: Integer]: TSkil read GetItemsi write SetItemsi;
end;
Var NI:TSkil;
implementation
Uses AAction;
{ TSkil }
//----------------------------------------------------------------------TSkil---
function TSkil.Getp: Boolean;
begin
Result:=false;
Try
if (GetTickCount-LastTimeUsed)>=ReuseDelay then Result:=True;
except on E : Exception do
ShowMessage('ОШИБКА TSkil.Getp:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

Procedure TSkil.SetDelay(Delay,LTU:integer);
Begin
Try
LastTimeUsed:=LTU;
ReuseDelay:=Delay;
except on E : Exception do
ShowMessage('ОШИБКА TSkil.SetDelay:'+E.ClassName+' ошибка: '+E.Message);
End;
End;


function TSkil.Cust(CID:integer):boolean;
Begin
result:=false;
Try
if isActive then Begin
LastTimeUsed:=GetTickCount;
ReuseDelay:=1500;
MagicSU(CID,ID);
Result:=true;
End;
except on E : Exception do
ShowMessage('ОШИБКА TSkil.Cust:'+E.ClassName+' ошибка: '+E.Message);
End;
End;
//------------------------------------------------------------------------------
{ TSkilList }
//------------------------------------------------------------------TSkilList---
function TSkilList.GetItems(Index: Integer): TSkil;
begin
Result:=NI;
Try
if (Index>-1)and(Index<Count) then Result := TSkil(inherited GetItem(Index));
except on E : Exception do
ShowMessage('ОШИБКА TSkilList.GetItems:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

function TSkilList.GetItemsi(Index: Integer): TSkil;
begin
Result:=TSkil.Create;
Try
Index:=IFIID(Index);
if (Index>-1)and(Index<Count) then Result := TSkil(inherited GetItem(Index));
except on E : Exception do
ShowMessage('ОШИБКА TSkilList.GetItems:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

function TSkilList.IFIID(ID: Integer): Integer;
Var i:integer;
begin
Result:=-1;
Try
i:=0;
while (Result=-1) and (i<Count) do
if items[i].ID=ID then Result:=i else inc(i);
except on E : Exception do
ShowMessage('ОШИБКА TSkilList.IFIID:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

function TSkilList.IFName(Nm: String): Integer;
Var i:integer;
begin
Result:=-1;
Try
i:=0;
while (Result=-1) and (i<Count) do
if items[i].Name=Nm then Result:=i else inc(i);
except on E : Exception do
ShowMessage('ОШИБКА TSkilList.IFName:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

procedure TSkilList.SetItems(Index: Integer; const Value: TSkil);
begin
Try
if (Index>-1)and(Index<Count) then inherited SetItem(Index, Value);
except on E : Exception do
ShowMessage('ОШИБКА TSkilList.SetItems:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

procedure TSkilList.SetItemsi(Index: Integer; const Value: TSkil);
begin
Try
Index:=IFIID(Index);
if (Index>-1)and(Index<Count) then inherited SetItem(Index, Value);
except on E : Exception do
ShowMessage('ОШИБКА TSkilList.SetItems:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

Procedure TSkilList.ADDSkil(SkilName:string;ID:Integer);
Var MySkil:TSkil;
Begin
Try
if IFIID(ID)=-1 then Begin
MySkil:=TSkil.create;
MySkil.Name:=SkilName;
MySkil.ID:=ID;
Add(MySkil);
End;
except on E : Exception do
ShowMessage('ОШИБКА TSkilList.ADDSkil:'+E.ClassName+' ошибка: '+E.Message);
End;
End;
Begin
NI:=TSkil.Create;
end.


[I]Добавлено через 45 секунд
unit AAction;

interface
uses Coding, SysUtils,Dialogs,Classes,windows,ExtCtrls,unit2,Ot her_Func,OtherTypes;

function MoveToPoint(CID,mx,my,mz:integer):boolean;
function MoveTT(CID:integer):boolean;
function UseItem(CID,IID:integer):boolean;
function AutoBaf(CID:integer):boolean;
function Sweep(CID:integer):boolean;
procedure PickUp(cid:integer);
procedure ShowInfo(CID:integer);
procedure MagicSU(CID,MagicID:integer);
procedure AAtack(cid:integer);
procedure AAssist(cid:integer);
procedure PartyBaf(CID:integer);
procedure SelfBaf(CID:integer);
procedure AutoHeal(CID:integer);
Procedure AutoBotleUse(CID:integer);
procedure Move2(Cid:integer);
procedure STS(CID:integer;msg:string;F:boolean = true);
procedure Say(CID:integer;msg:string);
procedure DoAction(CID:integer);
Procedure StopMoveTT(CID:integer);
Procedure Fishing(CID:integer);
Procedure UnHold(CID:integer);
const
fish=1312; //ID fishing
pump=1313; //ID pumping
reel=1314; //ID reeling
//MP726=726; //mp маленькая банка iid-726
//HP
//FShotID=6540;
//WeaponID=5643;
//RoodID=6534;

//Green Colored Lure ID:6520 6519-6527
//Purple Colored Lure - High Grade ID:6524
//Yellow Colored Lure - High Grade ID:6527
//Triton Pole ID:6534
Var
ppck: PPacket;
ps: TPluginStruct;


implementation
uses msbu,MsbForm;
Procedure UnHold(CID:integer);
Begin
with user[CID] do Begin
isInHold:=false;
IsHPUse:=false;
IsMPUse:=false;
isInCombat:=false;
INPU:=false;
INKT:=false;
End;
End;

Procedure Fishing(CID:integer);
Begin
if user[CID]<>nil then with user[CID] do Begin
if (RoodOID<>0) and (RHID<>RoodOID) then UseItem(CID,RoodOID);
if (CurenLureOID<>0) and (LHID<>CurenLureOID) then UseItem(CID,CurenLureOID);

End;
End;
Procedure StopMoveTT(CID:integer);
Begin
if user[CID]<>nil then with user[CID] do Begin
OnAutoMTT:=False;
isInMTP:=false;
End;
End;
procedure DoAction(CID:integer);
var
al:TStrings;
id,oid:integer;
fl:boolean;
s,buf:string;
Begin
Try
with user[CID] do if (MA.AList<>'') and (MA.md.Active) then begin
fl:=false;
oid:=0;
al:=TstringList.Create;
al.Text:=MA.AList; //NPCDLG(Jeremy[ID=31521])
if pos('NPCDLG',al[MA.CA])<>0 then Begin
id:=strtoint(copy(al[MA.CA],pos('(',al[MA.CA])+1,pos(')',al[MA.CA])-pos('(',al[MA.CA])-1));
id:=NpcList.IFIID(id);
if id<>-1 then oid:=NpcList[id].ObjectID;
if (oid<>0) and (CurentT.ID<>oid) then Begin
STS(cid,'1f'+anti4HEX(oid)+'0000000000000000000000 0000');
MA.md.SLTU(1000);
End;
if (oid<>0) and (CurentT.ID=oid) then Begin
STS(cid,'1f'+anti4HEX(oid)+'0000000000000000000000 0000');
fl:=true;
MA.md.SLTU(1000);
End;
if oid=0 then MA.isComplete:=true;

End;
if pos('DLGSEL',al[MA.CA])<>0 then Begin
s:=copy(al[MA.CA],pos('(',al[MA.CA])+1,pos(')',al[MA.CA])-pos('(',al[MA.CA])-1);
with ps do begin
buf:=HexToString('23');
WriteS(buf,s);
SendPckStr(buf,CID,True);
end;
fl:=true;
MA.md.SLTU(1000);
End;
if pos('UseSkill',al[MA.CA])<>0 then Begin
s:=copy(al[MA.CA],pos('(',al[MA.CA])+1,pos(')',al[MA.CA])-pos('(',al[MA.CA])-1);
if SkilList.Itemi[strtoint(s)].Cust(CID) then Begin
INKT:=True;
fl:=true;
MA.md.SLTU(200);
End;
End;
if pos('USEITEM',al[MA.CA])<>0 then Begin //USEITEM(Greater Haste Potion[ID=1374])
id:=strtoint(copy(al[MA.CA],pos('(',al[MA.CA])+1,pos(')',al[MA.CA])-pos('(',al[MA.CA])-1));

if (id=1374) and (Baffs.Itemi[2034].Duration<=300) then UseItem(CID,id);

if id<>1374 then UseItem(CID,id);
fl:=true;
MA.md.SLTU(200);
End;
if pos('RESTART',al[MA.CA])<>0 then Begin //USEITEM(Greater Haste Potion[ID=1374])
CurentPN:=0;
fl:=true;
End;
if fl then inc(MA.CA);
if MA.CA=MA.Count then MA.isComplete:=true;
al.Free;
End;


except on E : Exception do
ShowMessage('ОШИБКА DoAction:'+E.ClassName+' ошибка: '+E.Message);
end;
End;
//---------------------------------------------------------------AutoBotleUse---
Procedure AutoBotleUse(CID:integer);
Begin
Try
with User[CID] do begin
if (HP>0) and (MaxCP>0) and (MaxCP-CP>100) and (not IsCPUse) and (useitem(cid,CPiID)) then IsCPUse:=True;
if (HP>0) and (MaxHP>0) and (HP/MaxHP<0.8) and (not IsHPUse) and (useitem(cid,HPiID)) then IsHPUse:=True;
if (HP>0) and (MaxMP>0) and (MP/MaxMP<0.8) and (not IsMPUse) and (useitem(cid,MPiID)) then IsMPUse:=True;
end;
except on E : Exception do
ShowMessage('ОШИБКА AutoBotleUse:'+E.ClassName+' ошибка: '+E.Message);
end;
End;
//------------------------------------------------------------------------------
//----------------------------------------------------------------MoveToPoint---
function MoveToPoint(CID,mx,my,mz:integer):boolean;
Begin
Result:=false;
Try
with User[CID] do if ras(x,y,mx,my)>20 then begin
isInMTP:=true;
MovePoint.x:=mx;
MovePoint.y:=my;
MovePoint.z:=mz;
STS(cid,'0f'+anti4HEX(mx)+anti4HEX(my)+anti4HEX(mz )+'00000000000000000000000001000000');
Result:=true;
end;
except on E : Exception do
ShowMessage('ОШИБКА MoveToPoint:'+E.ClassName+' ошибка: '+E.Message);
end;
End;
//------------------------------------------------------------------------------
//----------------------------------------------------------------MoveToPoint---
function MoveTT(CID:integer):boolean;
Begin
Result:=false;
Try

with User[CID] do begin
OnAutoOFF:=true;
//say(CID,'Curent point: '+inttostr(CurentPN));
if (Treck.size>0) and (CurentPN<=Treck.size) then Begin
if (Treck.Point[CurentPN].alist<>'') and (ma.PN<>CurentPN) then
ma.SetAction(CurentPN,Treck.Point[CurentPN].alist);
if ((Treck.Point[CurentPN].alist='') or (ma.isComplete)) and (CurentPN<Treck.size) then Begin
inc(CurentPN);
MoveToPoint(CID,Treck.Point[CurentPN].x,Treck.Point[CurentPN].y,Treck.Point[CurentPN].z);
End;
End;
end;
except on E : Exception do
ShowMessage('ОШИБКА MoveToPoint:'+E.ClassName+' ошибка: '+E.Message);
end;
End;
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------Swep---
function Sweep(CID:integer):boolean;
Begin
Result:=false;
Try
with User[CID] do if (SwepList.Count>0) and ((User[cid].ClassID=55) or (ClassID=117)) then begin
if (CurentT.ID<>strtoint(SwepList[0])) and (not CurentT.selected) then Begin
isInSweep:=true;
CurentT.ID:=strtoint(SwepList[0]);
STS(cid,'1f'+anti4HEX(CurentT.ID)+'000000000000000 00000000001');
End;
if (CurentT.ID=strtoint(SwepList[0])) and CurentT.selected then Begin
INKT:=True;
SkilList.Itemi[42].Cust(Cid);
SwepList.Delete(0);
End;
Result:=true;
end;
except on E : Exception do
ShowMessage('ОШИБКА Swep:'+E.ClassName+' ошибка: '+E.Message);
end;
End;
//------------------------------------------------------------------------------
//----------------------------------------------------------------Авто PickUp---
procedure PickUp(cid:integer);
begin
Try
with User[cid] do if (DropList.Count<>0) then Begin
INPU:=true;
CurentPUID:=strtoint(DropList[DropList.Count-1]);
STS(cid,'1f'+anti4HEX(CurentPUID)+'000000000000000 00000000000');
End;
except on E : Exception do
ShowMessage('ОШИБКА PickUp:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------

//-------------------------------------------------------------------ShowInfo---
procedure ShowInfo(CID:integer);
var
buf: string;
hmlstr:widestring;
begin
Try
with User[cid] do Begin
hmlstr:='';
hmlstr:='<html><title>'+Name+' ['+inttostr(ClassID)+']['+inttostr(ObjectID)+']'+'</title><body>';
hmlstr:=hmlstr+'<center>';
hmlstr:=hmlstr+'<br><button action="bypass mtt" value="MTT" width=74 height=21 back="L2UI_CH3.Btn1_normalOn" fore="L2UI_CH3.Btn1_normal">';
hmlstr:=hmlstr+'<br><button action="bypass sbs" value="SBS" width=74 height=21 back="L2UI_CH3.Btn1_normalOn" fore="L2UI_CH3.Btn1_normal">';
hmlstr:=hmlstr+'<br><button action="bypass np" value="Next point" width=74 height=21 back="L2UI_CH3.Btn1_normalOn" fore="L2UI_CH3.Btn1_normal">';
hmlstr:=hmlstr+'<br><button action="bypass ag" value="Ag" width=74 height=21 back="L2UI_CH3.Btn1_normalOn" fore="L2UI_CH3.Btn1_normal">';
hmlstr:=hmlstr+'<br><button action="bypass ka" value="Ka" width=74 height=21 back="L2UI_CH3.Btn1_normalOn" fore="L2UI_CH3.Btn1_normal">';

hmlstr:=hmlstr+'</center>';
//hmlstr:=hmlstr+'<buttom value="MTT" action="bypass mtt" width="100" height="22"><br>';
//hmlstr:=hmlstr+'<buttom value="Next point" action="bypass np" width="100" height="22" back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"><br>';
hmlstr:=hmlstr+'</body></html>';
End;
if User[cid].ObjectID<>0 then with ps do begin
buf:=HexToString('19');
WriteD(buf,User[cid].ObjectID);
WriteS(buf,hmlstr);
WriteD(buf,0);
SendPckStr(buf,CID,False);
end;
except on E : Exception do
ShowMessage('ОШИБКА ShowInfo:'+E.ClassName+' ошибка: '+E.Message);
End;
End;
//------------------------------------------------------------------------------
//--------------------------------------------------------------------MagicSU---
procedure MagicSU(CID,MagicID:integer);
begin
sts(CID,'39'+anti4HEX(MagicID)+'0000000000');
end;
//------------------------------------------------------------------------------
//--------------------------------------------------------------------UseItem---
function UseItem(CID,IID:integer):boolean;
begin
Result:=false;
Try
with User[cid].IList.Itemi[IID] do begin
if (OID<>0) and (Count<>0) then Result:=true;
if Result then sts(CID,'19'+anti4HEX(OID)+'00000000');
end;
except on E : Exception do
ShowMessage('ОШИБКА UseItem:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//-----------------------------------------------------------------Авто Atack---
procedure AAtack(cid:integer);
Var i:integer;
fl:boolean;
begin
Try
fl:=false;
with User[cid] do Begin
if (CurentT.ID=0) and (not CurentT.selected) and (not isInCombat) then Begin
i:=NpcList.GetMinDist(rk);
CurentT.ID:=i;
if i<>0 then STS(cid,'1f'+anti4HEX(i)+'000000000000000000000000 01');
End;
if (CurentT.selected) and (not isInCombat) and(status[6]='-') then Begin
isInCombat:=true;
STS(cid,'1f'+anti4HEX(CurentT.ID)+'000000000000000 00000000000');
End;
if (CurentT.selected) and (MAS<>0) then Begin
isInCombat:=true;
if (MCS<>0) and (not CurentT.isInCurse) then Begin
fl:=true;
CurentT.CurseTime:=GetTickCount;
CurentT.isInCurse:=true;
SkilList.Itemi[MCS].Cust(Cid);
End;
if not fl then SkilList.Itemi[MAS].Cust(Cid);
End;
End;
except on E : Exception do
ShowMessage('ОШИБКА AAtack:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//---------------------------------------------------------------Авто AAssist---
procedure AAssist(cid:integer);
var
fl:boolean;
begin
Try
fl:=false;
with User[cid] do Begin
if (CurentT.ID<>Lider.DTT) and (Lider.DTT<>0) then Begin
CurentT.ID:=Lider.DTT;
STS(cid,'1f'+anti4HEX(CurentT.ID)+'000000000000000 00000000001');
isInCombat:=False;
End;
if (CurentT.ID=Lider.DTT) and (Lider.DTT<>0) and (not isInCombat) and(status[6]='-') then Begin
isInCombat:=true;
STS(cid,'1f'+anti4HEX(CurentT.ID)+'000000000000000 00000000000');
End;
if (CurentT.ID=Lider.DTT) and (Lider.DTT<>0) and (MAS<>0) then Begin
if (MCS<>0) and (not CurentT.isInCurse) then Begin
isInCombat:=true;
fl:=true;
CurentT.CurseTime:=GetTickCount;
CurentT.isInCurse:=true;
SkilList.Itemi[MCS].Cust(Cid);
End;
if not fl then SkilList.Itemi[MAS].Cust(Cid);
End;
End;
except on E : Exception do
ShowMessage('ОШИБКА AAssist:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//-------------------------------------------------------------------PartyBuf---
procedure PartyBaf(CID:integer);
var i,p,bi:integer;
fl,pfl:boolean;
ms,bt:boolean;
begin
Try
fl:=false;
pfl:=false;
ms:=false;
p:=0;
bi:=0;
with User[cid] do Begin
while (p<=PartyList.Count-1) and (not pfl) do Begin
case PartyList[p].ClassID of
10..17,25..30,38..43,49..52,94..98,103..105,110..1 12,115,116:bt:=true;
else bt:=false;
end;
if bt and (MBList.Count<>0) then begin//--------------------Mistick baf---
i:=0;
while (i<=MBList.Count-1) and (not fl) and (PartyList[p].HP>0) and (PartyList[p].dist<700) do Begin
if not PartyList[p].Baffs.Active[StrToInt(MBList.Names[i])] then fl:=true;
if not fl then inc(i);
End;
if fl then bi:=strtoint(MBList.Names[i]);
if fl then pfl:=true;
End;

if not bt and (FBList.Count<>0) then begin//----------------Fighter baf---
i:=0;
while (i<=FBList.Count-1) and (not fl) and (PartyList[p].HP>0) and (PartyList[p].dist<700) do Begin
if not PartyList[p].Baffs.Active[StrToInt(FBList.Names[i])] then fl:=true;
if not fl then inc(i);
End;
if fl then bi:=strtoint(FBList.Names[i]);
if fl then pfl:=true;
End;
if not pfl then inc(p);
End;

//if (pfl) and (User[cid].PartyList[p].dist>700) then pfl:=false;

if (pfl) and (((CurentT.ID=PartyList[p].ObjectID) and (CurentT .selected)) or (ms)) and (not INKT) then Begin
if SkilList.Itemi[bi].Cust(cid) then INKT:=True;;
End;
if (pfl) and (CurentT.ID<>PartyList[p].ObjectID) and (not ms) then Begin
CurentT.selected:=false;
CurentT.ID:=PartyList[p].ObjectID;
STS(cid,'1f'+anti4HEX(CurentT.ID)+'000000000000000 00000000001');
End;
End;
except on E : Exception do
ShowMessage('ОШИБКА PartyBaf:'+Inttostr(CID)+'-'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------

//--------------------------------------------------------------------SelfBaf---
procedure SelfBaf(CID:integer);
var i,bi:integer;
fl,ms,bt:boolean;
begin
Try

fl:=false;
ms:=false;
bi:=0;
with User[cid] do begin
case ClassID of
10..17,25..30,38..43,49..52,94..98,103..105,110..1 12,115,116:bt:=true;
else bt:=false;
end;
if bt and (MBList.Count<>0) then begin
i:=0;
while (i<=MBList.Count-1) and (not fl) do Begin
if not Baffs.Active[StrToInt(MBList.Names[i])] then fl:=true;
if not fl then inc(i);
End;
if fl then bi:=strtoint(MBList.Names[i]);
End;
if not bt and (FBList.Count<>0) then begin
i:=0;
while (i<=FBList.Count-1) and (not fl) do Begin
if not Baffs.Active[StrToInt(FBList.Names[i])] then fl:=true;
if not fl then inc(i);
End;
if fl then bi:=strtoint(FBList.Names[i]);
End;
case ClassID of
95:ms:=true;
end;
if (bi<>0) and (CurentT.ID<>ObjectID) and (not ms) then Begin
//User[cid].INKT:=True;
CurentT.selected:=false;
CurentT.ID:=ObjectID;
STS(cid,'1f'+anti4HEX(ObjectID)+'00000000000000000 000000001');
End;
if (bi<>0) and (((CurentT.ID=ObjectID) and CurentT.selected) or ms) and
not INKT and SkilList.Itemi[bi].Cust(CID) then INKT:=True;

if bi=0 then isInSBaf:=false else isInSBaf:=true;
end;


except on E : Exception do
ShowMessage('ОШИБКА SelfBaf:'+Inttostr(CID)+'-'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//--------------------------------------------------------------------AutoBaf---
function AutoBaf(CID:integer):boolean;
var i,bi:integer;
fl:boolean;
begin
Result:=false;
Try
fl:=false;
bi:=0;
with User[cid] do Begin
if ABList.Count<>0 then begin
i:=0;
while (i<=ABList.Count-1) and (not fl) do Begin
if not Baffs.Active[StrToInt(ABList.Names[i])] then fl:=true;
if not fl then inc(i);
End;
if fl then bi:=strtoint(ABList.Names[i]);
End;
if (bi<>0) and (not INKT) then Begin
if SkilList.Itemi[bi].Cust(CID) then INKT:=True;
if INKT then Begin
isInCombat:=false;
End;
Result:=True
End;
End;
except on E : Exception do
ShowMessage('ОШИБКА AutoBaf:'+Inttostr(CID)+'-'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------

//--------------------------------------------------------------------AutoHeal---
procedure AutoHeal(CID:integer);
var i,n:integer;
begin
Try
with User[cid] do begin
INPU:=False;
n:=0;
i:=0;
if (MHS<>0) then Begin
if (MaxHP-HP>600) then n:=ObjectID;
while (i<=PartyList.Count-1) and (n>=0) do with PartyList[i] do Begin
if (ObjectID<>0) and (HP<>0) and (dist<630) and (HP/MaxHP<0.75) and (n>0)
and (User[cid].MMH<>0) and (SkilList[SkilList.IFIID(MMH)].isActive) then n:=-1;
if (ObjectID<>0) and (HP<>0) and (dist<630) and (HP/MaxHP<0.75) and (n=0) then n:=ObjectID;
inc(i);
End;
if (n>0) and (CurentT.ID<>n) then Begin
CurentT.selected:=false;
CurentT.ID:=n;
isInHeal:=True;
STS(cid,'1f'+anti4HEX(n)+'000000000000000000000000 01');
End;
if (n>0) and (CurentT.ID=n) and (CurentT.selected) and (not INKT) then
if SkilList[SkilList.IFIID(MHS)].Cust(cid) then INKT:=True;
End;
if (n<0) and (MMH<>0) and (not INKT) then
if SkilList[SkilList.IFIID(MMH)].Cust(cid) then INKT:=True;
if n=0 then isInHeal:=False else isInHeal:=True;

end;
except on E : Exception do
ShowMessage('ОШИБКА AutoHeal:'+Inttostr(CID)+'-'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

procedure Move2(Cid:integer);// -------------------------Следование за лидером---
var d:integer;
begin
Try
Randomize;
with User[Cid] do if (Lider.ID<>0) and (OnMoveToLiader) Then begin
d:=ras(x,y,Lider.x,Lider.y);
if (d>200) and (d<1900) then begin
MoveToPoint(Cid,Lider.x+20+random(50),Lider.y+20+r andom(50),Lider.z);
INKT:=false;
INPU:=false;
isInHeal:=false;
isInCombat:=false;
Lider.isInCombat:=false;
End;
end;

except on E : Exception do
ShowMessage('ОШИБКА Move2:'+E.ClassName+' ошибка: '+E.Message);
end;
end;
//------------------------------------------------------------------------------

//------------------------------------------------------------------------STS---
procedure STS(CID:integer;msg:string;F:boolean = true);
begin
if (CID<>-1) and (msg<>'') then with ps do SendPckStr(HexToString(msg),CID,f);
end;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------Say---
procedure Say(CID:integer;msg:string);
var
buf: string;
begin
with ps do begin
buf:=HexToString('4A00000000');
WriteD(buf,2);
WriteS(buf,'Auto');
WriteS(buf,msg);
SendPckStr(buf,CID,False);
end;
end;
//------------------------------------------------------------------------------
end.

Name4Me
22.04.2009, 00:24
unit OtherTypes;

interface

uses Windows,Classes;

Type
TBaff = Record
public
SkillID:integer;
LTU:DWORD;
Duration:integer;
End;

TBaffList = Record
private
items:array[0..36] of TBaff;
Count:integer;
function IFID(ID: Integer): Integer;
function GetR(ID: Integer): boolean;
function GetItem(ID: Integer): TBaff;
public
Procedure SLTU(ID:Integer;D:integer = 1000);
Property Active:boolean read GetR;
Property Itemi[ID: Integer]:TBaff read GetItem;
End;

TMyDelay = Record
private
Delay:DWord;
LTU:DWord;
function GetR: boolean;
public
Procedure SLTU(D:integer = 1000);
Property Active:boolean read GetR;
End;

TMyMacroAction = Record
md:TMyDelay;
CA:DWord;
Count:DWord;
AList:string;
PN:integer;
isComplete:Boolean;
Procedure SetAction (PointN:integer;ActionList:string);
End;
implementation

{------------------------------------------------------------------TBaffList---}

function TBaffList.GetItem(ID: Integer): TBaff;
var i:integer;
b:TBaff;
begin
Result:=b;
i:=IFID(ID);
if i<>-1 then Result:=Items[i];
end;

function TBaffList.GetR(ID: Integer): boolean;
var i:integer;
begin
Result:=false;
i:=IFID(ID);
if (i<>-1) and (((items[i].Duration-(GetTickCount-items[i].LTU)/1000)>20)) then Result:=True;
end;

procedure TBaffList.SLTU(ID:Integer;D: integer);
var i:integer;
begin
i:=IFID(ID);
if i=-1 then Begin
items[Count].SkillID:=ID;
items[Count].Duration:=D;
items[Count].LTU:=GetTickCount;
inc(Count);
End else Begin
items[i].Duration:=D;
items[i].LTU:=GetTickCount;
End;
end;

function TBaffList.IFID(ID: Integer): Integer;
var i:integer;
begin
Result:=-1;
i:=0;
while (Result=-1) and (i<Count) do
if items[i].SkillID=ID then Result:=i else inc(i);
end;
{-------------------------------------------------------------------TMyDelay---}

function TMyDelay.GetR: boolean;
begin
Result := false;
if LTU+Delay<GetTickCount then Result := True;
end;

procedure TMyDelay.SLTU(D:integer = 1000);
begin
Delay:=D;
LTU:=GetTickCount;
end;

{ TMyMacroAction }

procedure TMyMacroAction.SetAction(PointN:integer;ActionList :string);
var ml:TStrings;
begin
ml:=TstringList.Create;
isComplete:=false;
PN:=PointN;
CA:=0;
AList:=ActionList;
ml.Text:=ActionList;
Count:=ml.Count;
ml.Free;
end;

end.


[I]Добавлено через 1 минуту
unit MsbForm;


interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls,
Gauges, ToolWin, Buttons, ImgList,DateUtils, Menus,
msbu, Spin, Tabs, DockTabSet, ButtonGroup;

type
TForm2 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TBR: TTrackBar;
Shp1: TShape;
Panel1: TPanel;
ProgressBar1: TProgressBar;
TabSheet3: TTabSheet;
Memo1: TMemo;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
ImageList1: TImageList;
PageControl2: TPageControl;
TabSheet7: TTabSheet;
Gauge4: TGauge;
Gauge5: TGauge;
Gauge6: TGauge;
Button3: TButton;
CheckBox2: TCheckBox;
CheckBox1: TCheckBox;
Gauge3: TGauge;
Timer1: TTimer;
Panel2: TPanel;
Label1: TLabel;
Label2: TLabel;
Gauge1: TGauge;
Panel3: TPanel;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
CheckBox9: TCheckBox;
CheckBox10: TCheckBox;
StatusBar1: TStatusBar;
Label3: TLabel;
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
PM: TPopupMenu;
FBUF1: TMenuItem;
MBuf1: TMenuItem;
AllBuF1: TMenuItem;
ADD1: TMenuItem;
Remove1: TMenuItem;
FBuf2: TMenuItem;
MBuf2: TMenuItem;
AllBuf2: TMenuItem;
Ignor1: TMenuItem;
AutoBuff1: TMenuItem;
MAS1: TMenuItem;
MDS1: TMenuItem;
MBS1: TMenuItem;
SetLiader1: TMenuItem;
WarList1: TMenuItem;
FrendList1: TMenuItem;
PB: TPaintBox;
TrackBar3: TTrackBar;
Button2: TButton;
RadioGroup3: TRadioGroup;
MCS1: TMenuItem;
Button1: TButton;
OPD: TOpenDialog;
PageControl3: TPageControl;
TabSheet2: TTabSheet;
ListBox1: TListBox;
TabSheet6: TTabSheet;
TabSheet8: TTabSheet;
TabSheet9: TTabSheet;
SpinEdit1: TSpinEdit;
procedure Ncr(id:integer);
procedure DN(id:integer);
procedure StUpdate(id:integer);
procedure MyRGClick(Sender: TObject);
procedure MyBTClick(Sender: TObject);
procedure MySPClick(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MyTimer(Sender: TObject);
procedure FBUF1Click(Sender: TObject);
procedure PMPopup(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure TrackBar3Change(Sender: TObject);
procedure MySpinEditChange(Sender: TObject);
procedure MyTreeViewClick(Sender: TObject);
procedure MyTreeViewCustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode;
State: TCustomDrawState; var DefaultDraw: Boolean);
procedure MyTreeViewEdited(Sender: TObject; Node: TTreeNode; var S: string);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure SpinEdit1Change(Sender: TObject);
procedure RadioGroup3Click(Sender: TObject);

end;
var
Form2: TForm2;
mx,my:integer;
lb:bool;
implementation
uses unit2,AAction,Other_Func,TNpcs;
{$R *.dfm}


procedure TForm2.MySpinEditChange(Sender: TObject);
begin
with Sender as TSpinEdit do User[strtoint(Name[3])].rk:=Value;
end;

procedure TForm2.FBUF1Click(Sender: TObject);
Var Cid:integer;
begin
cid:=strtoint((PM.PopupComponent as TComboBox).Name[3]);
with (PM.PopupComponent as TComboBox) do
with User[cid] do
Case TMenuItem(Sender).Tag of
//28: User[id].SList.IgnorList.Add(User[id].SList.SkilList[(PM.PopupComponent as TComboBox).ItemIndex]);

24: with SkilList[SkilList.IFName(SelText)] do
if ABList.IndexOfName(inttostr(id))=-1 then ABList.Add(inttostr(id)+'='+Name);
27: with SkilList[SkilList.IFName(SelText)] do
if ABList.IndexOfName(inttostr(id))<>-1 then ABList.Delete(ABList.IndexOfName(inttostr(id)));
29: MAS:=SkilList[SkilList.IFName(SelText)].ID;
38: MCS:=SkilList[SkilList.IFName(SelText)].ID;
//30: User[id].mds:=strtoint(User[id].SList.SkilList.Names[(PM.PopupComponent as TComboBox).ItemIndex]);
//31: User[id].mbs:=strtoint(User[id].SList.SkilList.Names[(PM.PopupComponent as TComboBox).ItemIndex]);
//33: User[id].LiderInfo.ID:=User[id].CharList.ValueFromIndex[(PM.PopupComponent as TComboBox).ItemIndex];
End;

end;

procedure TForm2.SpinEdit1Change(Sender: TObject);
begin
User[RadioGroup3.ItemIndex].CurentPN:=SpinEdit1.Value;
end;

procedure TForm2.StUpdate(id:integer);
Var
i:integer;
var CI:TTreeNode;

Begin
try

if (User[id]<>nil) and(User[id].Online) and visible then with User[id] do
with PageControl2 do
with TTabSheet(FindComponent('NT'+inttostr(id))) do Begin
Caption:=User[id].Name+'['+inttostr(ClassID)+']';
TLabel(FindComponent('LB'+inttostr(id))).Caption:= inttostr(ObjectID);
TSpinEdit(FindComponent('SE'+inttostr(id))).Value: =rk;

TLabel(FindComponent('LBT'+inttostr(id))).Caption: =inttostr(CurentT.ID)+'-['+inttostr(CurentT.HP)+'/'+inttostr(CurentT.MaxHP)+']';
if CurentT.spoiled then TLabel(FindComponent('LBT'+inttostr(id))).Caption: =TLabel(FindComponent('LBT'+inttostr(id))).Caption +'+';

TGauge(FindComponent('CG')).MaxValue:=MaxCP;
TGauge(FindComponent('CG')).Progress:=CP;
TGauge(FindComponent('HG')).MaxValue:=MaxHP;
TGauge(FindComponent('HG')).Progress:=HP;
TGauge(FindComponent('MG')).MaxValue:=MaxMP;
TGauge(FindComponent('MG')).Progress:=MP;
TGauge(FindComponent('HGT')).MaxValue:=CurentT.Max HP;
TGauge(FindComponent('HGT')).Progress:=CurentT.HP;

//-------------------------------------------------------------SkilList---
if User[id].SkilList.Count<>0 then with TComboBox(FindComponent('SL'+inttostr(id))) do Begin
if Items.count<>User[id].SkilList.Count then Begin
Clear;
for I := 0 to User[id].SkilList.Count-1 do Items.Add(User[id].SkilList[i].Name);
End;
End;
//------------------------------------------------------------------------

TRadioGroup(FindComponent('RG1'+inttostr(id))).Cap tion:='HP ['+inttostr(IList.Itemi[HPiID].Count)+']';
if User[id].HPiID = 1060 then TRadioGroup(FindComponent('RG1'+inttostr(id))).Ite mIndex:=0;
if User[id].HPiID = 1061 then TRadioGroup(FindComponent('RG1'+inttostr(id))).Ite mIndex:=1;
if User[id].HPiID = 1539 then TRadioGroup(FindComponent('RG1'+inttostr(id))).Ite mIndex:=2;

TRadioGroup(FindComponent('RG2'+inttostr(id))).Cap tion:='MP ['+inttostr(IList.Itemi[MPiID].Count)+']';
if User[id].MPiID = 726 then TRadioGroup (FindComponent('RG2'+inttostr(id))).ItemIndex:=0;
if User[id].MPiID = 728 then TRadioGroup (FindComponent('RG2'+inttostr(id))).ItemIndex:=1;



if User[id].isInCombat then TShape(FindComponent('SH'+inttostr(id)+'1')).Brush .Color:=Clgreen
else TShape(FindComponent('SH'+inttostr(id)+'1')).Brush .Color:=ClWhite;
if User[id].IsCPUse then TShape(FindComponent('SH'+inttostr(id)+'2')).Brush .Color:=ClYellow
else TShape(FindComponent('SH'+inttostr(id)+'2')).Brush .Color:=ClWhite;
if User[id].IsHPUse then TShape(FindComponent('SH'+inttostr(id)+'3')).Brush .Color:=ClRed
else TShape(FindComponent('SH'+inttostr(id)+'3')).Brush .Color:=ClWhite;
if User[id].IsMPUse then TShape(FindComponent('SH'+inttostr(id)+'4')).Brush .Color:=ClBlue
else TShape(FindComponent('SH'+inttostr(id)+'4')).Brush .Color:=ClWhite;
if User[id].CurentT.isInCurse then TShape(FindComponent('SH'+inttostr(id)+'5')).Brush .Color:=Clgreen
else TShape(FindComponent('SH'+inttostr(id)+'5')).Brush .Color:=ClWhite;
if User[id].isInMTP then TShape(FindComponent('SH'+inttostr(id)+'6')).Brush .Color:=Clgreen
else TShape(FindComponent('SH'+inttostr(id)+'6')).Brush .Color:=ClWhite;
if isInHold then TShape(FindComponent('SH'+inttostr(id)+'7')).Brush .Color:=ClBlue
else TShape(FindComponent('SH'+inttostr(id)+'7')).Brush .Color:=ClWhite;
if User[id].isInHeal then TShape(FindComponent('SH'+inttostr(id)+'8')).Brush .Color:=ClRed
else TShape(FindComponent('SH'+inttostr(id)+'8')).Brush .Color:=ClWhite;
if User[id].isInSBaf then TShape(FindComponent('SH'+inttostr(id)+'9')).Brush .Color:=ClBlue
else TShape(FindComponent('SH'+inttostr(id)+'9')).Brush .Color:=ClWhite;
if User[id].isInSweep then TShape(FindComponent('SH'+inttostr(id)+'10')).Brus h.Color:=clFuchsia
else TShape(FindComponent('SH'+inttostr(id)+'10')).Brus h.Color:=ClWhite;

if User[id].OnAutoBaf then TShape(FindComponent('SH'+inttostr(id)+'11')).Brus h.Color:=clFuchsia
else TShape(FindComponent('SH'+inttostr(id)+'11')).Brus h.Color:=ClWhite;
if User[id].OnPartyBaf then TShape(FindComponent('SH'+inttostr(id)+'12')).Brus h.Color:=clFuchsia
else TShape(FindComponent('SH'+inttostr(id)+'12')).Brus h.Color:=ClWhite;
if User[id].OnSelfBaf then TShape(FindComponent('SH'+inttostr(id)+'13')).Brus h.Color:=clFuchsia
else TShape(FindComponent('SH'+inttostr(id)+'13')).Brus h.Color:=ClWhite;
if User[id].OnAutoAtack then TShape(FindComponent('SH'+inttostr(id)+'14')).Brus h.Color:=clFuchsia
else TShape(FindComponent('SH'+inttostr(id)+'14')).Brus h.Color:=ClWhite;
if User[id].OnAutoPickUp then TShape(FindComponent('SH'+inttostr(id)+'15')).Brus h.Color:=clFuchsia
else TShape(FindComponent('SH'+inttostr(id)+'15')).Brus h.Color:=ClWhite;
if User[id].OnAutoAssist then TShape(FindComponent('SH'+inttostr(id)+'16')).Brus h.Color:=clFuchsia
else TShape(FindComponent('SH'+inttostr(id)+'16')).Brus h.Color:=ClWhite;
if User[id].OnMoveToLiader then TShape(FindComponent('SH'+inttostr(id)+'17')).Brus h.Color:=clFuchsia
else TShape(FindComponent('SH'+inttostr(id)+'17')).Brus h.Color:=ClWhite;
if User[id].OnAutoMTT then TShape(FindComponent('SH'+inttostr(id)+'23')).Brus h.Color:=Clgreen
else TShape(FindComponent('SH'+inttostr(id)+'23')).Brus h.Color:=ClWhite;
if status[6]='+' then TShape(FindComponent('SH'+inttostr(id)+'24')).Brus h.Color:=clFuchsia
else TShape(FindComponent('SH'+inttostr(id)+'24')).Brus h.Color:=ClWhite;
if User[id].INPU then TShape(FindComponent('SH'+inttostr(id)+'19')).Brus h.Color:=Clgreen
else TShape(FindComponent('SH'+inttostr(id)+'19')).Brus h.Color:=ClWhite;
if User[id].INKT then TShape(FindComponent('SH'+inttostr(id)+'21')).Brus h.Color:=Clgreen
else TShape(FindComponent('SH'+inttostr(id)+'21')).Brus h.Color:=ClWhite;
if User[id].OnAutoOFF then TShape(FindComponent('SH'+inttostr(id)+'22')).Brus h.Color:=Clgreen
else TShape(FindComponent('SH'+inttostr(id)+'22')).Brus h.Color:=ClWhite;

{
with TTreeView(FindComponent('TV'+inttostr(id))).Items do Begin
CI:=GetFirstNode;
while CI<>nil do Begin
if (CI.Text='[UserInfo]') then Begin
if Lider.isInCombat then CI.Item[0].Text:='Lider ID: '+inttostr(Lider.ID)+' ! ['+inttostr(Lider.DTT)+']'
else CI.Item[0].Text:='Lider ID: '+inttostr(Lider.ID)+' ['+inttostr(Lider.DTT)+']';
CI.Item[1].Text:='MAS ['+inttostr(Mas)+']';
CI.Item[2].Text:='MCS ['+inttostr(Mcs)+']';
End;
if (CI.Text='[Party list]') and (PartyList.Count>0) and (PartyList.Count<>CI.Count) then
for I := 0 to NpcList.Count - 1 do Begin
if CI.Count<PartyList.Count then AddChild(CI,PartyList[i].Name);
CI.Item[i].Text:=PartyList[i].Name+' --> '+inttostr(PartyList[i].Dist);
CI.Item[i].SelectedIndex:=PartyList[i].ObjectID;
if CI.Count>PartyList.Count then Delete(CI.Item[PartyList.Count]);
End;

if (CI.Text='[NPC list]') and (NpcList.Count>0) then Begin
NpcList.Sort(@MyNPCSort);
for I := 0 to NpcList.Count - 1 do Begin
if CI.Count<NpcList.Count then AddChild(CI,'');
CI.Item[i].Text:=NpcList[i].NpcName+' ['+inttostr(NpcList[i].NpcID)+'] --> '+inttostr(NpcList[i].Dist);
CI.Item[i].SelectedIndex:=NpcList[i].ObjectID;
CI.Item[i].StateIndex:=NpcList[i].NpcID;
if CI.Count>NpcList.Count then Delete(CI.Item[NpcList.Count]);
End;
End;
//---------------------------------------------------------CharList---
if (CI.Text='[Char list]') and (CharList.Count>0) and (CharList.Count<>CI.Count) then
for I := 0 to CharList.Count - 1 do Begin
if CI.Count<CharList.Count then AddChild(CI,CharList[i].Name);
CI.Item[i].Text:=CharList[i].Name;
CI.Item[i].SelectedIndex:=CharList[i].ObjectID;
CI.Item[i].StateIndex:=CharList[i].ClassID;
if CI.Count>CharList.Count then Delete(CI.Item[CharList.Count]);
End;
if (CI.Text='[ATList]') and (ATList.Count>0) then
for I := 0 to ATList.Count - 1 do Begin
if CI.Count<ATList.Count then AddChild(CI,ATList[i]);
CI.Item[i].Text:=ATList[i];
CI.Item[i].SelectedIndex:=StrToInt(ATList[i]);
if CI.Count>ATList.Count then Delete(CI.Item[ATList.Count]);
End;
if (CI.Text='[ItemList]') and (IList.Count>0) then
for I := 0 to IList.Count - 1 do Begin
if CI.Count<IList.Count then AddChild(CI,'');
if itid.Values[inttostr(IList[i].ID)]<>'' then
CI.Item[i].Text:=itid.Values[inttostr(IList[i].ID)]+' ['+inttostr(IList[i].Count)+']'
else CI.Item[i].Text:='['+inttostr(IList[i].ID)+']'+' ['+inttostr(IList[i].Count)+']';

//CI.Item[i].SelectedIndex:=StrToInt(IList[i]);
if CI.Count>IList.Count then Delete(CI.Item[IList.Count]);
End;
CI:=CI.GetNext;
End;
End;
//------------------------------------------------------------------------
}


End;
except on E : Exception do
ShowMessage('ОШИБКА StUpdate:'+E.ClassName+' ошибка: '+E.Message);
end;
End;


procedure TForm2.Timer1Timer(Sender: TObject);
Var CID,i:integer;
mt:real;
begin
Try
CID:=RadioGroup3.ItemIndex;
with PB.Canvas do with User[CID] do Begin
Brush.Color := ClWhite;
FillRect(ClipRect);

if Treck.size>1 then for i:= 1 to Treck.size do begin


Pen.Color:=ClBlue;
//map.LoadFromFile(GetCurrentDir+'\Treks\Atrei1.trk' );
Pen.Color:=ClRed;
Pen.Width:=1;
with User[CID].Treck do Begin
mt:=(350/mult);
Font.Size:=4;
TextOut(round((maxx-Point[i].x)*mt)+15,10+round((maxy-Point[i].y)*mt),Point[i].Name);
if i>1 then Begin

MoveTo(round((maxx-Point[i-1].x)*mt)+15,10+round((maxy-Point[i-1].y)*mt));
LineTo(round((maxx-Point[i].x)*mt)+15,10+round((maxy-Point[i].y)*mt));
End;
//Pen.Color:=cllime;
//PB.Canvas.Brush.Style:=bsSolid;
Brush.Color:=cllime;
Ellipse(round((maxx-x)*mt)+11,6+round((maxy-y)*mt),round((maxx-x)*mt)+19,14+round((maxy-y)*mt));
FloodFill(round((maxx-x)*mt)+15,10+round((maxy-y)*mt),cllime,fsBorder);
Brush.Color := ClWhite;
End;
End;
Pen.Color:=ClGreen;
Font.Size:=5;
TextOut(5,2,'Curent poin: '+inttostr(CurentPN));
TextOut(5,15,'Treck Size: '+inttostr(Treck.size));
End;
except on E : Exception do
ShowMessage('ОШИБКА Timer1Timer:'+E.ClassName+' ошибка: '+E.Message);
End;
end;

procedure TForm2.TrackBar3Change(Sender: TObject);
begin
Form2.AlphaBlendValue:=TrackBar3.Position;
end;

procedure TForm2.MyTreeViewEdited(Sender: TObject; Node: TTreeNode;
var S: string);
begin
{if Node.StateIndex>0 then Begin
if npid.IndexOfName(inttostr(Node.StateIndex))=-1 then npid.Add(inttostr(Node.StateIndex)+'='+s);
npid.SaveToFile('npcsid.ini');
End;

Caption:=s;}
end;

procedure TForm2.MyTreeViewCustomDrawItem(Sender: TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
Var MC:TColor;
Begin
with Sender as TTreeView do
if (Node.HasAsParent(Node)) and (Node.Parent.Text='[Char list]') then Begin
mc:=Canvas.Pen.Color;
case Node.StateIndex of
16: Canvas.Pen.Color := clSkyBlue;
97: Canvas.Pen.Color := clSkyBlue;
116: Canvas.Pen.Color := clFuchsia;
else Canvas.Pen.Color := mc;
End;
End;
End;

procedure TForm2.MyTreeViewClick(Sender: TObject);
Var CID:integer;
begin
with Sender as TTreeView do Begin
cid:=strtoint(name[3]);
if Selected.SelectedIndex>0 then STS(cid,'1f'+anti4HEX(Selected.SelectedIndex)+'000 00000000000000000000001'); //Select
//Caption:=Selected.Text+inttostr(Selected.Index);
End;
end;

procedure TForm2.Ncr;
Var
i:integer;
sCID:string;
mp,p:TComponent;
begin
sCID:=inttostr(id);
with TTabSheet.Create(PageControl2) do begin
Name:='NT'+sCID;
Caption:=User[id].Name;
PageControl:=PageControl2;
end;

mp:=PageControl2.FindComponent('NT'+sCID);
with TPageControl.Create(mp) do begin
Parent:=mp as TTabSheet;
Name:='PGC'+sCID;
Width:=380;
Height:=454;
top:=215;
Left:=3;
end;
//End;

p:=mp.FindComponent('PGC'+sCID);
with TTabSheet.Create(p) do begin
Name:='PG1';
Caption:='NPC List';
PageControl:=p as TPageControl;
end;


with TButton.Create(mp) do begin
Parent:=mp as TTabSheet;
Name:='MB'+sCID;
caption:='On';
Width:=30;
Height:=17;
top:=3;
Left:=3;
OnClick:=MyBTClick;
end;
with TSpinEdit.Create(mp) do begin
Parent:=mp as TTabSheet;
Name:='SE'+sCID;
Width:=60;
Height:=22;
top:=165;
Left:=3;
OnChange:=MySpinEditChange;
ShowHint:=true;
Hint:='Radius Kacha';
end;
with TComboBox.Create(mp) do begin
Parent:=mp as TTabSheet;
Name:='SL'+sCID;
top:=190;
PopupMenu:=PM;
Text:='';
Width:=158;
Left:=3;
end;

for i:=1 to 24 do with TShape.Create(mp) do begin
Parent:=mp as TTabSheet;
Name:='SH'+sCID+inttostr(i);
Width:=10;
Height:=10;
ShowHint:=true;
OnMouseDown:=MySPClick;
Tag:=i;
case i of
1:Hint:='IsInCombat';
2:Hint:='IsCPUse';
3:Hint:='IsHPUse';
4:Hint:='IsMPUse';
5:Hint:='TargetIsInCurse';
6:Hint:='MoveToPoint';
7:Hint:='isInHold';
8:Hint:='isInHeal';
9:Hint:='isInSBaf';
10:Hint:='isInSweep';

11:Hint:='OnAutoBaf';
12:Hint:='OnPartyBaf';
13:Hint:='OnSelfBaf';
14:Hint:='OnAutoAtack';
15:Hint:='OnAutoPickUp';
16:Hint:='OnAutoAssist';
17:Hint:='OnMoveToLiader';

18:Hint:='INA';
19:Hint:='INPU';
20:Hint:='INAA';
21:Hint:='INKT';
22:Hint:='OnAutoOFF';

23:Hint:='';
24:Hint:='Mistik';
end;
case i of
1..40: Begin
Top:=3;
Left:=40+i*13;
End;
end;
end;

with TLabel.Create(mp) do begin
Parent:=mp as TTabSheet;
Name:='LB'+sCID;
top:=25;
Left:=3;
end;
with TLabel.Create(mp) do begin
Parent:=mp as TTabSheet;
Name:='LBT'+sCID;
top:=63;
Left:=3;
end;

for i:=1 to 4 do
with TGauge.Create(mp) do begin
Parent:=mp as TTabSheet;
Case i of
1: begin
Name:='CG';
ForeColor:=ClYellow;
Top:=40;
end;
2: begin
Name:='HG';
ForeColor:=ClRed;
Top:=47;
end;
3: begin
Name:='MG';
ForeColor:=ClBlue;
Top:=54;
end;
4: begin
Name:='HGT';
ForeColor:=ClRed;
Top:=78;
end
end;
ShowText:=False;
Width:=158;
Height:=6;
Left:=3;
end;
for i:=1 to 2 do
with TRadioGroup.Create(mp) do begin
Parent:=mp as TTabSheet;
Name:='RG'+inttostr(i)+sCID;
Width:=80;
Height:=60;
Left:=3+85*(i-1);
Top:=95;
tag:=i;
case i of
1:Begin
Caption:='HP';
items.Add('LHP'); items.Add('HP'); items.Add('GHP');
End;
2:Begin
Caption:='MP';
items.Add('MP'); items.Add('GMP');
End;
End;
OnClick:=MyRGClick;
end;

with TTimer.Create(mp) do begin
Name:='MT'+sCID;
interval:=100;
ontimer:=MyTimer;
Enabled:=True;
end;
End;

procedure TForm2.PMPopup(Sender: TObject);
var i:integer;
begin
if pos('UL',TPopupMenu(Sender).PopupComponent.name)<>0 then
for i := 0 to TPopupMenu(Sender).Items.Count - 1 do case TPopupMenu(Sender).Items[i].Tag of
33..35: TPopupMenu(Sender).Items[i].Visible:=true;
end
else for i := 0 to TPopupMenu(Sender).Items.Count - 1 do case TPopupMenu(Sender).Items[i].Tag of
33..35: TPopupMenu(Sender).Items[i].Visible:=false;
end;
if pos('SL',TPopupMenu(Sender).PopupComponent.name)<>0 then
for i := 0 to TPopupMenu(Sender).Items.Count - 1 do case TPopupMenu(Sender).Items[i].Tag of
21..31,38: TPopupMenu(Sender).Items[i].Visible:=true;
end
else for i := 0 to TPopupMenu(Sender).Items.Count - 1 do case TPopupMenu(Sender).Items[i].Tag of
21..31,38: TPopupMenu(Sender).Items[i].Visible:=false;
end;

//ShowMessage(TPopupMenu(Sender).PopupComponent.Clas sName);
end;

procedure TForm2.RadioGroup3Click(Sender: TObject);
begin
//RadioGroup3.Items.Objects[0]. :=false;
end;

procedure TForm2.Button1Click(Sender: TObject);
Var s:string;
begin
s:=InputBox('Save Treck','Name',User[RadioGroup3.ItemIndex].Name);
if s<>'' then with User[RadioGroup3.ItemIndex] do
Treck.SaveToFile(GetCurrentDir+'\Treks\'+s+'.trk') ;
end;

procedure TForm2.Button2Click(Sender: TObject);
begin
OPD.InitialDir:=GetCurrentDir+'\Treks\';
OPD.Execute;
if OPD.FileName<>'' then User[RadioGroup3.ItemIndex].Treck.LoadFromFile(OPD.FileName);
end;

procedure TForm2.Button3Click(Sender: TObject);
begin
user[0].Init('MrXtreme');
Form2.Ncr(0);
end;

procedure TForm2.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then Form2.FormStyle:=fsStayOnTop
else Form2.FormStyle:=fsNormal;
end;

procedure TForm2.DN;
begin
(PageControl2.FindComponent('NT'+inttostr(id)) as TTabSheet).Destroy;
End;

procedure TForm2.MyRGClick(Sender: TObject);
begin
with sender as TRadioGroup do with User[strtoint(name[4])] do
case tag of
1: case ItemIndex of
0: HPiID:=1060;
1: HPiID:=1061;
2: HPiID:=1539;
end;
2: case ItemIndex of
0: MPiID:=726;
1: MPiID:=728;
end;
end;
end;

procedure TForm2.MyBTClick(Sender: TObject);
Var id:string;
begin
with sender as TButton do Begin
id:=name[3];
if Caption='On' then Begin
Caption:='Off';
with PageControl2 do
with TTabSheet(FindComponent('NT'+id)) do TTimer(FindComponent('MT'+id)).Enabled:=True;

End
Else Begin
Caption:='On';
with PageControl2 do
with TTabSheet(FindComponent('NT'+id)) do TTimer(FindComponent('MT'+id)).Enabled:=False;
End;
End;
end;

procedure TForm2.MySPClick(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
with sender as TShape do
with User[strtoint(name[3])] do
Case Tag of
1: IsInCombat:= not IsInCombat;
2: IsCPUse:= not IsCPUse;
3: IsHPUse:= not IsHPUse;
4: IsMPUse:= not IsMPUse;
5: CurentT.IsInCurse:= not CurentT.IsInCurse;
6: isInMTP:= not isInMTP;
7: isInHold:= not isInHold;
8: isInHeal:= not isInHeal;
9: isInSBaf:= not isInSBaf;
10: isInSweep:= not isInSweep;

11: OnAutoBaf:= not OnAutoBaf;
12: OnPartyBaf:= not OnPartyBaf;
13: OnSelfBaf:= not OnSelfBaf;
14: OnAutoAtack:= not OnAutoAtack;
15: OnAutoPickUp:= not OnAutoPickUp;
16: OnAutoAssist:= not OnAutoAssist;
17: OnMoveToLiader:= not OnMoveToLiader;

18: ;
19: INPU:= not INPU;
20: ;
21: INKT:= not INKT;
22: OnAutoOFF:= not OnAutoOFF;

23: ;
24: ;
//11: if Pen.Color=clLime then OnAutoBaf:=True else OnAutoBaf:=False;
//12: if Pen.Color=clLime then OnPartyBaf:=True else OnPartyBaf:=False;
//13: if Pen.Color=clLime then OnSelfBaf:=True else OnSelfBaf:=False;
//14: if Pen.Color=clLime then OnAutoAtack:=True else OnAutoAtack:=False;
//15: if Pen.Color=clLime then OnAutoPickUp:=True else OnAutoPickUp:=False;
//16: if Pen.Color=clLime then OnAutoAssist:=True else OnAutoAssist:=False;
//17: if Pen.Color=clLime then OnMoveToLiader:=True else OnMoveToLiader:=False;
//24: if Pen.Color=clLime then status[6]:='+' else status[6]:='-';
End;
end;

procedure TForm2.MyTimer(Sender: TObject);
var Cid:integer;
begin
Cid:=0;
try
with sender as TTimer do Cid:=strtoint(name[3]);
With User[CID] Do Begin
if not isInHold then AA(CID);
if isInHold then with Baffs.Itemi[4072] do if Duration<(GetTickCount-LTU)/1000 then UnHold(cid);


End;
except on E : Exception do
ShowMessage('ОШИБКА MyTimer:'+inttostr(Cid)+' '+E.ClassName+' ошибка: '+E.Message);
End;
end;


end.

Name4Me
22.04.2009, 00:30
Вроде всё если что виложу чего не виложил...
Буду оч благодарен если кто напишет свои предложения....
Бот пока сирой но достаточно работоспосбний, писался под хелбаунд

Поддерживаеться:
-авто мп,хп,( сп вроде как иногда глючит);
-Авто асист, следование за лидером, авто атака с ограничением дистанции и возможностью вибора радиуса и центра кача (для файтера и мага);
-авто баф, есть возможность бафать по 2 вариантам, авто хил;
-споил, свип;
-Подерживаеться возможность асиста петом;
-Поддерживаеться работа движения по маршруту с виполнением действий в определёних точках

Johnson
11.05.2009, 08:57
Выложите пожалста откомпилированый плагин. Просто дельфи нету под рукой щас

QaK
12.05.2009, 15:02
Name4Me, Для оформления кода юзай теги [ HIGHLIGHT = "delphi" ]тут код [ /HIGHLIGHT ] без пробелов в тегах
Также, неплохо было бы убарть ненужный код в каментах и прокоментировать рабочий код.

Name4Me
14.05.2009, 19:01
Рабочий плагин под камель
http://www.rapidshare.ru/1038288

NLObP
14.05.2009, 22:18
При запуске требует libmySQL.dll, где брать?
//alexteam: в гугл! -)))

Нашел. Это от MySQL. :)

Только не пойму, для чего там эта либа?

Name4Me
15.05.2009, 01:54
В раней версии велась запись в базу даних... MySQL, запись отрубил а ссилка осталась ща найду где отрублю

Name4Me
15.05.2009, 02:05
По ходу должна работать без библиотеки, только что специально просмотрел код ссилки, на дллку нет.
Хотя мож что и пропустил, дело в том что сначала планировалось писать стати чаров в базу даних потом по ходу заменил на ини файл.

Name4Me
15.05.2009, 12:08
Добавил возможность агюментации в одно нажатие... 1 раз делаем агюмент в ручную чтоб задать оружие и тип ЛС дальше при нажатии на кнопку если оружие имеет агюмент, то агюмент снимаеться если нет то устанавливается.
unit Agumentation;

interface
Uses msbu;
Var
subID,WIID,LSIID,GSIID,GSCount : integer;
Procedure SetAgValue(CID,sID,WObjID,LObjID,GObjID,Count:inte ger);
Procedure Augment(CID:integer);
implementation
Uses AAction,Other_Func;
Procedure SetAgValue(CID,sID,WObjID,LObjID,GObjID,Count:inte ger);
Begin
subID:=sID;
WIID:=user[CID].IList.Itemo[WObjID].ID;
LSIID:=user[CID].IList.Itemo[LObjID].ID;
GSIID:=user[CID].IList.Itemo[GObjID].ID;
GSCount:=Count;
say(CID,'Елементы для агюментации заданы');
End;
Procedure Augment(CID:integer);
Begin
with user[CID] do Begin
if (WIID<>0) and (IList.Itemi[WIID].AugmentationBonus<>0) then sts(CID,'D04600'+anti4HEX(IList.Itemi[WIID].OID));
if (WIID<>0) and (IList.Itemi[WIID].AugmentationBonus=0) Then if (IList.Itemi[LSIID].Count>0)
and (IList.Itemi[GSIID].Count>=GSCount) then
sts(CID,'D04400'+anti4HEX(IList.Itemi[WIID].OID)+anti4HEX(IList.Itemi[LSIID].OID)+anti4HEX(IList.Itemi[GSIID].OID)+anti4HEX(GSCount))
else say(CID,'Недостаточно елементов для агюментации');
End;
End;

end.

Добавлено через 9 часов 42 минуты
Вчера час рыл питаясь понять почему идёт запрос на либу май скул не нашол а сегодня дошло что выкинул ссилку на старую версию плагина... Сори вот ссилка на текущую версию дллки с исходником http://www.rapidshare.ru/1039102
P.s. Просьба к гуру, у меня на 1 компе при вигрузке плагина в определёних случаях при закритии пакетхака видаёт ерор на других норм.... давно бьюсь не могу понять в чом дело если кто увидит и разберёться буду оч признателен...

QaK
15.05.2009, 12:48
Name4Me, при каких случаях вылетает, при каких нет, опиши хотябы что делал до этого.

Name4Me
15.05.2009, 22:30
Еслиб знал в каком случае вилетает давно б исправил... по ходу не висвобождаеться какойто обьект... но какой отловить не могу.
//alexteam: вылетает. просто закрывается ? если да - 80% - переполнение стека.