Code: Select all
program mining;
{$Include 'all.inc'}
const
xa = 6;
ya = 6;
xb = -6;
yb = -6;
pixt = $0e85;
bcheese = $097e;
mcheese = $097d;
scheese = $097c;
guardmode = 0;
tilenum = 1339;
tilenummax = 1344;
var
posx,posy : array[1..250] of integer;
PickaxeID : cardinal;
stime,gtime : TDateTime;
c,max : integer;
Exitflag : boolean;
stx,sty : integer;
// ----------------------------------------------------------------
// 2)
procedure RestoreStamina;
// если стамины мало, восстанавливаем ее чару до половины
begin
if (connected) and (Stam < 5) then
begin
repeat
wait(1000);
waitconnection(10000);
until Stam > 25;
end;
end;
// 1)
procedure GotoXY(x,y,prec : integer; runflag : boolean);
// x,y - координаты, в которые идем
// prec - точность подхода
// runflag - бежать или идти
// v. 1.04 (с) Edred, скрипт портирован с инжекта
// оригинальная версия Yoko с доработкой AGRS и Edred.
var ld, ldc, dx, dy, mx, my : Integer;
begin
ld := 0; ldc := 0;
while true do
begin
dx := GetX(self) - x; if dx < 0 then dx := 0 - dx;
dy := GetY(self) - y; if dy < 0 then dy := 0 - dy;
if dy > dx then dx := dy;
if dx <= prec then exit;
mx := GetX(self); my := GetY(self);
dx := mx - x; if dx < 0 then dx := 0 - dx;
dy := my - y; if dy < 0 then dy := 0 - dy;
if dy > dx then dx := dy;
if dx <= prec then exit;
if ld = dx then begin
RestoreStamina;
ldc := ldc + 1;
if ldc > 10 then begin addtosystemjournal( 'GotoXY: Cannot reach location!' ); exit; end;
end
else ld := dx;
waitconnection(10000);
if mx = x then begin
if my = y then exit;
// North
if my > y then begin Raw_Move(0,runflag); continue; end;
// South
Raw_Move(4,runflag); continue;
end;
if mx < x then begin
// Northeast
if my > y then begin Raw_Move(1,runflag); continue; end;
// East
if my = y then begin Raw_Move(2,runflag); continue; end;
// Southeast
Raw_Move(3,runflag); continue;
end;
// Southwest
if my < y then begin Raw_Move(5,runflag); continue; end;
// West
if my = y then begin Raw_Move(6,runflag); continue; end;
// Nortwest
Raw_Move(7,runflag); continue;
end;
end;
// 3)
procedure checkpix;
begin
waitconnection(10000);
if (GetType(ObjAtLayer(RhandLayer)) <> pixt) then
begin
if (ObjAtLayer(RhandLayer) <> 0) then
begin
waitconnection(10000);
checksave;
Disarm;
wait(2000);
end;
WaitConnection(10000);
PickaxeID:=FindTypeEx(pixt,$FFFF,backpack,true);
if findcount < 1 then begin exitflag:=true; Exit; end;
CheckSave();
equip(RhandLayer,PickaxeID);
wait(2000);
CheckSave();
WaitConnection(10000);
end
else
begin
CheckSave();
WaitConnection(20000)
end;
end;
// 4)
procedure guards;
var n : integer;
begin
if (guardmode = 0) then Exit;
n:=injournal('attacking you');
if (n <> -1) then
begin
uosay('.guards');
gtime:=now;
SetJournalLine(n,' ');
end;
if (not dead) and (maxlife-life>7) and (now-stime > EncodeTime(0,0,7,0)) then
begin
uosay('.guards');
gtime:=now;
end;
end;
// 5)
procedure checkandset;
begin
Exitflag:=false;
gtime:=now-EncodeTime(0,0,10,0);
if (xb>xa) or (yb>ya) then
begin
AddToSystemJournal('Wrong coords, exiting!');
Exitflag:=true;
end;
stx:=getx(self);
sty:=gety(self);
end;
// 6)
procedure minearound;
var kx,ky,k,i,j : integer;
begin
kx:=getx(self);
ky:=gety(self);
for i:=-2 to 2 do
for j:=-2 to 2 do
begin
checkpix;
if (connected) and ((Exitflag) or (dead)) then Exit;
waitconnection(10000);
if TargetPresent then CancelTarget;
stime := Now;
useobject(PickaxeID);
WaitForTarget(5000);
TargetToTile(tilenum, (kx+i), (ky+j), getz(self));
k := 0;
repeat
guards;
// if (InJournal('пойти добывать')<>-1) or (k > 300) then begin
// useobject(PickaxeID);
// WaitForTarget(5000);
// TargetToTile(tilenummax, (kx+i), (ky+j), getz(self));
// end;
wait(1000);
k := k + 1;
checksave;
CheckTargetError(2,2);
until (InJournalBetweenTimes('инструмент|прекратили|слишком',stime, Now)<>-1) or (k > 300) or (not connected) or (dead);
end;
end;
// 7)
procedure razbienie;
var sx,sy : integer;
begin
sx:=getx(self)+xb;
sy:=gety(self)+yb;
max:=1;
while sy<sty+ya do begin
while sx<stx+xa do
begin
posx[max]:=sx+2;
posy[max]:=sy+2;
sx:=sx+5;
max:=max+1;
end;
sx:=getx(self)+xb;
sy:=sy+5;
end;
end;
// ----------------------------------------------
Begin
Disarm;
wait(500);
checkandset;
razbienie;
while (true) do
begin
if (connected) and ((Exitflag) or (dead)) then Exit;
for c:=1 to max-1 do
begin
if (connected) and ((Exitflag) or (dead)) then Exit;
waitconnection(10000);
checksave;
GotoXY(posx[c],posy[c],0,false);
wait(500);
waitconnection(10000);
checksave;
minearound;
end;
end;
AddToSystemJournal('End of script');
End.