program AMM8;
var ksm,magec, ksmy, ksmx, ksmw, ksu, ksd, ksr, ksl,clickheal, hit:integer;
var x,w,y, skip,z, monster1, monsterM,sx, sy, xx, yy, t, ptts: Integer;
var clx, cly, ksosx, ksosy, setclx, setcly, ksoffsetx, ksoffsety:integer;
var ptx, pty, tr, relogtime, relogtimer,buypotsX, buypotsY:integer;
var window:string;
var ksS, selfbox: TBox;
const


user='username';
pass='password';
share=0;  //1 is on //anything else is off



Procedure ReadString(str: String);{by rena: START}
var
i,strLength :Integer;
goer: Boolean;

begin
i:=1
strLength:=Length(str)
goer:=False
while(i<strLength+1) do
begin
if(GetKeyCode(StrGet(str,i))=191)then
begin
KeyDown(16)
goer:=True
i:=i+1
end;
KeyDown(GetKeyCode(StrGet(str,i)))
wait(10)
KeyUp(GetKeyCode(StrGet(str,i)))
wait(100)
KeyUp(GetKeyCode(StrGet(str,i)))
wait(50)
i:=i+1
if(goer=True)then
begin
KeyUp(16)
wait(600)
end;
end;
wait(300)
end;{by rena: END}
Procedure relog;
var char:integer;
begin   //
char:=1
clickmouse(600, 50, true);wait(500);
findcolorspiral2(x, y, 10079232, 10, 10, 640, 350);clickmouse(x, y, true)
wait(1000)
repeat
clickmouse(400, 224, true);wait(700);clickmouse(400, 324, true);wait(700)
until (findcolorspiral (x, y, 255,17, 359, 54, 496)=false)
repeat clickmouse(115, 375, true);wait(500)
until ((findcolorspiral(x, y, 255, 276, 322,575, 343)) or
(findcolorspiral(x, y, 10079232, 358, 307, 449, 332)))
clickmouse(414, 353, true);wait(500);
if(findcolorspiral (x, y, 255,17, 359, 54, 496)=false)then begin;
readstring(user);clickmouse(414, 388, true);wait(500);readstring(pass);wait(500)
clickmouse(409, 428, true);wait(3000);end
if findcolorspiral(x, y, 10079232,357, 305, 444, 333) then begin
clickmouse(380, 315, true);wait(500);pty:=4545 end

if ((findcolorspiral(x, y, 255,280, 323, 574, 343)=false)and(pty=4545)=false )
then begin
wait(500);clickmouse(534, (124*(char)), true);wait(500);
repeat until((findcolorspiral (x, y, 255,17, 359, 54, 496))OR
(findcolorspiral(x, y, 255,280, 323, 574, 343))) end
pty:=0   ;wait(500);
clickmouse(608, 446, true)
wait(500)
if (findcolorspiral(x, y,13158600,465, 455, 469, 459)=false) then begin
if (not(share=1))then begin
clickmouse(567, 461, true);wait(200)
end
end
if (findcolorspiral(x, y,13158600,465, 455, 469, 459)) then begin
if (share=1)then begin
clickmouse(567, 461, true);wait(200)
end
wait(100);clickmouse(80,446,true);wait(100)
end


end;   //
Procedure check_dc;
var char:integer;
begin   //
char:=1
if (((findcolorspiral (x, y, 10079232, 410, 210, 458, 287)
or (findcolorspiral(x, y, 255,17, 359, 54, 496)=false)))and
((user='no relog')=false)) then begin repeat
clickmouse(400, 224, true);wait(700);clickmouse(400, 324, true);wait(700)
until (findcolorspiral (x, y, 255,17, 359, 54, 496)=false)
repeat clickmouse(115, 375, true);wait(500)
until ((findcolorspiral(x, y, 255, 276, 322,575, 343)) or
(findcolorspiral(x, y, 10079232, 358, 307, 449, 332)))
clickmouse(414, 353, true);wait(500);
if(findcolorspiral (x, y, 255,17, 359, 54, 496)=false)then begin;
readstring(user);clickmouse(414, 388, true);wait(500);readstring(pass);wait(500)
clickmouse(409, 428, true);wait(3000);end
if findcolorspiral(x, y, 10079232,357, 305, 444, 333) then begin
clickmouse(380, 315, true);wait(500);pty:=4545 end


