память влпрос
Posted: 04.11.2014 17:03
by Roman
из-за чего скрипт может постоянно жрать память? примерно +10 метров за 20 минут? что может на это влиять?
скрипт
program mining_for_bot;
const
tminertool = $0F39;
resoursesbox = $4026C3B9; // сундук для остального
orebox = $42C21DA4; // сундук для руды
toolsbox = $4098DB65; // сундук с лопатами
ore = $19B7;
runebookshift = 5; // 7 - чива, 5 магия.
lagwait = 15000;
hy = 3615; // координата y тайла на который телепортируемся
minhx = 515; // Квадрат по ширине ступенек перед домом.
maxhx = 528; // Если чар попадает в этот квадрат то бежит
minhy = 3619; // по оси (-Y) на N до тайла со ступеньками
maxhy = 3621; // на которых телепорты
var
stime : tdatetime;
currentrune,currentbook : integer;
resourses,killers,orecolor,oretype : array of word;
minerb,homerb : array of integer;
open,protect : string;
rec,cpk : boolean;
procedure writetofile(filepath : string ; data : string);
var mode : word;
begin
if fileexists(filepath) then mode := fmopenreadwrite
else mode := fmcreate;
with tfilestream.create(filepath,mode) do
try
seek(0,sofromend);
writebuffer(data,length(data)*2);
finally
free;
end;
end;
procedure check_notoriety(id : cardinal);
var ntrt : byte;
begin
ntrt := getnotoriety(id);
if (ntrt > 3) and (ntrt < 7) then
setglobal('char','enemy',inttostr(id));
end;
procedure drawobject(id : cardinal);
begin
check_notoriety(id);
end;
procedure drawcontainer(id,modelgump : integer);
begin
//addtosystemjournal('id = ' + inttostr(id) + ' modelgump = ' +inttostr(modelgump));
if id = resoursesbox then
open := 'resoursesbox';
if id = orebox then
open := 'orebox';
if id = toolsbox then
open := 'toolsbox';
end;
function BoolToStr(const value : boolean) : string;
begin
if value then Result := 'True' else Result := 'False';
end;
procedure buff_debuffsystem(id : integer ; attribute_id : word ; isenabled : boolean);
begin
//addtosystemjournal('id = ' + inttostr(id) + ' attribute_id = ' + inttostr(attribute_id) + ' isenabled = ' + booltostr(isenabled));
clientprint('buffchecker called');
if attribute_id = 1029 then
if isenabled then
begin
protect := 'ptotected'
addtosystemjournal('ptotected');
end
else
begin
protect := 'none';
addtosystemjournal('protect none');
end;
end;
procedure checksave(checktime:tdatetime);
begin
if injournalbetweentimes('The world is saving, please wait.',checktime,now)>=0 then
begin
addtosystemjournal('The world is saving, please wait.');
waitjournalline(checktime,'World save complete.',10000);
addtosystemjournal('World save complete.');
end;
end;
procedure backpack_items_ignore(item_type : word);
begin
repeat
findtype(item_type,backpack);
wait(50);
if findcount <> 0 then
ignore(finditem)
else
exit;
until false;
end;
procedure init_all;
var
hrb1,hrb2,hrb3,mrb1,mrb2,mrb3,ia : integer;
begin
if dead then exit;
orecolor := [$0000,$0973,$0966,$096D,$0972,$08A5,$0979,$089F,$08AB];
oretype := [$19BA,$19B8,$19B9];
resourses := [$3192,$3193,$3194,$3195,$3196,$3197,$3198,$3199]; // Сюда вписывать type того что складывать в сундук с ресурсами
killers := [$0190,$0191,$025E,$025D,$029A,$029B,$02ED,$02EA,$02EC]; // check pk
while findtype($22C5,backpack) > 0 do
begin
if bmsearch(1,gettooltip(finditem),'home') <> 0 then
hrb1 := finditem;
if bmsearch(1,gettooltip(finditem),'mining') <> 0 then
if mrb1 <> 0 then
if mrb2 <> 0 then
mrb3 := finditem
else
mrb2 := finditem
else
mrb1 := finditem;
if bmsearch(1,gettooltip(finditem),'pk') <> 0 then
if hrb2 <> 0 then
hrb3 := finditem
else
hrb2 := finditem;
ignore(finditem);
end;
ignorereset;
homerb :=[hrb1,hrb2,hrb3];
minerb :=[mrb1,mrb2,mrb3];
for ia := 0 to length(homerb)-1 do
if ia = 0 then
addtosystemjournal('home rb = $' + inttohex(homerb[ia],8))
else
if ia = 1 then
addtosystemjournal('pk rb = $' + inttohex(homerb[ia],8))
else
addtosystemjournal('pk rb 2 = $' + inttohex(homerb[ia],8));
for ia := 0 to length(minerb)-1 do
begin
if ia = 0 then
addtosystemjournal('mining rb = $' + inttohex(minerb[ia],8))
else
addtosystemjournal('mining rb ' + inttostr(ia + 1) + ' = $' + inttohex(minerb[ia],8));
end;
end;
function check_item_count_in_box(container : integer) : integer;
var i : integer;
fs,ss,ts : tstringlist;
Begin
fs := tstringlist.create; //лист первой сепарации
ss := tstringlist.create; //лист второй сепарации
ts := tstringlist.create; //лист третьей сепарации
strbreakapart(gettooltip(container),'|',fs);
if fs.count > 0 then
for i := 0 to fs.count - 1 do
if bmsearch(1,fs.strings,'Contents') <> 0 then
begin
strbreakapart(fs.strings,' ',ss);
if ss.count > 0 then
begin
strbreakapart(ss.strings[1],'/',ts);
result := (strtoint(ts.strings[0]));
end;
end;
fs.free;
ss.free;
ts.free;
end;
function items_count(item_type : word ; container : cardinal) : integer;
begin
findtype(item_type,container);
result := findcount;
end;
procedure checkdress;
var
ignored_item : array [0..12] of word;
a,b : word;
c,x,y : integer;
begin
if objatlayer(1) = 0 then
begin;
while objatlayer(22) <> 0 do
begin
unequip(22);
wait(500);
checklag(lagwait);
end;
while findtypeex($1F03,$08FD,backpack,false) <> 0 do
begin
for x := -1 to 1 do
begin
for y := -1 to 1 do
begin
moveitem(finditem,1,ground,getx(self) + x,gety(self) + y,getz(self));
waitfortarget(500);
checklag(lagwait);
if findtypeex($1F03,$08FD,backpack,false) = 0 then break;
end;
if findtypeex($1F03,$08FD,backpack,false) = 0 then break;
end;
end;
ignored_item[0] := $19B7; // руда
ignored_item[1] := $19BA; // руда
ignored_item[2] := $19B8; // руда
ignored_item[3] := $19B9; // руда
ignored_item[4] := $22C5; // рунабука
ignored_item[5] := $0F39; // лопата
ignored_item[6] := $3194; // perfect emerald
ignored_item[7] := $3198; // blue diamond
ignored_item[8] := $3195; // ecru citrine
ignored_item[9] := $3197; // fire ruby
ignored_item[10] := $3192; // dark sapphire
ignored_item[11] := $1F04; // роба
ignored_item[12] := $1F03; // роба
for a := 0 to 12 do
backpack_items_ignore(ignored_item[a]);
b := 0;
c := items_count(-1,backpack);
while (items_count(-1,backpack) > 0) and (b <= c) do
begin
equip(1,findtype(-1,backpack));
wait(500);
checklag(15000);
ignore(finditem);
b := b + 1;
end;
ignorereset;
end;
end;
procedure checkores;
var i : integer;
begin
for i := 0 to high(orecolor) do
begin
if findtypeex(ore,orecolor,backpack,false) = 0 then
begin
if check_item_count_in_box(orebox) <> items_count(-1,orebox) then
repeat
if dead then exit;
useobject(orebox);
wait(500);
until open = 'orebox';
if findtypeex(ore,orecolor,orebox,false) > 0 then
begin
stime:=now;
moveitem(finditem,1,backpack,0,0,0);
wait(500);
checklag(lagwait);
checksave(stime);
end;
end;
end;
end;
procedure unload;
var
ul,uc : integer;
begin
if not hidden then
useskill('hiding');
addtosystemjournal('разгрузка');
for ul := 0 to high(orecolor) do
if findtypeex(ore,orecolor[ul],backpack,false) > 0 then
if findquantity > 1 then
begin
if dead then exit;
stime := now;
uc := (findquantity - 1);
moveitem(finditem,uc,orebox,0,0,0);
wait(500);
checklag(lagwait);
checksave(stime);
end;
for ul := 0 to high(resourses) do
begin
while findtype(resourses[ul],backpack) > 0 do
begin
if dead then exit;
moveitem(finditem,-1,resoursesbox,0,0,0);
wait(500);
checklag(lagwait);
end;
end;
if items_count(tminertool,backpack) < 3 then
begin
repeat
if dead then exit;
if check_item_count_in_box(toolsbox) <> items_count(-1,toolsbox) then
begin
repeat
if dead then exit;
useobject(toolsbox);
wait(500);
until open = 'toolsbox';
open := 'close';
end;
stime:=now;
if check_item_count_in_box(toolsbox) > 0 then
begin
addtosystemjournal('берем лопату');
moveitem(findtype(tminertool,toolsbox),1,backpack,0,0,0);
wait(500);
checklag(lagwait);
checksave(stime);
end
else
begin
addtosystemjournal('Закончились лопаты');
wait(60000);
end;
until items_count(tminertool,backpack) >= 3;
end;
end;
procedure stackores;
var
so,sc : word;
begin
for so := 0 to length(oretype)-1 do
begin
while findtype(oretype[so],backpack) > 0 do
begin
if targetpresent then canceltarget else cancelwaittarget;
if dead then exit;
sc := getcolor(finditem);
waittargetobject(finditem);
if findtypeex(ore,sc,backpack,false) > 0 then
begin
useobject(finditem);
checklag(lagwait);
end;
waitfortarget(50);
end;
end;
end;
function wait_for_gump(gump_id,wait_time_ms : integer) : boolean;
var
circle : byte;
begin
if dead then exit;
circle := 0;
repeat
if getgumpid(getgumpscount-1) = gump_id then
begin
result := true;
exit;
end;
wait(50);
circle := (circle+1);
//addtosystemjournal('circle = ' + inttostr(circle));
until circle >= (wait_time_ms/50);
result := false;
end;
function recall(myx,myy,runebook,runenum:integer):boolean;
var
msg_cantm,msg_fizzle,msg_dist,msg_mana,msg_book,msg_recovery,msg_block,msg_end_wait,msg_home : string;
homerec,hb : integer;
wtime : tdatetime;
begin
msg_cantm := 'cannot move.'
msg_fizzle := 'spell fizzles.'
msg_dist := 'Your concentration is disturbed, thus ruining thy spell.'
msg_mana := 'mana for this spell.';
msg_book := 'book needs time to recharge.';
msg_recovery := 'You have not yet recovered from casting a spell.';
msg_block := 'location is blocked.';
msg_end_wait := msg_mana + '|' + msg_book + '|' + msg_recovery + '|' + msg_block + '|' + msg_dist + '|' + msg_fizzle + '|' + msg_cantm;
msg_home := msg_book + '|' + msg_block + '|' + msg_recovery + '|' + msg_dist + '|' + msg_fizzle + '|' + msg_cantm;
setglobal('char','enemy','true');
homerec := 0;
hb := runebook;
repeat
if dead then exit;
stime := now;
useobject(hb);
checklag(lagwait);
wtime := (stime + mstodatetime(3000));
if wait_for_gump($554B87F3,1000) or (injournalbetweentimes(msg_book,stime,now) <> -1) then
begin
if getgumpid(getgumpscount-1) = $554B87F3 then
numgumpbutton(getgumpscount-1,runebookshift + 6 * runenum);
repeat
if dead then exit;
wait(100);
until (injournalbetweentimes(msg_end_wait,stime,wtime) <> -1) or (getx(self) <> myx) or (gety(self) <> myy);
if injournalbetweentimes(msg_home,stime,wtime) <> -1 then
begin
if hb = homerb[homerec] then
if homerec < 2 then
begin
inc(homerec);
hb := homerb[homerec];
addtosystemjournal('$' + inttohex(hb,8));
continue;
end
else
begin
homerec := 0;
hb := homerb[homerec];
addtosystemjournal('$' + inttohex(hb,8));
continue;
end;
exit;
end;
checksave(stime);
checklag(lagwait);
end;
until (getx(self)<>myx) or (gety(self)<>myy);
////////////// проверка x y дома и шаг в сторону телепорта (getx(self),(minhy-1))
if (getx(self) >= minhx) and (getx(self) <= maxhx) and (gety(self) >= minhy) and (gety(self) <= maxhy) then
repeat
if dead then exit;
step(0,true);
wait(50);
until gety(self) <= hy;
result:=true;
end;
procedure check_pk;
var
i,q:integer;
begin
finddistance := 25;
for q := 0 to high(killers) do
begin
for i := 3 to 6 do
begin
if findnotoriety(killers[q],i)>0 then
begin
setglobal('char','enemy',inttostr(finditem));
finddistance := 2;
exit;
end;
end;
end;
finddistance := 2;
end;
procedure heal;
begin
while poisoned do
begin
if dead then exit;
if targetpresent then canceltarget;
addtosystemjournal('cure');
cast('cure');
waitfortarget(2000);
targettoobject(self);
end;
while hp < maxhp do
begin
if dead then exit;
if (hp < ((maxhp/4)*3)) and (hp > (maxhp/6)) then
begin
if targetpresent then canceltarget;
addtosystemjournal('greater heal');
cast('greater heal');
waitfortarget(2000);
targettoobject(self);
end
else
begin
if targetpresent then canceltarget;
addtosystemjournal('heal');
cast('heal');
waitfortarget(2000);
targettoobject(self);
end;
end;
while protect <> 'ptotected' do
begin
if dead then exit;
cast('protection');
wait(1000);
end;
end;
procedure mine_here();
var
msgmine_wheredig,msgmine_sucs,msgmine_fail,msgmine_nometal,
msgmine_faraway,msgmine_cantthere,msgmine_cantthat,msgmine_target,
msgmine_youmoved,msgmine_packfull,msgmine_wormtool,msgmine_riding,
msgmine_polymorphed,msgmine_extractstone,oreandstone_doubleharvest,
sand_noresources,sand_fail,sand_sucs,sand_packfull,
msgmine_end,msgmine_all,fname : string;
mountaintiles,sandtiles,cavetiles : array of word;
idminertool,enem : cardinal;
mapcell : tmapcell;
staticcell : tstaticcell;
mtime : tdatetime;
t,x,y,timecheck : word;
z : shortint;
i,j,ix,iy : integer;
ismountain : boolean;
begin
msgmine_wheredig := 'Where do you wish to dig?';
msgmine_sucs := 'You dig some'; //You dig some ... ore and put it in your backpack.
msgmine_fail := 'You loosen some rocks but fail to find any useable ore.';
msgmine_nometal := 'There is no metal here to mine.';
msgmine_faraway := 'That is too far away.';
msgmine_cantthere := 'You can''t mine there.';
msgmine_cantthat := 'You can''t mine that.';
msgmine_target := 'Target cannot be seen.';
msgmine_youmoved := 'You have moved too far away to continue mining.';
msgmine_packfull := 'Your backpack is full, so the ore you mined is lost.';
msgmine_wormtool := 'You have worn out your tool!';
msgmine_riding := 'You can''t mine while riding.';
msgmine_polymorphed := 'You can''t mine while polymorphed.';
msgmine_extractstone := 'You carefully extract some workable stone from the ore vein!';
oreandstone_doubleharvest := 'Someone has gotten to the metal before you.';
sand_fail := 'You dig for a while but fail to find any of sufficient quality for glassblowing.';
sand_sucs := 'You carefully dig up sand of sufficient quality for glassblowing.';
sand_noresources := 'There is no sand here to mine.';
sand_packfull := 'Your backpack can''t hold the sand, and it is lost!';
msgmine_end := msgmine_nometal + '|' + msgmine_faraway + '|' +
msgmine_cantthere + '|' + msgmine_cantthat + '|' +
msgmine_target + '|' + msgmine_youmoved + '|' +
sand_noresources + '|' + msgmine_packfull + '|' +
sand_packfull + '|' + msgmine_riding + '|' +
msgmine_polymorphed;
msgmine_all := msgmine_end + '|' + msgmine_sucs + '|' + msgmine_fail + '|' +
sand_fail + '|' + sand_sucs + '|' + msgMine_extractstone + '|' +
oreandstone_doubleharvest;
mountaintiles :=
[
220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 236, 237, 238,
239, 240, 241, 242, 243, 244, 245, 246, 247, 252, 253, 254, 255, 256, 257,
258, 259, 260, 261, 262, 263, 268, 269, 270, 271, 272, 273, 274, 275, 276,
277, 278, 279, 286, 287, 288, 289, 290, 291, 292, 293, 294, 296, 296, 297,
321, 322, 323, 324, 467, 468, 469, 470, 471, 472, 473, 474, 476, 477, 478,
479, 480, 481, 482, 483, 484, 485, 486, 487, 492, 493, 494, 495, 543, 544,
545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559,
560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574,
575, 576, 577, 578, 579, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590,
591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 610, 611, 612, 613,
1010, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751,
1752, 1753, 1754, 1755, 1756, 1757, 1771, 1772, 1773, 1774, 1775, 1776,
1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788,
1789, 1790, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1811,
1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823,
1824, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841,
1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853,
1854, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871,
1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883,
1884, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991,
1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2028, 2029, 2030, 2031, 2032, 2033, 2100, 2101, 2102, 2103, 2104,
2105, 17723, 17724, 17725, 17726, 17727, 17728, 17729, 17730, 17731, 17732,
17733, 17734, 17735, 17736, 17737, 17738, 17739, 17740, 17741, 17742, 17743
];
sandtiles :=
[
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 68, 69, 70, 71, 72, 73, 74, 75,
286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300,
301, 402, 424, 425, 426, 427, 441, 442, 443, 444, 445, 446, 447, 448, 449,
450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464,
465, 642, 643, 644, 645, 650, 651, 652, 653, 654, 655, 656, 657, 821, 822,
823, 824, 825, 826, 827, 828, 833, 834, 835, 836, 845, 846, 847, 848, 849,
850, 851, 852, 857, 858, 859, 860, 951, 952, 953, 954, 955, 956, 957, 958,
967, 968, 969, 970,
1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1611,
1612, 1613, 1614, 1615, 1616, 1617, 1618, 1623, 1624, 1625, 1626, 1635, 1636,
1637, 1638, 1639, 1640, 1641, 1642, 1647, 1648, 1649, 1650
];
cavetiles :=
[
1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349,
1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359
];
if targetpresent then canceltarget else cancelwaittarget;
t := 0;
x := getx(self);
y := gety(self);
z := getz(self);
ismountain := true;
for ix := (x - 1) to (x + 1) do
begin
for iy := (y - 1) to (y + 1) do
begin
mapcell := getmapcell(ix, iy, worldnum);
for i := 0 to (length(mountaintiles) - 1) do
if (mapcell.tile = mountaintiles) and (abs(z - mapcell.z) < 15) then
begin
addtosystemjournal('-- скала --');
t := mapcell.tile;
x := ix;
y := iy;
z := mapcell.z;
break;
end;
if t > 0 then break;
end;
if t > 0 then break;
end;
if t = 0 then
begin
mapcell := getmapcell(x, y, worldnum);
for i := 0 to (length(sandtiles) - 1) do
if (mapcell.tile = sandtiles) and (abs(z - mapcell.z) < 15) then
begin
addtosystemjournal('-- песок --');
ismountain := true;
t := mapcell.tile;
z := mapcell.z;
break;
end;
end;
if t = 0 then
begin
ismountain := false;
staticcell := readstaticsxy(x, y, worldnum);
if staticcell.staticcount > 0 then
begin
for i := 0 to (staticcell.staticcount - 1) do
begin
for j := 0 to (length(cavetiles) - 1) do
begin
if staticcell.statics.tile = cavetiles[j] then
begin
addtosystemjournal('---- шахта ----');
t := staticcell.statics.tile;
break;
end;
end;
if t > 0 then break;
end;
end;
end;
addtosystemjournal('-- Tile = ' + inttostr(t) + ' X = ' + inttostr(ix) + ' Y = ' + inttostr(iy) + ' Z = ' + inttostr(z));
if t = 0 then
begin
addtosystemjournal('-- здесь нельзя добывать.');
clientprint('ЗДЕСЬ НЕЛЬЗЯ ДОБЫВАТЬ.');
exit;
end;
repeat
idminertool := findtype(tminertool,backpack);
if idminertool = $0 then
begin
addtosystemjournal('-- нет инструментов для добычи!');
clientprint('НЕТ ИСТРУМЕНТА ДЛЯ ДОБЫЧИ.');
end;
if targetpresent then canceltarget else cancelwaittarget;
if ismountain = true then
waittargetxyz(x,y,z) //Горы, кочки и песок.
else
waittargettile(t,x,y,z); //Шахта.
check_pk;
stime := now;
mtime := (stime + mstodatetime(1500));
if (getglobal('char','enemy') = 'true') then
useobject(idminertool);
//waitjournalline(stime,msgmine_all,1000);
timecheck := 0;
repeat
timecheck := timecheck + 1;
wait(50);
until (injournalbetweentimes(msgmine_all,stime,mtime) <> -1) or (getglobal('char','enemy') <> 'true') or (timecheck > 40)
stackores;
if (weight > (maxweight-30)) or (getglobal('char','enemy') <> 'true') or (idminertool = $0) then
begin
if getglobal('char','enemy') <> 'true' then
begin
enem := strtoint(getglobal('char','enemy'));
addtosystemjournal('Пришел плохой дядя - ' + getname(enem));
addtosystemjournal('Дистанция обнаружения - ' + inttostr(getdistance(enem)));
fname := ('D:\UO\scripts\logs\' + getname(self) + '.txt');
writetofile(fname,datetimetostr(now) + #13#10);
writetofile(fname,'Пришел плохой дядя - ' + getname(enem) + #13#10);
writetofile(fname,'Дистанция обнаружения - ' + inttostr(getdistance(enem)) + #13#10);
writetofile(fname,'x ' + inttostr(getx(self)) + ' y ' + inttostr(gety(self)) + #13#10);
writetofile(fname,'' + #13#10);
addtosystemjournal('Валим на следующую точку');
exit;
end;
if weight > (maxweight - 25) then
addtosystemjournal('Набрали максимальный вес');
if (idminertool = $0) then
addtosystemjournal('Нет лапат');
addtosystemjournal('Рекол домой');
recall(getx(self),gety(self),homerb[0],0);
heal;
unload;
addtosystemjournal('Возвращаемся в последнюю точку');
recall(getx(self),gety(self),minerb[currentbook],currentrune);
end;
until dead or (injournalbetweentimes(msgmine_end,stime,now) <> -1);
end;
begin
setglobal('char','enemy','true');
setarstatus(true);
if not connected then begin
connect;
wait(10000);
end;
while dead do
begin
while warmode = false do
setwarmode(true);
if getgumpid(getgumpscount-1) = $B04C9A31 then
numgumpbutton(getgumpscount-1,1);
wait(1000);
useobject(backpack);
wait(1000);
useobject(backpack);
wait(1000);
useobject(backpack);
end;
seteventproc(evdrawobject,'drawobject');
seteventproc(evdrawcontainer,'drawcontainer');
seteventproc(evbuff_debuffsystem,'buff_debuffsystem');
init_all;
checkdress;
recall(getx(self),gety(self),homerb[0],0);
heal;
checkores;
unload;
while true do
begin
if not connected then
begin
connect;
wait(10000);
continue;
end;
addtosystemjournal('рекол по : рб ' + inttostr(currentbook + 1) + ' руна ' + inttostr(currentrune + 1));
rec := recall(getx(self),gety(self),minerb[currentbook],currentrune);
if rec then
mine_here;
if dead then
begin
AddToSystemJournal('You Dead.');
AddToSystemJournal('Runebook № '+IntToStr(CurrentBook+1));
AddToSystemJournal('Rune № '+IntToStr(CurrentRune+1));
if getgumpid(getgumpscount-1) = $1F3940C6 then // id гампа приписки убийства
numgumpbutton(getgumpscount-1,1);
repeat
setglobal('stealth','runebook',inttostr(minerb[currentbook]));
setglobal('stealth','rune',inttostr(currentrune));
wait(5000);
if findtype($0DDA,ground) <> 0 then
newmovexy(getx(finditem),gety(finditem),false,0,true);
wait(1000);
if getgumpid(getgumpscount-1) = $DD8B146A then // id гампа вхождения в портал
numgumpbutton(getgumpscount-1,1);
wait(1000);
while warmode = false do
setwarmode(true);
wait(1000);
if getgumpid(getgumpscount-1) = $B04C9A31 then // id гампа воскрешения
numgumpbutton(getgumpscount-1,1);
wait(1000);
setglobal('stealth','runebook','none');
until not dead;
checkdress;
recall(getx(self),gety(self),homerb[0],0);
heal;
checkores;
end;
if currentbook >= 2 then
begin
currentbook := 0;
if currentrune >= 15 then
currentrune := 0
else
inc(currentrune);
end
else
inc(currentbook);
end;
end.
const
tminertool = $0F39;
resoursesbox = $4026C3B9; // сундук для остального
orebox = $42C21DA4; // сундук для руды
toolsbox = $4098DB65; // сундук с лопатами
ore = $19B7;
runebookshift = 5; // 7 - чива, 5 магия.
lagwait = 15000;
hy = 3615; // координата y тайла на который телепортируемся
minhx = 515; // Квадрат по ширине ступенек перед домом.
maxhx = 528; // Если чар попадает в этот квадрат то бежит
minhy = 3619; // по оси (-Y) на N до тайла со ступеньками
maxhy = 3621; // на которых телепорты
var
stime : tdatetime;
currentrune,currentbook : integer;
resourses,killers,orecolor,oretype : array of word;
minerb,homerb : array of integer;
open,protect : string;
rec,cpk : boolean;
procedure writetofile(filepath : string ; data : string);
var mode : word;
begin
if fileexists(filepath) then mode := fmopenreadwrite
else mode := fmcreate;
with tfilestream.create(filepath,mode) do
try
seek(0,sofromend);
writebuffer(data,length(data)*2);
finally
free;
end;
end;
procedure check_notoriety(id : cardinal);
var ntrt : byte;
begin
ntrt := getnotoriety(id);
if (ntrt > 3) and (ntrt < 7) then
setglobal('char','enemy',inttostr(id));
end;
procedure drawobject(id : cardinal);
begin
check_notoriety(id);
end;
procedure drawcontainer(id,modelgump : integer);
begin
//addtosystemjournal('id = ' + inttostr(id) + ' modelgump = ' +inttostr(modelgump));
if id = resoursesbox then
open := 'resoursesbox';
if id = orebox then
open := 'orebox';
if id = toolsbox then
open := 'toolsbox';
end;
function BoolToStr(const value : boolean) : string;
begin
if value then Result := 'True' else Result := 'False';
end;
procedure buff_debuffsystem(id : integer ; attribute_id : word ; isenabled : boolean);
begin
//addtosystemjournal('id = ' + inttostr(id) + ' attribute_id = ' + inttostr(attribute_id) + ' isenabled = ' + booltostr(isenabled));
clientprint('buffchecker called');
if attribute_id = 1029 then
if isenabled then
begin
protect := 'ptotected'
addtosystemjournal('ptotected');
end
else
begin
protect := 'none';
addtosystemjournal('protect none');
end;
end;
procedure checksave(checktime:tdatetime);
begin
if injournalbetweentimes('The world is saving, please wait.',checktime,now)>=0 then
begin
addtosystemjournal('The world is saving, please wait.');
waitjournalline(checktime,'World save complete.',10000);
addtosystemjournal('World save complete.');
end;
end;
procedure backpack_items_ignore(item_type : word);
begin
repeat
findtype(item_type,backpack);
wait(50);
if findcount <> 0 then
ignore(finditem)
else
exit;
until false;
end;
procedure init_all;
var
hrb1,hrb2,hrb3,mrb1,mrb2,mrb3,ia : integer;
begin
if dead then exit;
orecolor := [$0000,$0973,$0966,$096D,$0972,$08A5,$0979,$089F,$08AB];
oretype := [$19BA,$19B8,$19B9];
resourses := [$3192,$3193,$3194,$3195,$3196,$3197,$3198,$3199]; // Сюда вписывать type того что складывать в сундук с ресурсами
killers := [$0190,$0191,$025E,$025D,$029A,$029B,$02ED,$02EA,$02EC]; // check pk
while findtype($22C5,backpack) > 0 do
begin
if bmsearch(1,gettooltip(finditem),'home') <> 0 then
hrb1 := finditem;
if bmsearch(1,gettooltip(finditem),'mining') <> 0 then
if mrb1 <> 0 then
if mrb2 <> 0 then
mrb3 := finditem
else
mrb2 := finditem
else
mrb1 := finditem;
if bmsearch(1,gettooltip(finditem),'pk') <> 0 then
if hrb2 <> 0 then
hrb3 := finditem
else
hrb2 := finditem;
ignore(finditem);
end;
ignorereset;
homerb :=[hrb1,hrb2,hrb3];
minerb :=[mrb1,mrb2,mrb3];
for ia := 0 to length(homerb)-1 do
if ia = 0 then
addtosystemjournal('home rb = $' + inttohex(homerb[ia],8))
else
if ia = 1 then
addtosystemjournal('pk rb = $' + inttohex(homerb[ia],8))
else
addtosystemjournal('pk rb 2 = $' + inttohex(homerb[ia],8));
for ia := 0 to length(minerb)-1 do
begin
if ia = 0 then
addtosystemjournal('mining rb = $' + inttohex(minerb[ia],8))
else
addtosystemjournal('mining rb ' + inttostr(ia + 1) + ' = $' + inttohex(minerb[ia],8));
end;
end;
function check_item_count_in_box(container : integer) : integer;
var i : integer;
fs,ss,ts : tstringlist;
Begin
fs := tstringlist.create; //лист первой сепарации
ss := tstringlist.create; //лист второй сепарации
ts := tstringlist.create; //лист третьей сепарации
strbreakapart(gettooltip(container),'|',fs);
if fs.count > 0 then
for i := 0 to fs.count - 1 do
if bmsearch(1,fs.strings,'Contents') <> 0 then
begin
strbreakapart(fs.strings,' ',ss);
if ss.count > 0 then
begin
strbreakapart(ss.strings[1],'/',ts);
result := (strtoint(ts.strings[0]));
end;
end;
fs.free;
ss.free;
ts.free;
end;
function items_count(item_type : word ; container : cardinal) : integer;
begin
findtype(item_type,container);
result := findcount;
end;
procedure checkdress;
var
ignored_item : array [0..12] of word;
a,b : word;
c,x,y : integer;
begin
if objatlayer(1) = 0 then
begin;
while objatlayer(22) <> 0 do
begin
unequip(22);
wait(500);
checklag(lagwait);
end;
while findtypeex($1F03,$08FD,backpack,false) <> 0 do
begin
for x := -1 to 1 do
begin
for y := -1 to 1 do
begin
moveitem(finditem,1,ground,getx(self) + x,gety(self) + y,getz(self));
waitfortarget(500);
checklag(lagwait);
if findtypeex($1F03,$08FD,backpack,false) = 0 then break;
end;
if findtypeex($1F03,$08FD,backpack,false) = 0 then break;
end;
end;
ignored_item[0] := $19B7; // руда
ignored_item[1] := $19BA; // руда
ignored_item[2] := $19B8; // руда
ignored_item[3] := $19B9; // руда
ignored_item[4] := $22C5; // рунабука
ignored_item[5] := $0F39; // лопата
ignored_item[6] := $3194; // perfect emerald
ignored_item[7] := $3198; // blue diamond
ignored_item[8] := $3195; // ecru citrine
ignored_item[9] := $3197; // fire ruby
ignored_item[10] := $3192; // dark sapphire
ignored_item[11] := $1F04; // роба
ignored_item[12] := $1F03; // роба
for a := 0 to 12 do
backpack_items_ignore(ignored_item[a]);
b := 0;
c := items_count(-1,backpack);
while (items_count(-1,backpack) > 0) and (b <= c) do
begin
equip(1,findtype(-1,backpack));
wait(500);
checklag(15000);
ignore(finditem);
b := b + 1;
end;
ignorereset;
end;
end;
procedure checkores;
var i : integer;
begin
for i := 0 to high(orecolor) do
begin
if findtypeex(ore,orecolor,backpack,false) = 0 then
begin
if check_item_count_in_box(orebox) <> items_count(-1,orebox) then
repeat
if dead then exit;
useobject(orebox);
wait(500);
until open = 'orebox';
if findtypeex(ore,orecolor,orebox,false) > 0 then
begin
stime:=now;
moveitem(finditem,1,backpack,0,0,0);
wait(500);
checklag(lagwait);
checksave(stime);
end;
end;
end;
end;
procedure unload;
var
ul,uc : integer;
begin
if not hidden then
useskill('hiding');
addtosystemjournal('разгрузка');
for ul := 0 to high(orecolor) do
if findtypeex(ore,orecolor[ul],backpack,false) > 0 then
if findquantity > 1 then
begin
if dead then exit;
stime := now;
uc := (findquantity - 1);
moveitem(finditem,uc,orebox,0,0,0);
wait(500);
checklag(lagwait);
checksave(stime);
end;
for ul := 0 to high(resourses) do
begin
while findtype(resourses[ul],backpack) > 0 do
begin
if dead then exit;
moveitem(finditem,-1,resoursesbox,0,0,0);
wait(500);
checklag(lagwait);
end;
end;
if items_count(tminertool,backpack) < 3 then
begin
repeat
if dead then exit;
if check_item_count_in_box(toolsbox) <> items_count(-1,toolsbox) then
begin
repeat
if dead then exit;
useobject(toolsbox);
wait(500);
until open = 'toolsbox';
open := 'close';
end;
stime:=now;
if check_item_count_in_box(toolsbox) > 0 then
begin
addtosystemjournal('берем лопату');
moveitem(findtype(tminertool,toolsbox),1,backpack,0,0,0);
wait(500);
checklag(lagwait);
checksave(stime);
end
else
begin
addtosystemjournal('Закончились лопаты');
wait(60000);
end;
until items_count(tminertool,backpack) >= 3;
end;
end;
procedure stackores;
var
so,sc : word;
begin
for so := 0 to length(oretype)-1 do
begin
while findtype(oretype[so],backpack) > 0 do
begin
if targetpresent then canceltarget else cancelwaittarget;
if dead then exit;
sc := getcolor(finditem);
waittargetobject(finditem);
if findtypeex(ore,sc,backpack,false) > 0 then
begin
useobject(finditem);
checklag(lagwait);
end;
waitfortarget(50);
end;
end;
end;
function wait_for_gump(gump_id,wait_time_ms : integer) : boolean;
var
circle : byte;
begin
if dead then exit;
circle := 0;
repeat
if getgumpid(getgumpscount-1) = gump_id then
begin
result := true;
exit;
end;
wait(50);
circle := (circle+1);
//addtosystemjournal('circle = ' + inttostr(circle));
until circle >= (wait_time_ms/50);
result := false;
end;
function recall(myx,myy,runebook,runenum:integer):boolean;
var
msg_cantm,msg_fizzle,msg_dist,msg_mana,msg_book,msg_recovery,msg_block,msg_end_wait,msg_home : string;
homerec,hb : integer;
wtime : tdatetime;
begin
msg_cantm := 'cannot move.'
msg_fizzle := 'spell fizzles.'
msg_dist := 'Your concentration is disturbed, thus ruining thy spell.'
msg_mana := 'mana for this spell.';
msg_book := 'book needs time to recharge.';
msg_recovery := 'You have not yet recovered from casting a spell.';
msg_block := 'location is blocked.';
msg_end_wait := msg_mana + '|' + msg_book + '|' + msg_recovery + '|' + msg_block + '|' + msg_dist + '|' + msg_fizzle + '|' + msg_cantm;
msg_home := msg_book + '|' + msg_block + '|' + msg_recovery + '|' + msg_dist + '|' + msg_fizzle + '|' + msg_cantm;
setglobal('char','enemy','true');
homerec := 0;
hb := runebook;
repeat
if dead then exit;
stime := now;
useobject(hb);
checklag(lagwait);
wtime := (stime + mstodatetime(3000));
if wait_for_gump($554B87F3,1000) or (injournalbetweentimes(msg_book,stime,now) <> -1) then
begin
if getgumpid(getgumpscount-1) = $554B87F3 then
numgumpbutton(getgumpscount-1,runebookshift + 6 * runenum);
repeat
if dead then exit;
wait(100);
until (injournalbetweentimes(msg_end_wait,stime,wtime) <> -1) or (getx(self) <> myx) or (gety(self) <> myy);
if injournalbetweentimes(msg_home,stime,wtime) <> -1 then
begin
if hb = homerb[homerec] then
if homerec < 2 then
begin
inc(homerec);
hb := homerb[homerec];
addtosystemjournal('$' + inttohex(hb,8));
continue;
end
else
begin
homerec := 0;
hb := homerb[homerec];
addtosystemjournal('$' + inttohex(hb,8));
continue;
end;
exit;
end;
checksave(stime);
checklag(lagwait);
end;
until (getx(self)<>myx) or (gety(self)<>myy);
////////////// проверка x y дома и шаг в сторону телепорта (getx(self),(minhy-1))
if (getx(self) >= minhx) and (getx(self) <= maxhx) and (gety(self) >= minhy) and (gety(self) <= maxhy) then
repeat
if dead then exit;
step(0,true);
wait(50);
until gety(self) <= hy;
result:=true;
end;
procedure check_pk;
var
i,q:integer;
begin
finddistance := 25;
for q := 0 to high(killers) do
begin
for i := 3 to 6 do
begin
if findnotoriety(killers[q],i)>0 then
begin
setglobal('char','enemy',inttostr(finditem));
finddistance := 2;
exit;
end;
end;
end;
finddistance := 2;
end;
procedure heal;
begin
while poisoned do
begin
if dead then exit;
if targetpresent then canceltarget;
addtosystemjournal('cure');
cast('cure');
waitfortarget(2000);
targettoobject(self);
end;
while hp < maxhp do
begin
if dead then exit;
if (hp < ((maxhp/4)*3)) and (hp > (maxhp/6)) then
begin
if targetpresent then canceltarget;
addtosystemjournal('greater heal');
cast('greater heal');
waitfortarget(2000);
targettoobject(self);
end
else
begin
if targetpresent then canceltarget;
addtosystemjournal('heal');
cast('heal');
waitfortarget(2000);
targettoobject(self);
end;
end;
while protect <> 'ptotected' do
begin
if dead then exit;
cast('protection');
wait(1000);
end;
end;
procedure mine_here();
var
msgmine_wheredig,msgmine_sucs,msgmine_fail,msgmine_nometal,
msgmine_faraway,msgmine_cantthere,msgmine_cantthat,msgmine_target,
msgmine_youmoved,msgmine_packfull,msgmine_wormtool,msgmine_riding,
msgmine_polymorphed,msgmine_extractstone,oreandstone_doubleharvest,
sand_noresources,sand_fail,sand_sucs,sand_packfull,
msgmine_end,msgmine_all,fname : string;
mountaintiles,sandtiles,cavetiles : array of word;
idminertool,enem : cardinal;
mapcell : tmapcell;
staticcell : tstaticcell;
mtime : tdatetime;
t,x,y,timecheck : word;
z : shortint;
i,j,ix,iy : integer;
ismountain : boolean;
begin
msgmine_wheredig := 'Where do you wish to dig?';
msgmine_sucs := 'You dig some'; //You dig some ... ore and put it in your backpack.
msgmine_fail := 'You loosen some rocks but fail to find any useable ore.';
msgmine_nometal := 'There is no metal here to mine.';
msgmine_faraway := 'That is too far away.';
msgmine_cantthere := 'You can''t mine there.';
msgmine_cantthat := 'You can''t mine that.';
msgmine_target := 'Target cannot be seen.';
msgmine_youmoved := 'You have moved too far away to continue mining.';
msgmine_packfull := 'Your backpack is full, so the ore you mined is lost.';
msgmine_wormtool := 'You have worn out your tool!';
msgmine_riding := 'You can''t mine while riding.';
msgmine_polymorphed := 'You can''t mine while polymorphed.';
msgmine_extractstone := 'You carefully extract some workable stone from the ore vein!';
oreandstone_doubleharvest := 'Someone has gotten to the metal before you.';
sand_fail := 'You dig for a while but fail to find any of sufficient quality for glassblowing.';
sand_sucs := 'You carefully dig up sand of sufficient quality for glassblowing.';
sand_noresources := 'There is no sand here to mine.';
sand_packfull := 'Your backpack can''t hold the sand, and it is lost!';
msgmine_end := msgmine_nometal + '|' + msgmine_faraway + '|' +
msgmine_cantthere + '|' + msgmine_cantthat + '|' +
msgmine_target + '|' + msgmine_youmoved + '|' +
sand_noresources + '|' + msgmine_packfull + '|' +
sand_packfull + '|' + msgmine_riding + '|' +
msgmine_polymorphed;
msgmine_all := msgmine_end + '|' + msgmine_sucs + '|' + msgmine_fail + '|' +
sand_fail + '|' + sand_sucs + '|' + msgMine_extractstone + '|' +
oreandstone_doubleharvest;
mountaintiles :=
[
220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 236, 237, 238,
239, 240, 241, 242, 243, 244, 245, 246, 247, 252, 253, 254, 255, 256, 257,
258, 259, 260, 261, 262, 263, 268, 269, 270, 271, 272, 273, 274, 275, 276,
277, 278, 279, 286, 287, 288, 289, 290, 291, 292, 293, 294, 296, 296, 297,
321, 322, 323, 324, 467, 468, 469, 470, 471, 472, 473, 474, 476, 477, 478,
479, 480, 481, 482, 483, 484, 485, 486, 487, 492, 493, 494, 495, 543, 544,
545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559,
560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574,
575, 576, 577, 578, 579, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590,
591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 610, 611, 612, 613,
1010, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751,
1752, 1753, 1754, 1755, 1756, 1757, 1771, 1772, 1773, 1774, 1775, 1776,
1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788,
1789, 1790, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1811,
1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823,
1824, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841,
1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853,
1854, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871,
1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883,
1884, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991,
1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2028, 2029, 2030, 2031, 2032, 2033, 2100, 2101, 2102, 2103, 2104,
2105, 17723, 17724, 17725, 17726, 17727, 17728, 17729, 17730, 17731, 17732,
17733, 17734, 17735, 17736, 17737, 17738, 17739, 17740, 17741, 17742, 17743
];
sandtiles :=
[
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 68, 69, 70, 71, 72, 73, 74, 75,
286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300,
301, 402, 424, 425, 426, 427, 441, 442, 443, 444, 445, 446, 447, 448, 449,
450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464,
465, 642, 643, 644, 645, 650, 651, 652, 653, 654, 655, 656, 657, 821, 822,
823, 824, 825, 826, 827, 828, 833, 834, 835, 836, 845, 846, 847, 848, 849,
850, 851, 852, 857, 858, 859, 860, 951, 952, 953, 954, 955, 956, 957, 958,
967, 968, 969, 970,
1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1611,
1612, 1613, 1614, 1615, 1616, 1617, 1618, 1623, 1624, 1625, 1626, 1635, 1636,
1637, 1638, 1639, 1640, 1641, 1642, 1647, 1648, 1649, 1650
];
cavetiles :=
[
1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349,
1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359
];
if targetpresent then canceltarget else cancelwaittarget;
t := 0;
x := getx(self);
y := gety(self);
z := getz(self);
ismountain := true;
for ix := (x - 1) to (x + 1) do
begin
for iy := (y - 1) to (y + 1) do
begin
mapcell := getmapcell(ix, iy, worldnum);
for i := 0 to (length(mountaintiles) - 1) do
if (mapcell.tile = mountaintiles) and (abs(z - mapcell.z) < 15) then
begin
addtosystemjournal('-- скала --');
t := mapcell.tile;
x := ix;
y := iy;
z := mapcell.z;
break;
end;
if t > 0 then break;
end;
if t > 0 then break;
end;
if t = 0 then
begin
mapcell := getmapcell(x, y, worldnum);
for i := 0 to (length(sandtiles) - 1) do
if (mapcell.tile = sandtiles) and (abs(z - mapcell.z) < 15) then
begin
addtosystemjournal('-- песок --');
ismountain := true;
t := mapcell.tile;
z := mapcell.z;
break;
end;
end;
if t = 0 then
begin
ismountain := false;
staticcell := readstaticsxy(x, y, worldnum);
if staticcell.staticcount > 0 then
begin
for i := 0 to (staticcell.staticcount - 1) do
begin
for j := 0 to (length(cavetiles) - 1) do
begin
if staticcell.statics.tile = cavetiles[j] then
begin
addtosystemjournal('---- шахта ----');
t := staticcell.statics.tile;
break;
end;
end;
if t > 0 then break;
end;
end;
end;
addtosystemjournal('-- Tile = ' + inttostr(t) + ' X = ' + inttostr(ix) + ' Y = ' + inttostr(iy) + ' Z = ' + inttostr(z));
if t = 0 then
begin
addtosystemjournal('-- здесь нельзя добывать.');
clientprint('ЗДЕСЬ НЕЛЬЗЯ ДОБЫВАТЬ.');
exit;
end;
repeat
idminertool := findtype(tminertool,backpack);
if idminertool = $0 then
begin
addtosystemjournal('-- нет инструментов для добычи!');
clientprint('НЕТ ИСТРУМЕНТА ДЛЯ ДОБЫЧИ.');
end;
if targetpresent then canceltarget else cancelwaittarget;
if ismountain = true then
waittargetxyz(x,y,z) //Горы, кочки и песок.
else
waittargettile(t,x,y,z); //Шахта.
check_pk;
stime := now;
mtime := (stime + mstodatetime(1500));
if (getglobal('char','enemy') = 'true') then
useobject(idminertool);
//waitjournalline(stime,msgmine_all,1000);
timecheck := 0;
repeat
timecheck := timecheck + 1;
wait(50);
until (injournalbetweentimes(msgmine_all,stime,mtime) <> -1) or (getglobal('char','enemy') <> 'true') or (timecheck > 40)
stackores;
if (weight > (maxweight-30)) or (getglobal('char','enemy') <> 'true') or (idminertool = $0) then
begin
if getglobal('char','enemy') <> 'true' then
begin
enem := strtoint(getglobal('char','enemy'));
addtosystemjournal('Пришел плохой дядя - ' + getname(enem));
addtosystemjournal('Дистанция обнаружения - ' + inttostr(getdistance(enem)));
fname := ('D:\UO\scripts\logs\' + getname(self) + '.txt');
writetofile(fname,datetimetostr(now) + #13#10);
writetofile(fname,'Пришел плохой дядя - ' + getname(enem) + #13#10);
writetofile(fname,'Дистанция обнаружения - ' + inttostr(getdistance(enem)) + #13#10);
writetofile(fname,'x ' + inttostr(getx(self)) + ' y ' + inttostr(gety(self)) + #13#10);
writetofile(fname,'' + #13#10);
addtosystemjournal('Валим на следующую точку');
exit;
end;
if weight > (maxweight - 25) then
addtosystemjournal('Набрали максимальный вес');
if (idminertool = $0) then
addtosystemjournal('Нет лапат');
addtosystemjournal('Рекол домой');
recall(getx(self),gety(self),homerb[0],0);
heal;
unload;
addtosystemjournal('Возвращаемся в последнюю точку');
recall(getx(self),gety(self),minerb[currentbook],currentrune);
end;
until dead or (injournalbetweentimes(msgmine_end,stime,now) <> -1);
end;
begin
setglobal('char','enemy','true');
setarstatus(true);
if not connected then begin
connect;
wait(10000);
end;
while dead do
begin
while warmode = false do
setwarmode(true);
if getgumpid(getgumpscount-1) = $B04C9A31 then
numgumpbutton(getgumpscount-1,1);
wait(1000);
useobject(backpack);
wait(1000);
useobject(backpack);
wait(1000);
useobject(backpack);
end;
seteventproc(evdrawobject,'drawobject');
seteventproc(evdrawcontainer,'drawcontainer');
seteventproc(evbuff_debuffsystem,'buff_debuffsystem');
init_all;
checkdress;
recall(getx(self),gety(self),homerb[0],0);
heal;
checkores;
unload;
while true do
begin
if not connected then
begin
connect;
wait(10000);
continue;
end;
addtosystemjournal('рекол по : рб ' + inttostr(currentbook + 1) + ' руна ' + inttostr(currentrune + 1));
rec := recall(getx(self),gety(self),minerb[currentbook],currentrune);
if rec then
mine_here;
if dead then
begin
AddToSystemJournal('You Dead.');
AddToSystemJournal('Runebook № '+IntToStr(CurrentBook+1));
AddToSystemJournal('Rune № '+IntToStr(CurrentRune+1));
if getgumpid(getgumpscount-1) = $1F3940C6 then // id гампа приписки убийства
numgumpbutton(getgumpscount-1,1);
repeat
setglobal('stealth','runebook',inttostr(minerb[currentbook]));
setglobal('stealth','rune',inttostr(currentrune));
wait(5000);
if findtype($0DDA,ground) <> 0 then
newmovexy(getx(finditem),gety(finditem),false,0,true);
wait(1000);
if getgumpid(getgumpscount-1) = $DD8B146A then // id гампа вхождения в портал
numgumpbutton(getgumpscount-1,1);
wait(1000);
while warmode = false do
setwarmode(true);
wait(1000);
if getgumpid(getgumpscount-1) = $B04C9A31 then // id гампа воскрешения
numgumpbutton(getgumpscount-1,1);
wait(1000);
setglobal('stealth','runebook','none');
until not dead;
checkdress;
recall(getx(self),gety(self),homerb[0],0);
heal;
checkores;
end;
if currentbook >= 2 then
begin
currentbook := 0;
if currentrune >= 15 then
currentrune := 0
else
inc(currentrune);
end
else
inc(currentbook);
end;
end.