Playing around with Tribots draw tile debug feature, I wanted something similar.
After doing some reading through the forums, I came upon these threads:
https://villavu.com/forum/showthread.php?t=72965
https://villavu.com/forum/showthread.php?t=73768
With some inspiration, I have come up with these 2 scripts.
Reflection Tile Grid:
tzzOk41.png
Simba Code:
program TileGridDrawing
{$DEFINE SMART}
{$i Reflection/Reflection.simba}
{
Tile Grid Drawing
Author: Dissimulo (https://villavu.com/forum/member.php?u=160877)
Last Update: 19/05/2016
Version: 1.0
Category: Utility
Description: Displays a grid of the tiles surrounding the player
Includes: Reflection
Features:
- Reflection (https://villavu.com/forum/showthread.php?t=111662)
- Simple SMART paint
Versions:
- 1.0 (19/05/2016)
Cleaned up for the public
Credits:
- Kyle (Lape Reflection)
}
var MyGuy: TReflectLocalPlayer;
procedure DrawTileGrid();
var
i, j, k: integer;
TileArray: Array[0..8] of Array [0..8] of TPoint;
PointTileArray: Array[0..7] of Array [0..7] of TPoint;
begin
for j := 0 to 8 do
begin
for k := 0 to 8 do
begin
TileArray[j][k] := Point((MyGuy.GetTile.X - 4 + j), (MyGuy.GetTile.Y - 4 + k));
if ((MSX1 < TReflectionTiles.TileToMS(TileArray[j][k]).X) and (TReflectionTiles.TileToMS(TileArray[j][k]).X < MSX2) and
(MSY1 < TReflectionTiles.TileToMS(TileArray[j][k]).Y) and (TReflectionTiles.TileToMS(TileArray[j][k]).Y < MSY2)) then
begin
Reflect.Smart.Graphics.DrawCircle(TReflectionTiles.TileToMS(TileArray[j][k]), 1, clRed, True);
//Reflect.Smart.Graphics.DrawClippedText((inttostr(k) + ', ' + inttostr(j)),statChars,TReflectionTiles.TileToMS(TileArray[j][k]),clRed);
end;
end;
end;
for j := 0 to 7 do
begin
for k := 0 to 7 do
begin
PointTileArray[j][k] := MiddleTPA([TReflectionTiles.TileToMS(TileArray[j][k]), TReflectionTiles.TileToMS(TileArray[j+1][k+1]),
TReflectionTiles.TileToMS(TileArray[j+1][k]), TReflectionTiles.TileToMS(TileArray[j][k+1])]);
if ((MSX1 < PointTileArray[j][k].X) and (PointTileArray[j][k].X < MSX2) and
(MSY1 < PointTileArray[j][k].Y) and (PointTileArray[j][k].Y < MSY2)) then
begin
Reflect.Smart.Graphics.DrawCircle(PointTileArray[j][k], 1, clYellow, True);
//Reflect.Smart.Graphics.DrawClippedText((inttostr(k) + ', ' + inttostr(j)),statChars,PointTileArray[j][k],clYellow);
end;
end;
end;
for j := 0 to 7 do
begin
for k := 0 to 7 do
begin
if (k - 1 > -1) then
if ((MSX1 < PointTileArray[j][k].X) and (PointTileArray[j][k].X < MSX2) and
(MSY1 < PointTileArray[j][k].Y) and (PointTileArray[j][k].Y < MSY2) and
(MSX1 < PointTileArray[j][k - 1].X) and (PointTileArray[j][k - 1].X < MSX2) and
(MSY1 < PointTileArray[j][k - 1].Y) and (PointTileArray[j][k - 1].Y < MSY2)) then
Reflect.Smart.Graphics.DrawLine(PointTileArray[j][k], PointTileArray[j][k - 1], clPurple);
if (j - 1 > -1) then
if ((MSX1 < PointTileArray[j][k].X) and (PointTileArray[j][k].X < MSX2) and
(MSY1 < PointTileArray[j][k].Y) and (PointTileArray[j][k].Y < MSY2) and
(MSX1 < PointTileArray[j - 1][k].X) and (PointTileArray[j - 1][k].X < MSX2) and
(MSY1 < PointTileArray[j - 1][k].Y) and (PointTileArray[j - 1][k].Y < MSY2)) then
Reflect.Smart.Graphics.DrawLine(PointTileArray[j][k], PointTileArray[j - 1][k], clPurple);
end;
end;
end;
begin
Reflect.Setup;
MyGuy.Username := 'USERNAME';
MyGuy.Password := 'PASSWORD';
MyGuy.Active := True;
MyGuy.Login;
repeat
wait(600);
Reflect.Smart.Graphics.Clear;
DrawTileGrid();
until(False);
end.
Object Tile Bounds:
7K95Kdf.png
yjgMWaN.png
44EXIXx.png
Simba Code:
program ObjectTileBounds
{$DEFINE SMART}
{$i Reflection/Reflection.simba}
{
Object Tile Bounds
Author: Dissimulo (https://villavu.com/forum/member.php?u=160877)
Last Update: 19/05/2016
Version: 1.0
Category: Utility
Description: Displays the bounds of the tile that the object is on
Includes: Reflection
Features:
- Reflection (https://villavu.com/forum/showthread.php?t=111662)
- Simple SMART paint
Versions:
- 1.0 (19/05/2016)
Cleaned up for the public
Credits:
- Kyle (Lape Reflection)
}
var MyGuy: TReflectLocalPlayer;
ObjectArray: TReflectObjectArray;
tmpTPA, tmpTPAx, tmpTPAy: TPointArray;
tmpATPA, tmpATPAcolor: Array of TPointArray;
i: integer;
function GetObjectTileBounds(ObjectName: String; ObjectType: TObjectType; DrawBounds: Boolean; var OutputATPA: Array of TPointArray): Boolean;
var
i, j, k: integer;
MyTile: TTile;
TileArray: Array[0..2] of Array [0..2] of TPoint;
PointTileArray: Array[0..1] of Array [0..1] of TPoint;
begin
ObjectArray.Get(ObjectType, ObjectName, 10);
SetLength(OutputATPA, (High(ObjectArray) + 1));
for i:= 0 to High(ObjectArray) do
begin
for j := 0 to 2 do
begin
for k := 0 to 2 do
begin
TileArray[j][k] := Point((ObjectArray[i].GetTile.X - 1 + j), (ObjectArray[i].GetTile.Y - 1 + k));
end;
end;
for j := 0 to 1 do
begin
for k := 0 to 1 do
begin
PointTileArray[j][k] := MiddleTPA([TReflectionTiles.TileToMS(TileArray[j][k]), TReflectionTiles.TileToMS(TileArray[j+1][k+1]),
TReflectionTiles.TileToMS(TileArray[j+1][k]), TReflectionTiles.TileToMS(TileArray[j][k+1])]);
end;
end;
for j := 0 to 1 do
begin
for k := 0 to 1 do
begin
if (k - 1 > -1) then
if ((MSX1 < PointTileArray[j][k].X) and (PointTileArray[j][k].X < MSX2) and
(MSY1 < PointTileArray[j][k].Y) and (PointTileArray[j][k].Y < MSY2) and
(MSX1 < PointTileArray[j][k - 1].X) and (PointTileArray[j][k - 1].X < MSX2) and
(MSY1 < PointTileArray[j][k - 1].Y) and (PointTileArray[j][k - 1].Y < MSY2) and DrawBounds) then
Reflect.Smart.Graphics.DrawLine(PointTileArray[j][k], PointTileArray[j][k - 1], clPurple);
if (j - 1 > -1) then
if ((MSX1 < PointTileArray[j][k].X) and (PointTileArray[j][k].X < MSX2) and
(MSY1 < PointTileArray[j][k].Y) and (PointTileArray[j][k].Y < MSY2) and
(MSX1 < PointTileArray[j - 1][k].X) and (PointTileArray[j - 1][k].X < MSX2) and
(MSY1 < PointTileArray[j - 1][k].Y) and (PointTileArray[j - 1][k].Y < MSY2) and DrawBounds) then
Reflect.Smart.Graphics.DrawLine(PointTileArray[j][k], PointTileArray[j - 1][k], clPurple);
end;
end;
OutputATPA[i] := [PointTileArray[0][0], PointTileArray[0][1], PointTileArray[1][1], PointTileArray[1][0]];
Result := True;
end;
end;
begin
Reflect.Setup;
MyGuy.Username := 'USERNAME';
MyGuy.Password := 'PASSWORD';
MyGuy.Active := True;
MyGuy.Login;
repeat
wait(400);
Reflect.Smart.Graphics.Clear;
if GetObjectTileBounds('Rocks', ObjGame, True, tmpATPA) then
begin
for i := 0 to high(tmpATPA) do
begin
tmpTPAx := CopyTPA(tmpATPA[i]);
SortTPAByX(tmpTPAx, True);
tmpTPAy := CopyTPA(tmpATPA[i]);
SortTPAByY(tmpTPAy, True);
if (PointInBox(Point(Round((tmpTPAx[0].X + tmpTPAx[1].X) / 2), Round((tmpTPAy[0].Y + tmpTPAy[1].Y) / 2)), intToBox(MSX1, MSY1, MSX2, MSY2)) and
PointInBox(Point(Round((tmpTPAx[2].X + tmpTPAx[3].X) / 2), Round((tmpTPAy[2].Y + tmpTPAy[3].Y) / 2)), intToBox(MSX1, MSY1, MSX2, MSY2))) then
begin
Reflect.Smart.Graphics.DrawBox(Round((tmpTPAx[0].X + tmpTPAx[1].X) / 2), Round((tmpTPAy[0].Y + tmpTPAy[1].Y) / 2),
Round((tmpTPAx[2].X + tmpTPAx[3].X) / 2), Round((tmpTPAy[2].Y + tmpTPAy[3].Y) / 2), False, clYellow);
end;
end;
end;
until(False);
end.
The last 2 images are combining color finding within the TBoxes.