if ((findcolorspiral(x, y, 255,280, 323, 574, 343)=false)and(pty=4545)=false )
then begin
wait(500);clickmouse(534, (124*(char)), true);wait(500);
repeat until((findcolorspiral (x, y, 255,17, 359, 54, 496))OR
(findcolorspiral(x, y, 255,280, 323, 574, 343))) end
pty:=0
clickmouse(608, 446, true)
wait(500)
if (findcolorspiral(x, y,13158600,465, 455, 469, 459)=false) then begin
if (not(share=1))then begin
clickmouse(567, 461, true)
end
end
if (findcolorspiral(x, y,13158600,465, 455, 469, 459)) then begin
if (share=1)then begin
clickmouse(567, 461, true)
end
end
end

if ((findcolorspiral2(x, y, 10079232, 260, 208, 290, 238))
and (share=1)) then begin
clickmouse(x, y, true); wait(600)
if findcolorspiral2(x, y, 10079232, 354, 208, 442, 239)then begin
clickmouse(x, y, true);wait(600);
end
if findcolorspiral2(x, y, 6711039, 500, 291, 585, 319)then begin
clickmouse(x, y, true);wait(600);
end
wait(100);clickmouse(80,446,true);wait(100)
end

end;   //


begin

t:=1    //1 is right, 2 is left
tr:=1
relogtimer:=100

monster1:= 1638350;
monsterM:= 1638350;
ptts:=0


selfbox:=IntToBox(270, 144, 364, 199);
if (findwindowtitlepart('endless online', false)=false) then
begin
writeln('Endless Online is not running... Script Terminated.')
terminatescript;
end
cleardebug;
setclx:=641
setcly:=507
findwindowtitlepart('endless online', false)
wait(300)
GetClientDimensions(clx, cly)
writeln('Your Client size is  X: '+inttostr(clx)+'  -  Y:'+inttostr(cly))
ksosx:=setclx-clx
ksosy:=setcly-cly
writeln('Your Offset is       X: '+inttostr(ksosx)+'  -  Y:'+inttostr(ksosy))
ksoffsetx:=313-ksosx
ksoffsety:=489-ksosy
writeln('Your KS Detection is X: '+inttostr(ksoffsetx)+'  -  Y:'+inttostr(ksoffsety))
wait(1000)
   activateclient; WAIT(2000)
clickmouse(608, 446, true)
wait(500)
if (findcolorspiral(x, y,13158600,465, 455, 469, 459)=false) then begin
if (not(share=1))then begin
clickmouse(567, 461, true);wait(200)
end
end
if (findcolorspiral(x, y,13158600,465, 455, 469, 459)) then begin
if (share=1)then begin
clickmouse(567, 461, true);wait(200)
end
end
if (getcolor(34, 403)=255) then begin
clickmouse(80,446,true);wait(100)
end


repeaT
begin
z:=0
if tr=1 then begin
t:=(random(2)+1);writeln('Direction: '+inttostr(t));end

check_dc





if findcolorspiral(x, y,9175295,306, 103, 332, 126) then begin
ksl:=0;
ksr:=0;
ksd:=0;
ksu:=0;
end
repeat
z:=z+1

if (
   ( findcolorspiral(x, y,9175295,306, 86, 334, 104) )
and( findcolorspiral (x, y, monster1, 275, 154, 303, 174)=false )
and( findcolorspiral (x, y, monster1, 336, 182, 363, 209)=false )
and( findcolorspiral (x, y, monster1, 323, 157, 350, 165)=false )
and( findcolorspiral (x, y, monster1, 288, 184, 300, 194)=false )
){AMM8 by joeyroyden / EoBots}
then begin
keydown(123);wait(500);keyup(123)
end



  writeln(inttostr(z)+'-'+inttostr(w))
if(z=100)then
begin
z:=0
keydown(123)
wait(200)
keyup(123)
end
if (findcolorspiral (x, y, monster1,275, 154, 303, 174)=false)then begin
ksl:=0; end
if ((findcolorspiral (x, y, monster1, 275, 154, 303, 174))and(ksl=0)) then
begin
if(FindColorSpiral(x, y, 16235924, 153, 27, 155, 33))then
begin

clickmouse(78, 364, true)
if findcolorspiral(ptx, pty, 32896,114, 364, 476, 468)then begin
clickmouse(ptx, pty, true)
wait(8)
clickmouse(ptx, pty, true)
sleep (350)
ptts:=ptts+1;writeln('Used '+inttostr(ptts)+' Potions since you started AMM8')
end
end else
begin
writeln('No Healing Required')
wait(50);keydown(37)
wait(50)
keyup(37)
wait(20)
keydown(17)
wait(10)
keyup(17)
wait(100);

