What can this be used for?

- Main screen click walking.
- Item tracking
- MMtoMS (inaccurate atm, but close)

Shown above is the mid points of GridCoords and a box around it (example in GridBox).

Assuming you are facing at near perfect 0, 90, 180, 270 degrees and the ground is level this will get the mid point of the tile on main screen at high angle.

Point(0, 0) is on Character location (Grid coords example in code below). If point isn't in MSBox then the result is Point(-1, -1).

The Mini-Map is too distorted to get perfect position of what tile that grid is on. But I gave it a rough estimate and threw it in, its fairly accurate.

Simba Code:program new;

{$i srl/srl/misc/Smart.simba}

{$i srl/srl.simba}

{$i srl/srl/misc/paintsmart.simba}

Function GridCoords(GridPoint: TPoint): TPoint;

var

Yh: Extended;

begin

Yh := Abs((GridPoint.y+0.0) + 6.0);

Result.x := Round(259.5 + ((GridPoint.x+1.0)*38.0/(45.7-(Yh/9.0*12.8))) * 38.0);

Result.y := Round(178.5 + (GridPoint.y+0.0) * (36.0 + ((GridPoint.y+0.0)*37.0)/25.0));

if not PointInBox(Result, MSBox) then

Result := Point(-1, -1);

end;

Function MMToGrid(x, y: integer): TPoint;//Still needs work

begin

Result := Point(Round((x-626.5)/4.2), Round((y-84.5)/4.2));

end;

Function MMtoMSGrid(x, y: integer): TPoint;

begin

Result := GridCoords(MMtoGrid(x, y));

end;

Function GridBox(GridPoint: TPoint): TBox;//19x17 box around mid point (Just an example)

var

T: TPoint;

begin

T := GridCoords(GridPoint);

Result := IntToBox(T.x-10, T.y-8, T.x+8, T.y+8);

end;

var

x, y: integer;

T: TPoint;

begin

Smart_Server := 1;

Smart_Members:= true;

Smart_Signed := true;

Smart_SuperDetail := false;

SetupSRL;

SMART_ClearCanvas;

for x := -8 to 8 do

for y := -6 to 3 do

begin

T := GridCoords(Point(x, y));

if (T.x = -1) then

Continue;

SMART_DrawBoxEx(False, GridBox(Point(x, y)), clRed);

SMART_DrawDotsEx(False, [GridCoords(Point(x, y))], clBlue);

end;

Writeln(MMtoGrid(632, 65));

Writeln(MMtoMSGrid(651, 65));

end.

This is Grid 16 with polygon boxes showing tiles as well as the MMtoMS formula it uses. (which is basically what Grid 16 is) Its the most accurate MMtoMS I think we can manage right now. Note it returns the TPoint position on the ground. (This is assuming all tiles on MM are 4x4)

Example code below.

Simba Code:program new;

{$i srl/srl/misc/Smart.simba}

{$i srl/srl.simba}

{$i srl/srl/misc/paintsmart.simba}

Function GridCoords16(Grid16: TPoint): TPoint;

var

Yh, yMod: Extended;

begin

yMod := 36.0;

Yh := Abs((Grid16.y+0.0) + yMod);

Result.x := Round(263.5 + ((Grid16.x)*9.75/(12.8-(Yh/yMod*3.15))) * 9.75);

Result.y := Round(182.0 + (Grid16.y+0.0) * (6.3 + ((Yh/yMod)*2.4)));

if not PointInBox(Result, MSBox) then

Result := Point(-1, -1);

end;

Function MMtoMSG16(x, y: integer): TPoint;

begin

Result := GridCoords16(Point(x-627, y-85));

end;

procedure DrawGridBox(PT: TPoint; Color: integer);

var

T: TPoint;

i: integer;

ATPA: T2DPointArray;

begin

T := Point(PT.x*4, PT.y*4);

SetLength(ATPA, 4);

ATPA[0] := [GridCoords16(Point(T.x-2, T.y-2)), GridCoords16(Point(T.x+1, T.y-2))];

ATPA[1] := [GridCoords16(Point(T.x-2, T.y+1)), GridCoords16(Point(T.x+1, T.y+1))];

ATPA[2] := [GridCoords16(Point(T.x-2, T.y-2)), GridCoords16(Point(T.x-2, T.y+1))];

ATPA[3] := [GridCoords16(Point(T.x+1, T.y-2)), GridCoords16(Point(T.x+1, T.y+1))];

for i := 0 to 3 do

begin

if (ATPA[i][0].x = -1) or (ATPA[i][1].x = -1) then

Continue;

SMART_DrawLine(False, ATPA[i][0], ATPA[i][1], Color);

End;

end;

var

x, y, i: integer;

T: TPoint;

npc: TPointArray;

begin

Smart_Server := 1;

Smart_Members:= true;

Smart_Signed := true;

Smart_SuperDetail := false;

SetupSRL;

//SaveScreenshot(AppPath+'Grid shit 3.bmp');

SMART_ClearCanvas;

for x := -36 to 36 do

for y := -30 to 14 do

begin

T := GridCoords16(Point(x, y));

if (T.x = -1) then

Continue;

//SMART_DrawBoxEx(False, GridBox(Point(x, y)), clRed);

if (x = 0) and (y = 0) then

SMART_DrawDotsEx(false, [GridCoords16(Point(x, y))], clRed)

else

SMART_DrawDotsEx(false, [GridCoords16(Point(x, y))], clBlue);

end;

for x := -8 to 8 do

for y := -8 to 5 do

DrawGridBox(Point(x,y), clGreen);

npc := GetMiniMapDots('npc');

for i := 0 to high(NPC) do

Begin

T := MMtoMSG16(NPC[i].x, NPC[i].y);

SMART_DrawDotsEx(false, [T], clRed);

SMART_DrawBoxEx(False, IntToBox(T.x-2, T.y-2, T.x+2, T.y+2), clYellow);

SMART_DrawBoxEx(False, IntToBox(T.x-10, T.y-30, T.x+10, T.y+10), clBlue);

end;

end.