charly911, if you use Script by Voron ("Бот кач локомотив") there is o lot of errrs in this script,because olny Voron (as I known) use and test this script, so if something did'nt work correct - try to fix by yourself.
Цитата:
Сообщение от charly911
Also i wanted to calculate distance using Pythagoras (sqrt((x*x)+(y*y)), but sometimes i got erros (negative values, theoricaly impossible), thas why i wanted to understand it better.
Put there a code of the function to calculate distance, and example, where and how do you use it?
charly911, if you use Script by Voron ("Бот кач локомотив") there is o lot of errrs in this script,because olny Voron (as I known) use and test this script, so if something did'nt work correct - try to fix by yourself.
Put there a code of the function to calculate distance, and example, where and how do you use it?
Here is the code i tried to use to calculate the nearest Mob in the area:
This is just a test i made, its all a mess :P
What i wanted to do was to create a data base of Mobs position, determine the nearest, and when i pressed the button, the PJ (Player) run to that location. Result: only some times worked, why? i don't know. :'(
I have to re-write it, but i have not enought time as i am working and i have to study.
Maybe this weekend i'll do it, with the corresponding explanation.
I made this script to add it into another, that worked. This is the main working script:
delphi Код:
--------------------------------------------------------------------------
{This is very stupid bot, that works fine :D
The way it search mobs is very simple.
He moves to one of four secific points, and all the time uses /targetnext
When he finaly targets a mob, he atacks, until mod is dead.
Then he try to target another, and if no mob is targeted he goes to another position.
If his HP goes less than 55%, he drinks a greater Healing Pot, and if it is lower than 10% he dispears (not log off, but mobs cant atack)
until his HP goes more than 1/2.
He also try to use skills every time he can.
To select the four positions, the only thing that must be made, is to clic one button (Pos1/2/3/4), an then clic on the place you want
to set it.
}const PJName='UlTrApLeX';
var act,PotID1,PotID2,PotID3,PotID4:integer; me1:char; me2:char; me3:char; me4:char; nm:integer; t1:char; t2:char; t3:char; t4:char; nt:integer; shade:integer; mz:integer; pz:integer; tz:integer; hz:integer; MaxHP,CurHP,MaxMP,Shadow,CurMP,MaxCP,CurCP,ATT,TS,MyCorX,MyCorY,MyCorZ,CoordPpalX,CoordPpalY,CoordPpalZ,Contador,Posicion,Coord,Activo,Activo2,CoordX,CoordY,CoordZ,i: integer;
CoordX1,CoordX2,CoordX3,CoordY1,CoordY2,CoordY3,CoordZ1,CoordZ2,CoordZ3,CoordX4,CoordY4,CoordZ4,Espera,Esperando,AutoSelect,AutoSelect2,PJInfoAct,PJInfoAct2,p,RaceID,SexID,ClassID,MoveOK,MoveOK2,UsandoPot:integer;
m,m2,m3:TMemo; frm,frm2,frm3:TForm; Message,NombreDelPJ,Name,Sex,Race, Class: string;
button: tbutton;
etext3: TEdit;
IDdelPJ,VerificarID,Accuracy,Vicio,ShadowEterno,BichosMuertos:integer;
timer1,timer2,timer3: TTimer;
MiID,IDObtenida,IDTemporal,IDActualizable,NeedLoc,Comienzo:integer;
UltimaX,UltimaY,UltimaZ,UltimaXa,UltimaYa,UltimaZa,Memorizar,LocX1,LocX2,LocX3,LocX4,LocY1,LocY2,LocY3,LocY4,LocZ1,LocZ2,LocZ3,LocZ4:integer;
penel,penel2,penel3:TPanel;
ProgressBar1: TProgressBar;
Label1: TLabel;
penel4,penel0: TPanel;
statusBar: TStatusbar;
////000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000//procedure Init;
begin
frm := TForm.Create(nil);
frm.Caption := 'Movimiento';
frm.BorderStyle := bsSizeable;
frm.Position := poScreenCenter;
frm.Width:=210;
frm.Height:=900;
m:=TMemo.Create(frm);
m.parent:=frm;
m.align:=alClient;
m.ReadOnly:=true;
m.ScrollBars:=ssBoth;
penel:=TPanel.Create(frm);
penel.parent:=frm;
penel.align:=alBottom;
penel.Width:=150;
penel.height:=30;
penel2:=TPanel.Create(frm);
penel2.parent:=frm;
penel2.align:=alBottom;
penel2.Width:=150;
penel2.height:=30;
penel3:=TPanel.Create(frm);
penel3.parent:=frm;
penel3.align:=alBottom;
penel3.Width:=150;
penel3.height:=30;
penel4:=TPanel.Create(frm);
penel4.parent:=frm;
penel4.align:=alBottom;
penel4.Width:=150;
penel4.height:=17;
{penel0:=TPanel.Create(frm);
penel0.parent:=frm;
penel0.align:=alBottom;
penel0.Width:=150;
penel0.height:=30;
StatusBar:=TStatusBar.Create(penel0);
StatusBar.parent:=penel0;
StatusBar.Width:=200; }
button:=tbutton.Create(penel);
button.parent:=penel;
button.align:=alLeft;
button.Width:=25;
button.caption:='ID';
button.onClick:=@VerifID;
button.hint:='Verifica ID del PJ.';
button:=tbutton.Create(penel);
button.parent:=penel;
button.align:=alLeft;
button.Width:=30;
button.caption:='1';
button.onClick:=@Memo1;
button.hint:='Memoriza ubicacion 1.';
button:=tbutton.Create(penel);
button.parent:=penel;
button.align:=alLeft;
button.Width:=30;
button.caption:='2';
button.onClick:=@Memo2;
button.hint:='Memoriza ubicacion 2.';
button:=tbutton.Create(penel);
button.parent:=penel;
button.align:=alLeft;
button.Width:=30;
button.caption:='3';
button.onClick:=@Memo3;
button.hint:='Memoriza ubicacion 3.';
button:=tbutton.Create(penel);
button.parent:=penel;
button.align:=alLeft;
button.Width:=30;
button.caption:='4';
button.onClick:=@Memo4;
button.hint:='Memoriza ubicacion 4.';
button:=tbutton.Create(penel);
button.parent:=penel;
button.align:=alLeft;
button.Width:=55;
button.caption:='Contador';
button.onClick:=@ContBichos;
button.hint:='Verifica ID del PJ.';
button:=tbutton.Create(penel2);
button.parent:=penel2;
button.align:=alLeft;
button.Width:=50;
button.caption:='Ir a 1';
button.onClick:=@IrMemo1;
button.hint:='Ir a ubicacion 1.';
button:=tbutton.Create(penel2);
button.parent:=penel2;
button.align:=alLeft;
button.Width:=50;
button.caption:='Ir a 2';
button.onClick:=@IrMemo2;
button.hint:='Ir a ubicacion 2.';
button:=tbutton.Create(penel2);
button.parent:=penel2;
button.align:=alLeft;
button.Width:=50;
button.caption:='Ir a 3';
button.onClick:=@IrMemo3;
button.hint:='Ir a ubicacion 3.';
button:=tbutton.Create(penel2);
button.parent:=penel2;
button.align:=alLeft;
button.Width:=50;
button.caption:='Ir a 4';
button.onClick:=@IrMemo4;
button.hint:='Ir a ubicacion 4.';
button:=tbutton.Create(penel3);
button.parent:=penel3;
button.align:=alLeft;
button.Width:=50;
button.caption:='On / Off';
button.onClick:=@ActDes;
button.hint:='Activa / Desactiva el BOT.';
button:=tbutton.Create(penel3);
button.parent:=penel3;
button.align:=alLeft;
button.Width:=70;
button.caption:='Auto Target';
button.onClick:=@AutoSel;
button.hint:='Auto Target On/Off.';
button:=tbutton.Create(penel3);
button.parent:=penel3;
button.align:=alLeft;
button.Width:=60;
button.caption:='Movimiento';
button.onClick:=@PMoveOK;
button.hint:='Movimiento automatico.';
button:=tbutton.Create(penel3);
button.parent:=penel3;
button.align:=alLeft;
button.Width:=20; ////////////////////////////////////
button.caption:='R';
button.onClick:=@Reset;
button.hint:='Resetea contador de Bichos matados.';
Label1:=TLabel.Create(penel4);
Label1.parent:=penel4;
Label1.align:=alLeft;
Label1.Width:=20;
Label1.Caption:=' HP: ';
Progressbar1:= tprogressbar.create(penel4);
Progressbar1.parent:=penel4;
Progressbar1.align:=alLeft;
Progressbar1.Width:=175;
Progressbar1.Height:=20;
Progressbar1.Step:=1;
Progressbar1.Max:=100;
Progressbar1.Min:=0;
//ProgressBar1.PbColor:=Red;
frm.Show; // Initialice Variables
MiID:=0;
Activo:=0;
Activo2:=1;
PjinfoAct:=0;
PJInfoAct2:=1;
AutoSelect:=0;
AutoSelect2:=1;
MoveOK:=0;
MoveOK2:=1;
ShadowEterno:=1;
UsandoPot:=0;
BichosMuertos:=0;
Progressbar1.Position:=0;
//******************
timer1:=TTimer.Create(nil);
timer1.OnTimer:=@OnTimer1;
timer1.enabled:=true;
timer1.interval:=500;
//*****************
timer2:=TTimer.Create(nil);
timer2.OnTimer:=@OnTimer2;
timer2.enabled:=true;
timer2.interval:=500;
//******************
timer3:=TTimer.Create(nil);
timer3.OnTimer:=@OnTimer3;
timer3.enabled:=true;
timer3.interval:=1000;
//******************end;
procedure Free;
begin
m.Free;
frm.Free;
timer1.Free;
timer2.Free;
timer3.Free;
end;
procedure VerifID; // verify if i got my player IDbeginif(IDObtenida=1)and(MiID<>0)then m.Lines.Add('ID obtenida correctamente. ID: '+inttostr(MiID));
end;
procedure Memo1;
begin
Memorizar:=1;
NeedLoc:=1;
end;
procedure Memo2;
begin
Memorizar:=2;
NeedLoc:=1;
end;
procedure Memo3;
begin
Memorizar:=3;
NeedLoc:=1;
end;
procedure Memo4;
begin
Memorizar:=4;
NeedLoc:=1;
end;
procedure IrMemo1; // move to memory location 1begin
buf:=#$01;
WriteD(LocX1);
WriteD(LocY1);
WriteD(LocZ1);
WriteD(UltimaXa);
WriteD(UltimaYa);
WriteD(UltimaZa);
SendToServerEx(PJName);
m.Lines.Add('Ir Loc 1.');
end;
procedure IrMemo4; // move to memory location 4begin
buf:=#$01;
WriteD(LocX4);
WriteD(LocY4);
WriteD(LocZ4);
WriteD(UltimaXa);
WriteD(UltimaYa);
WriteD(UltimaZa);
SendToServerEx(PJName);
m.Lines.Add('Ir Loc 4.');
end;
procedure IrMemo2; // move to memory location 2begin
buf:=#$01;
WriteD(LocX2);
WriteD(LocY2);
WriteD(LocZ2);
WriteD(UltimaXa);
WriteD(UltimaYa);
WriteD(UltimaZa);
SendToServerEx(PJName);
m.Lines.Add('Ir Loc 2.');
end;
procedure IrMemo3; // move to memory location 3begin
buf:=#$01;
WriteD(LocX3);
WriteD(LocY3);
WriteD(LocZ3);
WriteD(UltimaXa);
WriteD(UltimaYa);
WriteD(UltimaZa);
SendToServerEx(PJName);
m.Lines.Add('Ir Loc 3.');
end;
procedure ActDes; // Bot On/Offbeginif Activo=1thenbegin
Activo:=0;
Activo2:=0;
Message:='Bot desactivado';
m.Lines.Add(Message);
end;
if(Activo=0)and(Activo2=1)thenbegin
Activo:=1;
Message:='Bot activado';
m.Lines.Add(Message);
end;
Activo2:=1;
end;
procedureReset; //not use :Pbeginend;
procedure PMoveOK; // Automatic movement On/Offbeginif MoveOK=1thenbegin
MoveOK:=0;
MoveOK2:=0;
Message:='Movimiento automatico desactivado.';
m.Lines.Add(Message);
end;
if(MoveOK=0)and(MoveOK2=1)thenbegin
MoveOK:=1;
Message:='Movomiento automatico activado.';
m.Lines.Add(Message);
end;
MoveOK2:=1;
end;
procedure AutoSel; // Auto Target On/Offbeginif AutoSelect=1thenbegin
AutoSelect:=0;
AutoSelect2:=0;
Message:='Auto Select desactivado';
m.Lines.Add(Message);
end;
if(AutoSelect=0)and(AutoSelect2=1)thenbegin
AutoSelect:=1;
Message:='Auto Select activado';
m.Lines.Add(Message);
end;
AutoSelect2:=1;
end;
//**********************************************************************// SKILL//procedure OnTimer1(Sender: TObject); // Skill usebeginif(TS=1)and(ATT=1)thenbegin{buf:=Hstr('2F 10 00 00 00 00 00 00 00 00 ');
SendToServer;
buf:=Hstr('45 02 00 00 00');
SendToServer;}
buf:=Hstr('2F 07 01 00 00 00 00 00 00 00');
SendToServerEx(PJName);
buf:=Hstr('45 02 00 00 00');
SendToServerEx(PJName);
end;
end;
//*************************************************// AUTO SELECT//procedure OnTimer2(Sender: TObject); // Targetnextbeginif(TS=0)and(AutoSelect=1){and (Espera=0)}thenbegin
buf:=Hstr('45 04 00 00 00'); // Selecciona.
SendToServerEx(PJName);
end;
end;
//*************************************************// ATACAR!!!//procedure OnTimer3(Sender: TObject); // Atackkkbeginif(Ts=1)thenbegin
buf:=Hstr('45 02 00 00 00'); // Ataca.
SendToServerEx(PJName);
ATT:=1;
end;
end;
//*********************************************procedure ContBichos; // Shows number of killed mobsbegin
m.lines.Add('.........................');
m.lines.Add('Total de Bichos matados: '+inttostr(BichosMuertos));
m.lines.Add('.........................');
end;
////000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000//begin// Obtener ID del PJ - Obtain Players IDif FromServer and(ConnectName=PJName)and(pck[1]=#$04)thenbegin
MiID:=ReadD(18);
IDObtenida:=1;
end;
// *****************************************************************************if FromServer and(ConnectName=PJName)and(pck[1]=#$01)then// Update Posbegin
IDTemporal:=ReadD(2);
if IDTemporal=MiID thenbegin
UltimaXa:=ReadD(6);
UltimaYa:=ReadD(10);
UltimaZa:=ReadD(14);
UltimaX:=ReadD(18);
UltimaY:=ReadD(22);
UltimaZ:=ReadD(26);
{m.Lines.Add('Recibido correctamente...');
m.Lines.Add('Coordenadas:');
m.Lines.Add(' Xa:'+inttostr(UltimaXa));
m.Lines.Add(' Ya:'+inttostr(UltimaYa));
m.Lines.Add(' Za:'+inttostr(UltimaZa));
m.Lines.Add(' X:'+inttostr(UltimaX));
m.Lines.Add(' Y:'+inttostr(UltimaY));
m.Lines.Add(' Z:'+inttostr(UltimaZ));}
IDActualizable:=1;
if NeedLoc=1thenbeginif Memorizar=1then// Updates memory Loc1begin
LocX1:=UltimaXa;
LocY1:=UltimaYa;
LocZ1:=UltimaZa;
Memorizar:=0;
m.Lines.Add('Memoria 1 actualizada.');
end;
if Memorizar=2then// Updates memory Loc2begin
LocX2:=UltimaXa;
LocY2:=UltimaYa;
LocZ2:=UltimaZa;
Memorizar:=0;
m.Lines.Add('Memoria 2 actualizada.');
end;
if Memorizar=3then// Updates memory Loc3begin
LocX3:=UltimaXa;
LocY3:=UltimaYa;
LocZ3:=UltimaZa;
Memorizar:=0;
m.Lines.Add('Memoria 3 actualizada.');
end;
if Memorizar=4then// Updates memory Loc4begin
LocX4:=UltimaXa;
LocY4:=UltimaYa;
LocZ4:=UltimaZa;
Memorizar:=0;
m.Lines.Add('Memoria 4 actualizada.');
end;
end;
end;
end;
//******************************************************************************if Activo=1thenbegin// Guarda valores de HP y MP - Update HP and MP Values// -----------------------------if FromServer and(ConnectName=PJName)and(pck[1]+pck[6]=#$0E#$04)thenbegin
CurHP:=ReadD(14);
MaxHP:=ReadD(22);
CurCP:=ReadD(30);
MaxCP:=ReadD(38);
if(CurHP<MaxHP/8)then// Me queda muy poca HP - If very little HP, Disapear!!begin
Shadow:=1;
end;
if(CurHP<MaxHP/1.8)and(UsandoPot=0)and(Shadow<>10)then// Little HP, Drink Potbegin
buf:=Hstr('14 54 D6 13 40 00 00 00 00'); // Poco HP ---- CAMBIAR CAMBIAR CAMBIAR CAMBIAR CAMBIAR
SendToServerEx(PJName);
//Message:='Menos de 66% de HP, tomo Pot';
m.Lines.Add('Tengo '+inttostr(CurHP)+'HP, tomo pot..');
UsandoPot:=1;
end;
if(CurHP=MaxHP)then// Tengo todo el HP - Full HP :Dbegin
Message:='HP al 100%';
m.Lines.Add(Message);
end;
if(CurCP<MaxCP/2)then// Me quieren PKear - Player ataks me, Desapear!!begin
Shadow:=3;
end;
Progressbar1.Position:=trunc((CurHP/MaxHp)*100);
end;
//****************************************************//********************************************************************// Muy poca vida// -----------------------if Shadow=1then// Disapear!!begin
buf:=Hstr('14 54 D6 13 40 00 00 00 00'); // Poco HP ---- CAMBIAR CAMBIAR CAMBIAR CAMBIAR CAMBIAR
SendToServerEx(PJName);
shade:=1;
buf:=#$48#$00#$00#$FE#$FF#$7F#$AB#$03#$00#$E9#$F1#$FF#$FF#$88#$D4#$00#$00#$00#$00#$00#$00;
SendToServerEx(PJName);
Message:='Menos del 10% de HP, desaparezco!';
m.Lines.Add(Message);
TS:=0;
ATT:=0;
Shadow:=10;
end;
//------------------------------------------------------------if Shadow=10then// Returnbeginif(CurHP>MaxHP/2)then Shadow:=2;
end;
//*************************************************************************// Volver de Shadowmelt// --------------------------if Shadow=2then// Returnbegin
shade:=0;
buf:=#$30#$00#$00;
SendToServerEx(PJName);
Message:='REcupere HP, volvi!';
m.Lines.Add(Message);
Shadow:=0;
Shadoweterno:=1;
end;
//****************************************************************************// Me PKean// ------------if Shadow=3then// Player atackssbegin
buf:=#$38;
WriteS('Chau PT!!!');
WriteD(0);
SendToServerEx(PJName);
shade:=1;
buf:=#$48#$00#$00#$FE#$FF#$7F#$AB#$03#$00#$E9#$F1#$FF#$FF#$88#$D4#$00#$00#$00#$00#$00#$00;
SendToServerEx(PJName);
Message:='Me ataco otro PJ y desapareci.';
m.Lines.Add(Message);
TS:=0;
ATT:=0;
delay (10000);
Shadow:=10;
end;
//**************************************************************************//*******************************************************************// Muerte// ----------------if FromServer and(ConnectName=PJName)and(pck[1]=#$06)then// Mob diedbegin
ATT:=0; // No ataca
TS:=0; // No tiene nada seleccionado
buf:=Hstr('45 05 00 00 00'); // Levantar drop
SendToServerEx(PJName);
m.Lines.Add('------------ Bicho muerto.........');
BichosMuertos:=BichosMuertos+1;
end;
//***********************************************************************// Selecciono?????// ----------------------if FromServer and(ConnectName=PJName)and(pck[1]=#$A6)then// Target selectedbegin
TS:=1;
end;
//*********************************************************************// Unselected???// ----------------if FromServer and(ConnectName=PJName)and(pck[1]=#$A2)then//Target not selected, Select!!begin
TS:=0;
ATT:=0;
buf:=Hstr('45 04 00 00 00'); // selecciona. (Target Next)
SendToServerEx(PJName);
end;
if TS=0thenbegin
buf:=Hstr('45 04 00 00 00'); // selecciona. (Target Next)
SendToServerEx(PJName);
buf:=Hstr('45 05 00 00 00'); // Levantar drop
SendToServerEx(PJName);
end;
if MoveOK=1thenbeginif(Contador=1)and(TS=0)then IrMemo1; // Move to locations...if(Contador=100)and(TS=0)then IrMemo2;
if(Contador=200)and(TS=0)then IrMemo3;
if(Contador=300)and(TS=0)then IrMemo4;
end;
Contador:=Contador+1;
IF Contador>400then Contador:=0;
if shade = 1thenbeginif FromClient and(pck[1]=#$30)then pck:='';
end;
//if FromServer and (pck[1]+pck[2]+pck[3]=#$7f#$00#$00) then UsandoPot:=0;if FromServer and(ConnectName=PJName)and(pck[1]+pck[2]+pck[3]+pck[4]+pck[5]+pck[6]+pck[7]+pck[8]+pck[9]+pck[10]+pck[11]+pck[12]+pck[13]+pck[14]+pck[15]+pck[16]+pck[17]+pck[18]+pck[19]+pck[20]+pck[21]=Hstr('64 5C 00 00 00 01 00 00 00 04 00 00 00 F5 07 00 00 01 00 00 00'))then UsandoPot:=0;
if FromServer and(ConnectName=PJname)and(pck[1]=#$27)and(pck[12]=#$03)and(pck[13]=#$06)thenbegin
PotID1:=ReadC(6);
PotID2:=ReadC(7);
PotID3:=ReadC(8);
PotID4:=ReadC(9);
m.Lines.Add('Greater Healing Potion');
m.Lines.Add('ObjectID='+inttostr(PotID1)+inttostr(PotID2)+inttostr(PotID3)+inttostr(PotID4));
end;
end;
end.
--------------------------------------------------------------------------
I know it is a dissaster but it finished like that because it started as a little simple script, but then i added some lines, then other and other and other... I have to re-write it also, but it requires time, that i don't have...
Maybe some parts are useful to some body, that is why i posted it...
If some one have some question about the scripts, just ask
Charly.
P.S.: i entered the code using CODE between [], and at the end /CODE, also between [], but the reserved words as "procedure" didn't appeared highlighted, am i doing it well???
--> Edited, now it's ok
--> New edit, i added some explanations of the code....
Последний раз редактировалось charly911, 25.08.2008 в 02:20.
P.S.: i entered the code using CODE between [], and at the end /CODE, also between [], but the reserved words as "procedure" didn't appeared highlighted, am i doing it well???