check_dc

keydown(17)
wait(10)
keyup(17)
wait(100);

skip:=skip-1
magec:=0
hit:=1
if(getcolor(ksoffsetx, ksoffsety)=0)then begin
ksl:=1;RELOGTIME:=RELOGTIME+8
end
end
end
until ((findcolorspiral(x, y, monster1, 275, 154, 303, 174)=false)or(ksl=1))
keyup(17)
wait(200)
{AMM8 by joeyroyden / EoBots}
if ((findcolorspiral(x, y, monsterM, 13, 61, 627, 331)=false) and (hit=1))
then begin
wait(randomrange(500, 1000))
hit:=0
sendarrowwait(t, 5)
end

repeat
z:=z+1
writeln(inttostr(z)+'-'+inttostr(w))
if(z=100)then
begin
z:=0
keydown(123)
wait(200)
keyup(123)
end
if (findcolorspiral (x, y, monster1,329, 176, 358, 196)=false)then begin
ksr:=0
end
if ((findcolorspiral (x, y, monster1, 329, 176, 358, 196))and(ksr=0)) then
begin
IF (FindColorSpiral(x, y, 16235924, 153, 27, 155, 33))then
begin {AMM8 by joeyroyden / EoBots}

clickmouse(78, 364, true)
if findcolorspiral(ptx, pty, 32896,114, 364, 476, 468)then begin
clickmouse(ptx, pty, true)
wait(8)
clickmouse(ptx, pty, true)
sleep (350)
ptts:=ptts+1;writeln('Used '+inttostr(ptts)+' Potions since you started AMM8')
end
end else
begin
writeln('No Healing Required')
wait(50);keydown(39)
wait(50)
keyup(39)
wait(20)
keydown(17)
wait(10)
keyup(17)

check_dc

keydown(17)
wait(10)
keyup(17)
wait(100);


wait(100);skip:=skip-1
magec:=0
if (t=2) then begin
hit:=1
end
if (t=1) then begin
hit:=0
end
if(getcolor(ksoffsetx, ksoffsety)=0)then begin
ksr:=1 ;RELOGTIME:=RELOGTIME+8
end
end
end
until ((findcolorspiral(x, y, monster1, 336, 182, 363, 209)=false)or(ksr=1))
keyup(17)
wait(200)
if ((findcolorspiral(x, y, monsterM, 13, 61, 627, 331)=false) and (hit=1)
and (t=2))
then begin
wait(randomrange(500, 1000))
hit:=0
sendarrowwait(t, 5)
end

if(getcolor(ksoffsetx, ksoffsety)=0)then begin
ksm:=1
ksmx:=xx
ksmy:=yy
ksmw:=1
end
repeat
z:=z+1
  writeln(inttostr(z)+'-'+inttostr(w))
if(z=100)then
begin
z:=0
keydown(123)
wait(200)
keyup(123)
end {AMM8 by joeyroyden / EoBots}
if (findcolorspiral (x, y, monster1,323, 157, 350, 165)=false)then begin
ksu:=0
end
if ((findcolorspiral (x, y, monster1, 323, 157, 350, 165))and(ksu=0)) then   ///////////////////////////////
begin
IF (FindColorSpiral(x, y, 16235924, 153, 27, 155, 33))then
begin {AMM8 by joeyroyden / EoBots}

clickmouse(78, 364, true)
if findcolorspiral(ptx, pty, 32896,114, 364, 476, 468)then begin
clickmouse(ptx, pty, true)
wait(8)
clickmouse(ptx, pty, true)
sleep (350)
ptts:=ptts+1;writeln('Used '+inttostr(ptts)+' Potions since you started AMM8')
end
end else
begin
writeln('No Healing Required')
wait(50);keydown(38)
wait(50)
keyup(38)
wait(20)
keydown(17)
wait(10)
keyup(17)
wait(100);skip:=skip-1

check_dc

keydown(17)
wait(10)
keyup(17)
wait(100);


magec:=0
hit:=1
if(getcolor(ksoffsetx, ksoffsety)=0)then begin
ksu:=1 ;RELOGTIME:=RELOGTIME+8
end
end
end
until ((findcolorspiral(x, y, monster1, 323, 157, 350, 165)=false)or(ksu=1))
keyup(17)
wait(200)
if ((findcolorspiral(x, y, monsterM, 13, 61, 627, 331)=false) and (hit=1))
then begin
hit:=0
wait(randomrange(500, 1000))
sendarrowwait(t, 5)
end
repeat
z:=z+1
  writeln(inttostr(z)+'-'+inttostr(w))
