Code: Select all
PROGRAM TestMining;
CONST
tMinerTool = $0F39; //Чем копать (тип инструмента): $0F39 - Shovel. $0E86 - Pickaxe.
VAR
x, y: Integer;
Procedure MiningHere(ix, iy: Integer);
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, msgMine_DoubleHarvest,
sand_NoResources, sand_Fail, sand_Sucs, sand_PackFull,
msgMine_END, msgMine_ALL : String;
MountainTiles, SandTiles, CaveTiles: array of Word;
idMinerTool: Cardinal;
startTime: TDateTime;
MapCell: TMapCell;
StaticCell: TStaticCell;
T, X, Y: Word;
Z: ShortInt;
i, j: 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!';
msgMine_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_ALL := msgMine_END + '|' + msgMine_Sucs + '|' + msgMine_Fail + '|' +
sand_Fail + '|' + sand_Sucs + '|' + msgMine_ExtractStone + '|' +
msgMine_DoubleHarvest;
// ТАЙЛЫ В КОТОРЫХ МОЖНО ВЕСТИ ДОБЫЧУ (из исходников RunUO):
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 := ix;
Y := iy;
Z := GetZ(self);
isMountain := TRUE;
// Ищим горы и кочки:
MapCell := GetMapCell(ix, iy, WorldNum);
for i := 0 to (Length(MountainTiles) - 1) do
begin
if (MapCell.Tile = MountainTiles[i]) and (abs(Z - MapCell.Z) < 15) then
begin
AddToSystemJournal('-- MOUNTAIN --');
T := MapCell.Tile;
Z := MapCell.Z;
BREAK;
end;
end;
// Ищим песок:
if T = 0 then
begin
MapCell := GetMapCell(ix, iy, WorldNum);
for i := 0 to (Length(SandTiles) - 1) do
begin
if (MapCell.Tile = SandTiles[i]) and (abs(Z - MapCell.Z) < 15) then
begin
AddToSystemJournal('-- SAND --');
T := MapCell.Tile;
Z := MapCell.Z;
BREAK;
end;
end;
end;
// Ищим пол шахты:
if T = 0 then
begin
isMountain := FALSE;
StaticCell := ReadStaticsXY(ix, iy, 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[i].Tile = CaveTiles[j] then
begin
AddToSystemJournal('-- CAVE --');
T := StaticCell.Statics[i].Tile;
Z := StaticCell.Statics[i].Z;
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('ЗДЕСЬ НЕЛЬЗЯ ДОБЫВАТЬ.');
CONTINUE;
end;
repeat
idMinerTool := FindType(tMinerTool, Backpack);
if idMinerTool = $0 then
begin
AddToSystemJournal('-- Нет инструментов для добычи!');
ClientPrint('НЕТ ИСТРУМЕНТА ДЛЯ ДОБЫЧИ.');
EXIT;
end;
//if TargetPresent then CancelTarget else CancelWaitTarget;
Wait(100);
startTime := Now;
if isMountain = TRUE then
WaitTargetXYZ(X, Y, Z) //Горы, кочки и песок.
else
WaitTargetTile(T, X, Y, Z); //Шахта.
UseObject(idMinerTool);
repeat
wait(100);
until Dead or not Connected or (InJournalBetweenTimes(msgMine_ALL,startTime,Now) <> -1);
until Dead or not Connected or (InJournalBetweenTimes(msgMine_END,startTime,Now) <> -1);
End;
BEGIN
for x := (GetX(self) - 2) to (GetX(self) + 2) do
for y := (GetY(self) - 2) to (GetY(self) + 2) do
MiningHere(x, y);
END.