Code: Select all
Program mining;
type
TypeArray = array [1..9] of array [1..2] of integer;
DirArray = array [1..9] of array [1..3] of integer;
const
bankId = $40004F34;
Pickaxe = $0E85;
Steps = 4;
CrossSteps = 6;
MaxWeight = 400;
WaitTime = 1000;
MaxStepDistance = 4;
MaxRangeDigger = 2;
var
MiningTool: Cardinal;
lastdir : integer;
lastsay : integer;
function DeliveryBank(x,y : Word):integer;
var
bankposx, bankposy : integer;
bankIdTemp, Bank, CurIngot : Cardinal;
i, CurIndex : shortInt;
oreType : array of Word;
var ore: TStringList;
begin
oreType := [$19B7,$19BA,$19B9,$19B8];
bankIdTemp := bankId;
NewMoveXY(GetX(bankIdTemp),GetY(bankIdTemp),false,1,true);
UseObject(bankIdTemp);
Bank:=ObjAtLayer(BankLayer);
if Bank <> 0 then begin
for i:=0 to getArrayLength(oreType) - 1 do
if (FindType(oreType[i], Backpack) > 0) then begin
try
ore := TStringList.Create;
if GetFindedList(ore) = False then begin
Result := 0;
end else begin
CurIndex := 0;
while CurIndex < ore.Count do begin
if Dead or not Connected then Exit;
uosay(inttostr(FindCount));
CurIngot := StrToInt('$' + ore.Strings[CurIndex]);
if MoveItem(CurIngot, GetQuantity(CurIngot), Bank, $FFFF, $FFFF, 0) then inc(curIndex);
wait(2000);
end;
end;
finally
ore.free;
end;
end;
end;
NewMoveXY(x,y,false,1,true);
wait(1000);
result := 0;
end;
function Safety():boolean;
var tmplast : integer;
begin
inc(lastsay);
tmplast := lastsay mod 5;
if tmplast = 0 then begin
uosay('Guards');
result := false;
end;
tmplast := lastsay mod 6000;
if tmplast = 0 then begin
lastsay := 0;
DeliveryBank(GetX(Self),GetY(Self));
result := false;
end;
end;
function GetTools():boolean;
begin
if not GetType(ObjAtLayer(RhandLayer)) <> Pickaxe then begin
MiningTool := ObjAtLayer(RhandLayer);
Result := true;
Exit;
end;
FindType(Pickaxe, Backpack);
if GetType(MiningTool) <> Pickaxe then MiningTool := FindItem;
Result := FindCount > 0;
end;
function Mine(X, Y: Integer):boolean;
var
StaticData: TStaticCell;
Tile: Word;
Finished: Boolean;
Counter: Byte;
StartTime: TDateTime;
LastTimer : integer;
MaxRange : integer;
tmp_MaxWeight : integer;
i, z : integer;
TileType : TypeArray;
begin
Finished := False;
StaticData := ReadStaticsXY(X, Y, WorldNum);
for i := 0 to StaticData.StaticCount - 1 do
begin
if i >= StaticData.StaticCount then Break;
if (GetTileFlags(2, StaticData.Statics[i].Tile) and $200) = $200 then
begin
Tile := StaticData.Statics[i].Tile;
Z := StaticData.Statics[i].Z;
Finished := True;
Break;
end;
end;
//ClearJournal();
while Finished do
begin
if Dead or not Connected then Exit;
if TargetPresent then CancelTarget;
if not GetTools then Exit;
UseObject(MiningTool);
WaitForTarget(WaitTime);
if TargetPresent then
begin
StartTime := Now;
TargetToTile(Tile, X, Y, Z);
Finished := false;
Counter := 7;
while not Finished do
begin
if InJournalBetweenTimes('нечего|line|away|Поробуйте', StartTime, Now) > 0 then Exit;
if InJournalBetweenTimes('помещенно|fail', StartTime, Now) > 0 then Finished := True;
Wait(200);
Safety;
Dec(Counter);
end;
end;
end;
result := true;
end;
function GetCircle():boolean;
var
MaxRange, X, Y : ShortInt;
mX, mY, mZ : Word;
begin
// TileType := [[616,618],[1339,1363],[2272,2282],[4963,4973],[6001, 6012],[13121, 13369],[13446,13455],[13484,13492],[13625,13628]];
MaxRange := MaxRangeDigger;
mX := GetX(Self);
mY := GetY(Self);
mZ := GetZ(Self);
for X := MaxRange - ( MaxRange * 2) to MaxRange do
begin
for Y := MaxRange - ( MaxRange * 2) to MaxRange do
begin
Mine(mX+X, mY+Y);
end;
end;
end;
function TestTile():boolean;
begin
result := true;
end;
function Move():boolean;
var
tmpdir : integer;
dirs : array of array of integer;
x,y : integer;
begin
SetLength(dirs, 8);
dirs[0] := [0,1,4]; //1
dirs[1] := [1,1,2]; //2
dirs[2] := [1,0,4]; //3
dirs[3] := [1,-1,2]; //6
dirs[4] := [1,-1,4]; //9
dirs[5] := [-1,-1,2]; //8
dirs[6] := [-1,0,4]; //7
dirs[7] := [-1,1,2]; //4
// dirs[8] := [0,0,2]; //5
x := GetX(Self) + dirs[lastdir][0]*(Random(MaxStepDistance)+1);
y := GetY(Self) + dirs[lastdir][1]*(Random(MaxStepDistance)+1);
NewMoveXY(x,y,false,1,true);
if lastdir < getArrayLength(dirs) - 1 then
begin
lastdir := lastdir + 1;
end
else
begin
lastdir := 0;
end;
result := true;
end;
{ BODY }
begin
repeat
//DeliveryBank;
//wait(5000);
move();
GetCircle();
until Dead;
end.