if(z=100)then
begin
z:=0
keydown(123)
wait(200)
keyup(123)
end
if (findcolorspiral (x, y, monster1,288, 184, 300, 194)=false)then begin
ksd:=0
end
if ((findcolorspiral (x, y, monster1, 288, 184, 300, 194))and(ksd=0)) then
begin
IF (FindColorSpiral(x, y, 16235924, 153, 27, 155, 33))then
begin
clickmouse(78, 364, true)
if findcolorspiral(ptx, pty, 32896,114, 364, 476, 468)then begin
clickmouse(ptx, pty, true)
wait(8)
clickmouse(ptx, pty, true)
sleep (350)
ptts:=ptts+1;writeln('Used '+inttostr(ptts)+' Potions since you started AMM8')
end
end else
begin
writeln('No Healing Required')
wait(50);keydown(40)
wait(50)
keyup(40)
wait(20)
keydown(17)
wait(10)
keyup(17)
wait(100);skip:=skip-1

check_dc

keydown(17)
wait(10)
keyup(17)
wait(100);

magec:=0
if (t=2) then begin
hit:=0
end
if (t=1) then begin
hit:=1
end
if(getcolor(ksoffsetx, ksoffsety)=0)then begin
ksd:=1 ;RELOGTIME:=RELOGTIME+8
end
end
end
until ((findcolorspiral(x, y, monster1, 288, 184, 300, 194)=false)or(ksd=1))
keyup(17){AMM8 by joeyroyden / EoBots}
if ((findcolorspiral(x, y, monsterM, 13, 61, 627, 331)=false) and (hit=1)
and (t=1))
then begin
wait(randomrange(500, 1000))
hit:=0
sendarrowwait(t, 5)
end
end
if (findcolorspiral (x, y,monsterm, 13, 61, 627, 331)=false)then
begin
magec:=0
IF (GETCOLOR(201, 31)=16235924)then begin    /////////mage heal
repeat
wait(100)
KEYDOWN(115)
WAIT(800)
KEYUP(115)
WAIT(450)
until (((GETCOLOR(201, 31)=16235924)=false)
or (findcolorspiral(x, y, monster1, 13, 61, 627, 331)))
end
wait(750)
if(FindColorSpiral(x, y,61373, 13, 61, 627, 331))then
begin
repeat
FindColorSpiral(x, y,61373, 13, 61, 627, 331)
movemousesmooth(x, y);wait(200);clickmouse(x, y, true)
wait(80)
clickmouse(x, y, true)
until((FindColorSpiral(x, y,61373, 13, 61, 627, 331)=false)
or(findcolorspiral(x, y, monster1, 13, 61, 627, 331)))
end
cleardebug;
if (findcolorspiral(x, y, monsterm, 13, 61, 627, 331)=false) then begin
ksm:=0
end
if (ksm=0) then begin
  ksS := IntToBox(0, 0, 5, 5); end
writeln('AMM8 Mage - By Joeyroyden - is waitting for a monster. (Direction: '+inttostr(t)+')')
writeln('Http://eobots.myteamtoolbar.com for quick links to other scripts')

writeln('Used '+inttostr(ptts)+' Potions since you started AMM8')
IF (findcolorspiral(x, y, monster1, 267, 144, 358, 199)=false) THEN BEGIN
relogtime:=0
END

if (findcolorspiral(x, y, monster1, 13, 61, 627, 331)=false) then begin
clickmouse(489, 33, true);wait(300)
end

repeat

if (isfkeydown(1) and isfkeydown(3))then begin
getmousepos(buypotsX, buypotsY);wait(200);keydown(52);wait(100)
repeat
clickmouse(buypotsX, buypotsY, true);wait(50);
clickmouse(322, 230, true);wait(50);clickmouse(322, 230, true);wait(50);
until ((isfkeydown(2) and isfkeydown(4))or
(findcolorspiral(x, y, 10079232, 385, 211, 440, 236)))
keyup(52);wait(100);
end
if findcolorspiral2(x, y, 10079232, 385, 211, 440, 236)then begin
clickmouse(x, y, true);wait(1000)
end

