quinta-feira, 31 de julho de 2008

Pot Destroyer by LordOfWar

//Your weapon must be in your left hand
const
ITEM_ID = 3465;

var
Checked: array of integer;
ScanX: integer;
ScanY: integer;
ScanItem: TItem;

function GetTileFromXYZ(X, Y, Z: integer): TTile;
begin
Result := nil;
if abs((Self.X - 7) - X) > 14 then Exit;
if abs((Self.Y - 5) - Y) > 11 then Exit;
if Self.Z <> Z then Exit;
Result := Screen.Tile[abs((Self.X - 7) - X), abs((Self.Y - 5) - Y)];
end;

function IsTileWalkable(Tile: TTile): boolean;
begin
Result := True;
for Z := 0 to Tile.Count - 1 do
begin
if Tile.Item[Z].Properties.Hole then
begin
Result := False;
end
else if Tile.Item[Z].Properties.Stairs then
begin
Result := False;
end
else if not Tile.Item[Z].Properties.Walkable then
begin
Result := False;
end;
end;
end;

function FindPath(FromX, FromY, FromZ, ToX, ToY, ToZ: integer; CheckLastTile: boolean): boolean;
var
Xloop, Yloop: integer;
begin
Result := False;
if FromZ <> ToZ then Exit;
Checked[abs(FromX - (Self.X - 7)), abs(FromY - (Self.Y - 5))] := True;
for Xloop := 0 to 2 do
begin
for Yloop := 0 to 2 do
begin
if (((FromX - 1) + Xloop) <> Self.X + 7) then Continue;
if (((FromY - 1) + Yloop) <> Self.Y + 5) then Continue;
if (((FromX - 1) + Xloop) = ToX) and (((FromY - 1) + Yloop) = ToY) then
begin
if IsTileWalkable(GetTileFromXYZ((FromX - 1) + Xloop, (FromY - 1) + Yloop, FromZ)) or (not CheckLastTile) then
begin
Result := True;
Exit;
end;
end;
if ((Xloop = 1) and (Yloop = 1)) then Continue;
if Checked[abs(((FromX - 1) + Xloop) - (Self.X - 7)), abs(((FromY - 1) + Yloop) - (Self.Y - 5))] then Continue;
if IsTileWalkable(GetTileFromXYZ((FromX - 1) + Xloop, (FromY - 1) + Yloop, FromZ)) then
begin
if FindPath((FromX - 1) + Xloop, (FromY - 1) + Yloop, FromZ, ToX, ToY, ToZ, CheckLastTile) then
begin
Result := True;
Exit;
end;
end;
end;
end;
end;

function IsReachable(X, Y, Z: integer);
begin
Checked := VarArrayCreate([0, 14, 0, 10], 11);
for InitX := 0 to 14 do
begin
for InitY := 0 to 1 do
begin
Checked[InitX, InitY] := False;
end;
end;
Result := FindPath(Self.X, Self.Y, Self.Z, X, Y, Z, False);
end;

function IsItemOnTile(ID: integer; Tile: TTile): boolean;
var
Z: integer;
begin
Result := False;
for Z := 0 to Tile.Count - 1 do
begin
if Z >= Tile.Count then Break;
if Tile.Item[Z].ID = ID then
begin
Result := True;
Break;
end;
end;
end;

while not Terminated do
begin
UpdateWorld;
for ScanX := 0 to 14 do
begin
for ScanY := 0 to 10 do
begin
if IsItemOnTile(ITEM_ID, Screen.Tile[ScanX, ScanY]) then
begin
if IsReachable(Self.X + (ScanX - 7), Self.Y + (ScanY - 5), Self.Z) then Self.LeftHand.UseWithGround(Self.X + (ScanX - 7), Self.Y + (ScanY - 5), Self.Z);
end;
Sleep(1);
end;
Sleep(1);
end;
Sleep(250);
end;

0 Comments: