ElGenio
2021-03-22 09:13:46
The problem I have is that it is very difficult for him to target the enemies and attack them, every time my character locks himself up and does not find a way to move, I made him use his special ability (requires use of mana) and he even does little to get it to work that when he has little mana or less than he touches he will use a potion, now he has suddenly decided not to work this option. Could someone help me a little please?
Do you see strange things?
For the issue of enemies I am thinking of a set of DTMs and with a list of enemies to be able to configure it to be able to choose which monsters you want me to kill.
[YOUTUBE]JVkLQqE8o1Y[/YOUTUBE]
Video Problem
I will appreciate any help. Thanks.
Do you see strange things?
For the issue of enemies I am thinking of a set of DTMs and with a list of enemies to be able to configure it to be able to choose which monsters you want me to kill.
program Rucoy;
{$loadlib tap}
{$loadlib LibMufasaLayer} {$DEFINE LAYER}
var
_w, _h, _hh, _d: Int32;
//noxplayer custom size: 798x482
const
MELEE = False; //SETUP
MAGIC = False; //SETUP
RANGE = False; //SETUP
//add new Tiles if you want
TILE_BROWN = 2504765; //mummies?
TILE_GRASS = 4757576; //crows
TILE_DIRT_PATH = 4749448; //
TILE_SKELETONS_75 = 1065293; //esqueletos
TILE_SAND = 10076395; //scorpions, snakes
TILE_MUD = 2376788; //
TILE_GRAVE_MUD = 1065293; //
TILE_GRAVE = 2843236; //
TILE_STONE = 5197647; //
TILE_GOBLINS = 2504765; //goblins??
TILE_STONE_BLUE = 5785654; //vampires
TILE_STONE_BROWN = 2702658; //wolves
TILE_MAZE = 3497525; //assassins
TILE_SKULLS = 12895428;
TILE_SKULLS1 = 11053224;
TILE_SKULLS2 = 2500134;
TILE_SKELLS = 13224393;
TILE_OWNTILE = 14526009;
TILE_ZOMBIES = 2843236;
TILE_SKEELS = 16777215;
TILE_SK1_STUCK = 5785654;
//TILE_MAZE_U = 2500134; //broken: don't use
//SETUP
PLAYER_LEVEL = 175;
TILE_COLORS: TIntegerArray = [
TILE_STONE_BLUE
//TILE_GRAVE_MUD
//TILE_MAZE
//TILE_BROWN
//TILE_STONE_BROWN
//TILE_GRASS
//TILE_DIRT_PATH
//TILE_SAND
//TILE_MUD
//TILE_GRAVE
//TILE_STONE
//TILE_GOBLINS
//TILE_SKELETONS_75
//TILE_SKULLS
//TILE_SKULLS1
//TILE_SKULLS2
//TILE_SKELLS
//TILE_OWNTILE
//TILE_ZOMBIES
//TILE_SKEELS
//TILE_SK1_STUCK
] ;
PLAYER_TILE = 67;
GRID_POINT: TPoint = [52, 72];
MSX1 = 27;
MSY1 = 51;
MSX2 = 777;
MSY2 = 501;
MSBOX: TBox = [MSX1, MSY1, MSX2, MSY2];
SKILL_BOX: TBox = [4, 285, 74, 355];
MANA_POT_BOX: TBox = [4, 362, 74, 432];
HP_POT_BOX: TBox = [4, 439, 74, 509];
LOOT_BOX: TBox = [748, 128, 797, 177];
MELEE_BOX: TBox = [748, 348, 797, 397];
RANGE_BOX: TBox = [748, 404, 797, 453];
MAGIC_BOX: TBox = [748, 460, 797, 509];
GAME_BOX: TBox = [2, 30, 799, 511];
BOT_LEFT_BOX: TBox = [0, 282, 78, 513];
BOT_RIGHT_BOX: TBox = [745, 345, 801, 513];
TOP_LEFT_BOX: TBox = [0, 0, 250, 67];
TOP_RIGHT_BOX: TBox = [645, 0, 801, 80];
LIMIT_BOXES: TBoxArray = [BOT_LEFT_BOX, BOT_RIGHT_BOX, TOP_LEFT_BOX, TOP_RIGHT_BOX];
MANA_BLUE = 16563260;
TEXT_WHITE = 15987699;
TEXT_YELLOW = 65514;
RED_SQUARE = 3289807;
TEXT_RED = 4013567;
TEXT_GREEN = 5171712;
TEXT_BLUE = 16563260;
LOOT_HAND = 4168184;
HP_GREEN = 4897310;
HP_YELLOW = 65514;
HP_GRAY = 6908265;
DARK_OUTLINE = 2500134;
WAND_BROWN = 28808;
CLOSE_LIGHT_GRAY = 13224393;
PLAYER_POINT: TPoint = [400, 284];
{$IFDEF LAYER}
const
NPC_COLOR = $0099FF;
PLAYER_COLOR = $0000FF;
VALID_TILE_COLOR = $00FF00;
TARGET_COLOR = $FFFF00;
var
Layer: TMufasaLayer;
procedure SetupLayer;
var
W, H: Integer;
begin
GetClientDimensions(W, H);
Layer.Init(GetNativeWindow(), True, PluginPath);
Layer.Bitmap.Init(Client.getMBitmaps());
Layer.Bitmap.SetPersistentMemory(PtrUInt(Layer.GetBitmapPtr(W, H)), W, H);
AddOnTerminate('FreeLayer');
end;
procedure FreeLayer;
begin
Layer.Bitmap.Free;
Layer.Free;
end;
function MsToTime(MS: Integer): string;
var
STA: array [0..5] of TVariantArray;
Time: array of Integer;
i, t, tl: Integer;
begin
Result := '';
tl := 3;
t := 2;
SetLength(Time,tl);
ConvertTime(MS, Time[0], Time[1], Time[2]);
STA[3] := [':', ':', '', True, 2];
for i := 0 to t do
if (Time[i] > 0) or (STA[3][tl]) or (i = t) then
Result := Result + PadZ(IntToStr(Time[i]), STA[3][tl+1]) + STA[3][i];
end;
procedure DrawClear();
begin
Layer.Bitmap.DrawClear(0);
Layer.Bitmap.DrawSystemText(MsToTime(GetTimeRunning()), 'Arial', 20, [344, 0], False, $FFFFFF);
end;
procedure DrawTPA(const TPA: TPointArray; Color: Int32; Clear: Boolean = True);
begin
if (Length(TPA) < 1) then Exit;
if Clear then DrawClear();
Layer.Bitmap.DrawTPA(TPA, Color);
end;
procedure DrawATPA(const ATPA: T2DPointArray; Clear: Boolean = True);
var
i: Int32;
Colors: TIntegerArray;
begin
if (Length(ATPA) < 1) then Exit;
if Clear then DrawClear();
SetLength(Colors, Length(ATPA));
for i := 0 to High(Colors) do Colors[i] := HSLToColor(i * 69 / Length(Colors), 100, 50);
Layer.Bitmap.DrawATPA(ATPA, Colors);
end;
procedure DrawATPA(const ATPA: T2DPointArray; Color: Int32; Clear: Boolean = True); Overload;
var
i: Int32;
Colors: TIntegerArray;
begin
if (Length(ATPA) < 1) then Exit;
if Clear then DrawClear();
SetLength(Colors, Length(ATPA));
for i := 0 to High(Colors) do Colors[i] := Color;
Layer.Bitmap.DrawATPA(ATPA, Colors);
end;
procedure DrawBoxes(const Boxes: TBoxArray; Fill: Boolean = False; Clear: Boolean = True);
var
i: Int32;
ATPA: T2DPointArray;
begin
if (Length(Boxes) < 1) then Exit;
SetLength(ATPA, Length(Boxes));
for i := 0 to High(ATPA) do
begin
if Fill then
ATPA[i] := TPAFromBox(Boxes[i]) else
ATPA[i] := EdgeFromBox(Boxes[i]);
end;
DrawATPA(ATPA, Clear);
end;
procedure DrawBoxes(const Boxes: TBoxArray; Color: Int32; Fill: Boolean = False; Clear: Boolean = True); Overload;
var
i: Int32;
ATPA: T2DPointArray;
begin
if (Length(Boxes) < 1) then Exit;
SetLength(ATPA, Length(Boxes));
for i := 0 to High(ATPA) do
begin
if Fill then
ATPA[i] := TPAFromBox(Boxes[i]) else
ATPA[i] := EdgeFromBox(Boxes[i]);
end;
DrawATPA(ATPA, Color, Clear);
end;
{$ENDIF LAYER}
function BoxWidth(const B: TBox): Int32;
begin
Result := B.X2 - B.X1 + 1;
end;
function BoxHeight(const B: TBox): Int32;
begin
Result := B.Y2 - B.Y1 + 1;
end;
function BoxArea(const B: TBox): Int32;
begin
Result := BoxWidth(B) * BoxHeight(B);
end;
function GridBox(Slot, Columns, Rows, w, h, dX, dY: Int32; StartPoint: TPoint): TBox;
begin
if (Slot > (Columns * Rows)) then
begin
WriteLn('GridBox: Invalid Slot: ', Slot);
Exit;
end;
Result.X1 := (StartPoint.x + ((Slot mod Columns) * dX) - (w div 2));
Result.Y1 := (StartPoint.y + ((Slot div Columns) * dY) - (h div 2));
Result.X2 := (Result.X1 + w);
Result.Y2 := (Result.Y1 + h);
end;
function Grid(Columns, Rows, w, h, dX, dY: Int32; StartPoint: TPoint): TBoxArray;
var
i: Int32;
begin
SetLength(Result, (Columns * Rows));
for i := 0 to High(Result) do
Result[i] := GridBox(i, Columns, Rows, w, h, dX, dY, StartPoint);
end;
procedure GetAndSet();
var
pp: TSysProcArr;
i, w, h: Int32;
begin
GetClientDimensions(w, h);
pp := Client.GetIOManager.GetProcesses;
for i := 0 to High(pp) do
begin
if Pos('NoxPlayer', pp[i].Title) then
begin
SetTarget(pp[i]);
_hh := pp[i].Handle;
GetClientDimensions(_w, _h);
if ((w = _w) and (h = _h)) then
begin
WriteLn('Do not target the game directly!');
TerminateScript;
end;
{$IFDEF LAYER} SetupLayer(); {$ENDIF LAYER}
Exit();
end;
end;
WriteLn('game not found');
TerminateScript();
end;
procedure Wait(const w1, w2: UInt32) Overload;
begin
Wait(Random(w1, w2));
end;
procedure Mouse(P: TPoint; Button: Byte = 0);
begin
tap(_hh, P, Random(44, 88));
end;
procedure MouseBox(B: TBox; Button: Byte = 0);
begin
Mouse(Point(B.X1 + Random(B.X2 - B.X1), B.Y1 + Random(B.Y2 - B.Y1)), Button);
end;
procedure TBox.Edit(const x1_, y1_, x2_, y2_: Int32);
begin
Self.X1 := Self.X1 + x1_;
Self.Y1 := Self.Y1 + y1_;
Self.X2 := Self.X2 + x2_;
Self.Y2 := Self.Y2 + y2_;
end;
procedure TBox.Shrink(const Size: Int32);
begin
Self.Edit(+Size, +Size, -Size, -Size);
end;
procedure TBox.Offset(const p: TPoint);
begin
Self.X1 := Self.X1 + p.x;
Self.X2 := Self.X2 + p.x;
Self.Y1 := Self.Y1 + p.y;
Self.Y2 := Self.Y2 + p.y;
end;
function ShrinkBox(const B: TBox; ShrinkBy: Int32): TBox;
begin
Result.X1 := B.X1 + ShrinkBy;
Result.Y1 := B.Y1 + ShrinkBy;
Result.X2 := B.X2 - ShrinkBy;
Result.Y2 := B.Y2 - ShrinkBy;
end;
function ShrinkBoxes(const BB: TBoxArray; ShrinkBy: Int32): TBoxArray;
var
i: Int32;
begin
SetLength(Result, Length(BB));
for i := 0 to High(Result) do Result[i] := ShrinkBox(BB[i], ShrinkBy);
end;
procedure IncludePointsBox(var TPA: TPointArray; const B: TBox);
begin
FilterPointsBox(TPA, B.X1, B.Y1, B.X2, B.Y2);
end;
procedure ExcludePointsBox(var TPA: TPointArray; const B: TBox);
var
Temp: TPointArray;
begin
Temp := TPAFromBox(B);
TPA := ClearTPAFromTPA(TPA, Temp);
end;
function IsDisconnected(): Boolean;
begin
Result := (InRange(CountColor(TEXT_WHITE, 0, 0, _w-1, _h-1), 2300, 2350) and
InRange(CountColor(0, 0, 0, _w-1, _h-1), 382000, 383000));
end;
function IsMagic(): Boolean;
begin
Result := (CountColor(WAND_BROWN, 745, 460, _w-1, _h-1) > 44);
end;
function GetTiles(): TBoxArray;
begin
Result := Grid(15, 9, 50, 50, 50, 50, GRID_POINT);
end;
function GetTile(Slot: Int32): TBox;
begin
if (not InRange(Slot, 0, 134)) then Exit;
Result := GridBox(Slot, 15, 9, 50, 50, 50, 50, GRID_POINT);
end;
function GetTiles(const Tiles: TIntegerArray): TBoxArray; Overload;
var
i: Int32;
begin
if (Length(Tiles) < 1) then Exit;
SetLength(Result, Length(Tiles));
for i := 0 to High(Result) do Result[i] := GetTile(Tiles[i]);
end;
function PlayerBox(): TBox;
begin
Result := GetTile(PLAYER_TILE);
end;
function PointToTile(p: TPoint): Int32;
var
i: Int32;
BB: TBoxArray;
begin
Result := -1;
BB := GetTiles();
for i := 0 to High(BB) do if PointInBox(p, BB[i]) then Exit(i);
end;
function GetTileRow(Slot: Int32): Int32;
begin
Result := Slot div 15;
end;
function GetTileCol(Slot: Int32): Int32;
begin
Result := Slot mod 15;
end;
function TileDist(t1, t2: Int32): Int32;
var
r1, r2, c1, c2: Int32;
begin
r1 := GetTileRow(t1);
r2 := GetTileRow(t2);
c1 := GetTileCol(t1);
c2 := GetTileCol(t2);
Result := max(r1, r2) - min(r1, r2) + max(c1, c2) - min(c1, c2);
end;
function IsInRange(t: Int32): Boolean;
begin
Result := (TileDist(PLAYER_TILE, t) <= 4);
end;
function InIntArrayI(const TIA: TIntegerArray; num: Int32): Int32;
var
i: Int32;
begin
Result := -1;
if inIntArray(TIA, num) then for i := 0 to High(TIA) do if (TIA[i] = num) then Exit(i);
end;
//procedure ClickMelee();
//begin
//MouseBox(MELEE_BOX);
//end;
//procedure ClickRange();
//begin
//MouseBox(RANGE_BOX);
//end;
//procedure ClickMagic();
//begin
//MouseBox(MAGIC_BOX);
//end;
function InCombat(out Tile: Int32): Boolean;
var
i: Int32;
p: TPoint;
B: TBox;
TPA: TPointArray;
ATPA, Temp: T2DPointArray;
begin
if FindColors(TPA, RED_SQUARE, MSX1, MSY1, MSX2, MSY2) then
begin
ExcludePointsBox(TPA, [0, 0, 255, 75]);
ExcludePointsBox(TPA, [0, 285, 75, _h-1]);
ExcludePointsBox(TPA, PlayerBox());
ATPA := ClusterTPA(TPA, 20);
FilterTPAsBetween(ATPA, 0, 50);
if (Length(ATPA) < 1) then Exit;
for i := 0 to High(ATPA) do
begin
p := MiddleTPA(ATPA[i]);
Tile := PointToTile(p);
B := [p.x, p.y, p.x, p.y];
B.Shrink(-20);
ExcludePointsBox(ATPA[i], B);
if InRange(Length(ATPA[i]), 100, 800) then
begin
{$IFDEF LAYER} DrawTPA(ATPA[i], TARGET_COLOR, True); {$ENDIF LAYER}
Exit(True);
end;
end;
end;
end;
function Loot(): Boolean;
begin
if (CountColor(LOOT_HAND, LOOT_BOX.X1, LOOT_BOX.Y1, LOOT_BOX.X2, LOOT_BOX.Y2) > 444) then
MouseBox(LOOT_BOX);
end;
function Close(): Boolean;
begin
if InRange(CountColor(CLOSE_LIGHT_GRAY, 745, 35, _w-1, 85), 333, 444) then
begin
MouseBox([757, 36, 790, 64]);
Exit(True);
end;
end;
function IsWalking(): Boolean
var
i, BMPA, BMPB: Int32;
begin
BMPA := BitmapFromClient(0, 0, _w-1, _h-1);
Wait(122);
BMPB := BitmapFromClient(0, 0, _w-1, _h-1);
Result := (CalculatePixelShift(BMPA, BMPB, [0, 0, _w-1, _h-1]) > 12345);
FreeBitmap(BMPA);
FreeBitmap(BMPB);
end;
function WalkWait(const Tile: Int32): Boolean;
begin
Wait(TileDist(PLAYER_TILE, Tile) * (420 - PLAYER_LEVEL));
end;
function IsMelee(): Boolean;
begin
Result := (CountColor(13417668, 750, 350, _w-1, _h-1) = 48);
end;
function IsRange(): Boolean;
begin
Result := (CountColor(13092807, 750, 350, _w-1, _h-1) = 108);
end;
procedure ClickTile(var B: TBox);
begin
B.Shrink(2);
MouseBox(B);
end;
procedure ClickTile(Slot: Int32); overload;
var
B: TBox;
begin
if (Slot = PLAYER_TILE) then Exit;
B := GetTile(Slot);
ClickTile(B);
end;
function OccupiedTile(B: TBox): Boolean;
begin
B.Shrink(5);
Result := (CountColor(DARK_OUTLINE, B.X1, B.Y1, B.X2, B.Y2) > 175);
end;
function OccupiedTile(const Tile: Int32): Boolean; overload;
begin
Result := OccupiedTile(GetTile(Tile));
end;
function ValidTileColor(const B: TBox): Boolean;
var
i, c: Int32;
begin
for i := 0 to High(TILE_COLORS) do c += CountColor(TILE_COLORS[i], B.X1, B.Y1, B.X2, B.Y2);
Result := (c > 9);
end;
function ValidTileColor(Slot: Int32): Boolean; overload;
begin
if InRange(Slot, 0, 134) then Result := ValidTileColor(GetTile(Slot));
end;
function ValidTile(B: TBox): Boolean;
var
i, c, a: Int32;
begin
B.Shrink(5);
a := BoxArea(B);
for i := 0 to High(TILE_COLORS) do c += CountColor(TILE_COLORS[i], B.X1, B.Y1, B.X2, B.Y2);
Result := ((c / a) > 0.60);
end;
function ValidTile(Slot: Int32): Boolean; overload;
begin
if InRange(Slot, 0, 134) then Result := ValidTile(GetTile(Slot));
end;
function GetAdjacentTileSlots(const Tile: Int32): TIntegerArray;
var
Row, Col: Int32;
begin
if (not InRange(Tile, 0, 134)) then
begin
WriteLn('GetAdjacentTileSlots: tile not in range');
Exit;
end;
Col := GetTileCol(Tile);
Row := GetTileRow(Tile);
if InRange(Col, 0, 13) then Result := Result + (Tile + 1);
if InRange(Col, 1, 14) then Result := Result + (Tile - 1);
if InRange(Row, 0, 7) then Result := Result + (Tile + 15);
if InRange(Row, 1, 8) then Result := Result + (Tile - 15);
end;
function GetAdjacentTileBoxes(const Tile: Int32): TBoxArray;
var
i: Int32;
Tiles: TIntegerArray;
begin
Tiles := GetAdjacentTileSlots(Tile);
if (Length(Tiles) < 1) then Exit;
SetLength(Result, Length(Tiles));
for i := 0 to High(Tiles) do Result[i] := GetTile(Tiles[i]);
end;
procedure ClickSkill_Box();
begin
MouseBox(SKILL_BOX);
end;
procedure ClickMana_Box();
begin
MouseBox(MANA_POT_BOX);
end;
function HasMPot(): Boolean;
begin
Result := (CountColor(8871435, 42, 442, 50, 443) > 9);
end;
procedure ClickMPot();
begin
MouseBox(MANA_POT_BOX);
end;
function GetManaPercent(): Int32;
var
TPA: TPointArray;
begin
Result := 100 * CountColor(MANA_BLUE, 4, 55, 250, 61) div 1470;
end;
function GetWalkableTileSlots(): TIntegerArray;
var
i, j, h: Int32;
TileSlots, IgnoreSlots: TIntegerArray;
begin
TileSlots := GetAdjacentTileSlots(PLAYER_TILE);
if (Length(TileSlots) < 1) then Exit;
for j := 0 to High(TileSlots) do
if (ValidTile(TileSlots[j]) and (not OccupiedTile(TileSlots[j]))) then
Result := Result + TileSlots[j] else
IgnoreSlots := IgnoreSlots + TileSlots[j];
if (Length(Result) < 1) then
begin
WriteLn('GetWalkableTileSlots: no walkable tiles found adjacent to player.');
ClickSkill_Box() ;
if (GetManaPercent() < 50) and HasMPot() then ClickMPot() ;
//ClickMana_Box();
Wait(567, 765);
Exit;
end;
IgnoreSlots := IgnoreSlots + PLAYER_TILE;
h := High(Result);
for i := 0 to h do
begin
TileSlots := GetAdjacentTileSlots(Result[i]);
if (Length(TileSlots) < 1) then Continue;
for j := 0 to High(TileSlots) do
begin
if InIntArray(CombineIntArray(Result, IgnoreSlots), TileSlots[j]) then
Continue;
for j := 0 to High(TileSlots) do
if (ValidTile(TileSlots[j]) and (not OccupiedTile(TileSlots[j]))) then
Result := Result + TileSlots[j] else
IgnoreSlots := IgnoreSlots + TileSlots[j];
h := High(Result);
end;
end;
{$IFDEF LAYER} DrawBoxes(ShrinkBoxes(GetTiles(Result), 1), VALID_TILE_COLOR, False, False); {$ENDIF LAYER}
end;
function GetWalkableTileBoxes(): TBoxArray;
var
i: Int32;
Slots: TIntegerArray;
begin
Slots := GetWalkableTileSlots();
if (Length(Slots) < 1) then Exit;
SetLength(Result, Length(Slots));
for i := 0 to High(Result) do Result[i] := GetTile(Slots[i]);
end;
procedure RandomWalk();
var
r: Int32;
Tiles: TIntegerArray;
begin
Tiles := GetWalkableTileSlots();
if (Length(Tiles) < 1) then Exit;
r := Tiles[Random(High(Tiles))];
{$IFDEF LAYER} DrawBoxes([GetTile(r)], VALID_TILE_COLOR, True, False); {$ENDIF LAYER}
ClickTile(r);
WalkWait(r);
end;
//SETUP
function GetDirectionTile(): Int32;
var
i, n: Int32;
tt, ValidTiles: TIntegerArray;
begin
Result := -1;
ValidTiles := GetWalkableTileSlots();
if (Length(ValidTiles) < 1) then Exit;
repeat
case _d of
{N} 1: tt := [7, 6, 8, 5, 9, 4, 10, 22, 23, 21, 24, 20, 25, 19, 26, 18, 27, 17, 28, 16];
{E} 2: tt := [73, 88, 58, 103, 42, 118, 28];
{S} 3: tt := [127, 126, 128, 125, 129, 124, 130, 112, 113, 111, 114, 110, 115, 109, 116, 108, 117, 107, 118, 106];
{W} 4: tt := [61, 76, 46, 91, 31, 106, 16];
end;
for i := 0 to High(tt) do if InIntArray(ValidTiles, tt[i]) then Exit(tt[i]);
_d := (_d mod 4) + 1;
Inc(n);
until (n > 4);
end;
function SlotFromCR(const Col, Row: Int32): Int32;
begin
Result := (Row * 15) + Col;
end;
function GetTileTPA(const c1, r1, c2, r2: Int32): TPointArray;
var
minR, minC, maxR, maxC, n, i, j: Int32;
begin
minR := min(r1, r2); maxR := max(r1, r2);
minC := min(c1, c2); maxC := max(c1, c2);
SetLength(Result, (maxR-minR+1)*(maxC-minC+1));
for i := minC to maxC do
begin
for j := minR to maxR do
begin
Result[n] := [i, j];
Inc(n);
end;
end;
end;
function GetTileTPA(const t1, t2: Int32): TPointArray; overload;
begin
Result := GetTileTPA(GetTileCol(t1), GetTileRow(t1), GetTileCol(t2), GetTileRow(t2));
end;
function GetValidTileNear(const Slot: Int32): Int32;
var
i, x, y: Int32;
B: TBox;
Tiles: TPointArray;
begin
Tiles := GetTileTPA(PLAYER_TILE, Slot);
SortTPAFrom(Tiles, [GetTileCol(Slot), GetTileRow(Slot)]);
for i := 0 to High(Tiles) do
begin
B := GetTile(SlotFromCR(Tiles[i].x, Tiles[i].y));
B.Shrink(4);
if (ValidTile(SlotFromCR(Tiles[i].x, Tiles[i].y)) and
(not FindColor(x, y, RED_SQUARE, B.X1, B.Y1, B.X2, B.Y2))) then
Exit(SlotFromCR(Tiles[i].x, Tiles[i].y));
end;
end;
function GetHpBarTPA(): TPointArray;
var
TPA, TPA2: TPointArray;
begin
FindColors(TPA, HP_GREEN, MSX1, MSY1, MSX2, MSY2);
//if FindColors(TPA2, HP_YELLOW, MSX1, MSY1, MSX2, MSY2) then TPA := CombineTPA(TPA, TPA2); //
if FindColors(TPA2, HP_GRAY, MSX1, MSY1, MSX2, MSY2) then TPA := CombineTPA(TPA, TPA2);
if FindColors(TPA2, RED_SQUARE, MSX1, MSY1, MSX2, MSY2) then TPA := CombineTPA(TPA, TPA2);
ExcludePointsBox(TPA, [375, 240, 425, 250]);
if (Length(TPA) < 1) then Exit;
Result := CopyTPA(TPA);
end;
function GetHpBarATPA(): T2DPointArray;
var
i: Int32;
B: TBox;
Temp: T2DPointArray;
begin
Temp := ClusterTPA(GetHpBarTPA, 1);
FilterTPAsBetween(Temp, 250, 9000);
FilterTPAsBetween(Temp, 0, 50);
if (Length(Temp) < 1) then Exit;
for i := 0 to High(Temp) do
begin
B := GetTPABounds(Temp[i]);
if (InRange(B.Y2 - B.Y1, 3, 6) and InRange(B.X2 - B.X1, 40, 50)) then Result := Result + Temp[i];
end;
end;
function GetPlayerTileSlots(const ATPA: T2DPointArray): TIntegerArray;
var
i, Tile: Int32;
P: TPoint;
B: TBox;
begin
for i := 0 to High(ATPA) do
begin
B := GetTPABounds(ATPA[i]);
if ((CountColor(TEXT_BLUE, B.X1, B.Y1 - 12, B.X2, B.Y2) +
CountColor(TEXT_GREEN, B.X1, B.Y1 - 12, B.X2, B.Y2) +
CountColor(TEXT_RED, B.X1, B.Y1 - 12, B.X2, B.Y2)) > 70) then
begin
P := MiddleTPA(ATPA[i]);
P.Y += 10;
Tile := PointToTile(P);
if (InRange(Tile, 0, 134) and (Tile <> PLAYER_TILE)) then Result := Result + Tile;
end;
end;
end;
function GetPlayerTileBoxes(const ATPA: T2DPointArray): TBoxArray;
var
i: Int32;
Tiles: TIntegerArray;
begin
Tiles := GetPlayerTileSlots(ATPA);
if (Length(Tiles) < 1) then Exit;
SetLength(Result, Length(Tiles));
for i := 0 to High(Tiles) do Result[i] := GetTile(Tiles[i]);
end;
function GetNPCTileSlots(const ATPA: T2DPointArray): TIntegerArray;
var
i, j, Tile: Int32;
ValidTiles, AdjTiles, PlayerTiles: TIntegerArray;
P: TPoint;
B: TBox;
begin
PlayerTiles := GetAdjacentTileSlots(PLAYER_TILE);
ValidTiles := GetWalkableTileSlots();
for i := 0 to High(ATPA) do
begin
B := GetTPABounds(ATPA[i]);
if ((CountColor(TEXT_WHITE, B.X1, B.Y1 - 12, B.X2, B.Y2) +
CountColor(TEXT_YELLOW, B.X1, B.Y1 - 12, B.X2, B.Y2)) > 70) then
begin
P := MiddleTPA(ATPA[i]);
P.Y += 25;
Tile := PointToTile(P);
if InRange(Tile, 0, 134) then
begin
if InIntArray(PlayerTiles, Tile) then
begin
Result := Result + Tile;
end else
begin
if ValidTileColor(Tile) then
Result := Result + Tile;
end;
end;
end;
end;
end;
function GetNPCTileBoxes(const ATPA: T2DPointArray): TBoxArray;
var
i: Int32;
Tiles: TIntegerArray;
begin
Tiles := GetNPCTileSlots(ATPA);
if (Length(Tiles) < 1) then Exit;
SetLength(Result, Length(Tiles));
for i := 0 to High(Tiles) do Result[i] := GetTile(Tiles[i]);
end;
function ClickClosestNPC(): Boolean;
var
i: Int32;
NPCs, Players, Exclude: TIntegerArray;
ATPA: T2DPointArray;
bb: TBoxArray;
begin
ATPA := GetHpBarATPA();
if (Length(ATPA) < 1) then Exit;
SortATPAFromMidPoint(ATPA, PLAYER_POINT);
NPCs := GetNPCTileSlots(ATPA);
if (Length(NPCs) < 1) then Exit;
{$IFDEF LAYER} DrawBoxes(GetTiles(NPCs), NPC_COLOR, False, False); {$ENDIF LAYER}
Players := GetPlayerTileSlots(ATPA);
if (Length(Players) > 0) then
begin
{$IFDEF LAYER} DrawBoxes(GetTiles(Players), PLAYER_COLOR, False, False); {$ENDIF LAYER}
Exclude := CombineIntArray(Exclude, Players);
for i := 0 to High(Players) do Exclude := CombineIntArray(Exclude, GetAdjacentTileSlots(Players[i]));
ClearSameIntegers(Exclude);
end else Exclude := Exclude + PLAYER_TILE;
for i := 0 to High(NPCs) do
begin
if InIntArray(Exclude, NPCs[i]) then Continue;
ClickTile(NPCs[i]);
{$IFDEF LAYER} DrawBoxes([GetTile(NPCs[i])], NPC_COLOR, True, False); {$ENDIF LAYER}
if IsMelee() then WalkWait(NPCs[i]);
Exit(True);
end;
end;
function HasArrows(): Boolean;
begin
Result := (CountColor(TEXT_WHITE, 675, 485, 692, _h-1) > 44);
end;
function FollowDirections(): Boolean;
var
t: Int32;
begin
t := GetDirectionTile();
if (t < 0) then Exit(False);
{$IFDEF LAYER} DrawBoxes([GetTile(t)], VALID_TILE_COLOR, True, False); {$ENDIF LAYER}
ClickTile(t);
WalkWait(t);
Exit(True);
end;
function IsTraining(): Boolean;
begin
Result := (CountColor(TEXT_RED, 257, 357, 542, 375) > 1000);
end;
procedure Mainloop();
var
TempTile, t: Int32;
begin
if IsDisconnected() then
begin
WriteLn('Disconnected');
TerminateScript();
end;
{$IFDEF LAYER} DrawClear(); {$ENDIF LAYER}
while InCombat(TempTile) do
begin
if (IsMagic() or IsRange()) then
begin
if (not IsInRange(TempTile)) then
begin
t := GetValidTileNear(TempTile);
ClickTile(t);
WalkWait(t);
end;
end else if ((TileDist(PLAYER_TILE, TempTile) > 1) and (not IsWalking())) then
begin
if ClickClosestNPC() then Wait(345, 456);
end;
Loot();
Wait(444, 666);
end;
//if (MAGIC and (GetManaPercent() > 20)) then
//begin
//if (not IsMagic()) then ClickMagic;
//end else
//if (RANGE and HasArrows()) then
//begin
//if (not IsRange()) then ClickRange();
//end else
//if (not IsMelee()) then ClickMelee();
while IsTraining() do
begin
{$IFDEF LAYER} Layer.Bitmap.DrawSystemText('TRAINING', 'Arial', 20, [344, 30], False, $0000FF); {$ENDIF LAYER}
FollowDirections();
Wait(234, 345);
end;
if Close() then Wait(345, 456);
if Loot() then Wait(345, 456);
if ((not IsTraining()) and ClickClosestNPC()) then
begin
Wait(567, 876);
end else if (not FollowDirections()) then RandomWalk();
Wait(121, 212);
end;
begin
ClearDebug();
GetAndSet();
while True do Mainloop();
end.[YOUTUBE]JVkLQqE8o1Y[/YOUTUBE]
Video Problem
I will appreciate any help. Thanks.