IF((getcolor(198, 33)=16235924)and(getcolor(239, 34)=16235924)///
and (findcolorspiral(x, y, monsterm, 267, 144, 358, 199)=false))then begin
keydown(112);wait(400);clickmouse(318, 137, true);keyup(112);wait(1200)
end
if ((findcolorspiral (ptx, pty, 3788395, 127, 382, 477, 469))
and (not(getcolor(311, 33)=16235924))) then begin
clickmouse(ptx, pty, true);wait(10);clickmouse(ptx, pty, true)
end ///
check_dc

if (
   ( findcolorspiral(ptx, pty,9175295,306, 86, 334, 104) )
and( findcolorspiral (ptx, pty, monster1, 275, 154, 303, 174)=false )
and( findcolorspiral (ptx, pty, monster1, 336, 182, 363, 209)=false )
and( findcolorspiral (ptx, pty, monster1, 323, 157, 350, 165)=false )
and( findcolorspiral (ptx, pty, monster1, 288, 184, 300, 194)=false )
) {AMM8 by joeyroyden / EoBots}
then begin
keydown(123);wait(500);keyup(123)
end

if(FindColorSpiral(x, y,8716032,244, 149, 398, 224))then
begin
FindColorSpiral(x, y,8716032, 244, 149, 398, 224)
movemousesmooth(x, y);wait(200);clickmouse(x, y, true);wait(500)

end
IF (FindColorSpiral(x, y, 16235924, 153, 27, 155, 33))then
begin {AMM8 by joeyroyden / EoBots}

clickmouse(78, 364, true)
if findcolorspiral(ptx, pty, 32896,114, 364, 476, 468)then

begin
clickmouse(ptx, pty, true)
wait(8)
clickmouse(ptx, pty, true)
sleep (350)
ptts:=ptts+1;writeln('Used '+inttostr(ptts)+' Potions since you started AMM8')
end

end else begin
if (x=0) then begin
x:=x+1
writeln('Used '+inttostr(ptts)+' Potions since you started AMM8')
end
end
until (findcolorspiral(x, y, monster1, 13, 61, 627, 331)=true)
end
RELOGTIME:=RELOGTIME+1
writeln('relog timer: '+inttostr(relogtimer - relogtime))
IF ((RELOGTIME>relogtimer)and(not(user='no relog'))) THEN BEGIN
relogtime:=0
RELOG
END

skip:=skip-1;writeln('skip: '+inttostr(skip))
if FindColorSkipBox(sx, sy, monsterm, 13, 61, 627, 331, selfbox)then
begin
if (findcolorspiral2(xx, yy, monsterM, 11, 63, 626, 335)=true)then begin
if ((findcolorspiral2 (x, y, monsterm, ksmx-75, ksmy-75, ksmx+75, ksmy+75)=false))
then begin
ksm:=0
ksmw:=0
magec:=0
end
if (ksm=1) then begin
  ksS := IntToBox((ksmx-90), (ksmy-90), (ksmx+90), (ksmy+90)); end
if (ksm=0) then begin
  ksS := IntToBox(0, 0, 5, 5); end
  if(FindColorSkipBox(sx, sy, monsterM, 13, 61, 627, 331, ksS))then begin
if((findcolorspiral (x, y, monster1,275, 154, 303, 174)=false)
and
(findcolorspiral (x, y, monster1,336, 182, 363, 209)=false)
and
(findcolorspiral (x, y, monster1,323, 157, 350, 165)=false)
and {AMM8 by joeyroyden / EoBots}
(findcolorspiral (x, y, monster1,288, 184, 300, 194)=false))then begin
FindColorspiral2(sx, sy, monsterM, 13, 61, 627, 331)
wait(50)
if magec=0 then begin
writeln('Go')
keydown(113)
wait(25)
keyup(113)
wait(50)
clickmouse(sx, sy, true)
wait(randomrange(900, 900))
magec:=0

end
end
ksmw:=0
skip:=1
if(getcolor(ksoffsetx, ksoffsety)=0)then begin
ksm:=1
ksmx:=xx
ksmy:=yy
ksmw:=1
end
end
end
wait(100)
if(getcolor(ksoffsetx, ksoffsety)=0)then begin
ksm:=1
ksmx:=xx
ksmy:=yy
ksmw:=1
end
if(getcolor(ksoffsetx, ksoffsety)=0)then begin
ksm:=1
ksmx:=xx
ksmy:=yy
ksmw:=1
end

check_dc

if findcolorspiral(x, y,9175295,306, 103, 332, 126) then begin
ksl:=0;
ksr:=0;
ksd:=0;
ksu:=0;
end
end
until(x = 500000000)
end.