SRL Archive - SRL Snippets

MS Grid system


Narcle

2012-01-21 18:25:09

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.


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.


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.

Shuttleu

2012-01-21 18:26:56

OMG! awesome!

mind if i use this for a bird nest finder?

~shut

[XoL]

2012-01-21 18:27:41

Wow this is awesome, nice job!

Narcle

2012-01-21 18:28:19

From: Shuttleu
OMG! awesome!

mind if i use this for a bird nest finder?

~shut


Ja. I was planning on adding it to math.simba in SRL after I get a better MMtoMSGrid.

Edit:
I still have grid walking functions to add.

onilika

2012-01-21 18:54:36

That's great for many things! Was waiting for something like that! :)
I'll take a deeper watch to it.

~onilika

Brandon

2012-01-21 19:04:15

From: Narcle
Ja. I was planning on adding it to math.simba in SRL after I get a better MMtoMSGrid.

Edit:
I still have grid walking functions to add.


OMG ILU.. :) I'm going to use this in every script if its successful.. Of course all credit to you. And where did u get the formula for the MMToMS? Is it a new one or the one from the include? if its the one from the include this will also have a tolerance of 1 tile off right?

Oh and my last and final question.. the picture shows grids spaced apart like that, what about the boxes that are in-between the grid boxes? Going to be the next SPS?

P.S. This will be the first thread I watch lol.

Richard

2012-01-21 20:01:55

I was talking to Naum a while back about developing a relative tiling system like this, just never got round to it with us both having A-levels. Very glad someone did it, though! Something that I was going to make an effort to create would be a way of detecting the pitch, then use the information on the pitch and rotation of the screen to get detailed coordinates at any screen angle and compass direction. The issue that I foresaw was that of tiles not all being flat, I guess this hasn't countered that problem just yet?

momotron

2012-01-21 20:04:49

From: ggzz
OMG ILU.. :) I'm going to use this in every script if its successful.. Of course all credit to you. And where did u get the formula for the MMToMS? Is it a new one or the one from the include? if its the one from the include this will also have a tolerance of 1 tile off right?

Oh and my last and final question.. the picture shows grids spaced apart like that, what about the boxes that are in-between the grid boxes? Going to be the next SPS?

P.S. This will be the first thread I watch lol.


The spaces are insignificant, so even if you press on that space, you'll end up in the square (grid thing) closest to the space you clicked :) the squares are the "tile".

Does that make any sense?

Brandon

2012-01-21 20:07:56

From: momotron
The spaces are insignificant, so even if you press on that space, you'll end up in the square (grid thing) closest to the space you clicked :) the squares are the "tile".

Does that make any sense?


No.. because it states it can be used for item finding when completed.. what happens when an item is directly in between a space and ur mouse only hovers on those grid boxes.. Not all tiles are flat so of course items can be on those spaces.

Shuttleu

2012-01-21 20:29:13

so far its been working perfectly for my birds nest finder

~shut

Gu3st...

2012-01-21 20:54:06

This is cool! I love the math!

Press Play

2012-01-21 21:35:29

This is amazing!! Good work Narcle :D

Narcle

2012-01-21 23:19:07

From: Richard
I was talking to Naum a while back about developing a relative tiling system like this, just never got round to it with us both having A-levels. Very glad someone did it, though! Something that I was going to make an effort to create would be a way of detecting the pitch, then use the information on the pitch and rotation of the screen to get detailed coordinates at any screen angle and compass direction. The issue that I foresaw was that of tiles not all being flat, I guess this hasn't countered that problem just yet?


Yeah Pitch would be difficult but I know it can be applied to the Compass and use it at any compass angle (I just didn't want to go into the math yet). Usually people always set scripts to be N, S, E or W.

Until we can map it out (hopefully via SPS) you could set a Height variable for that particular tile in a database of sorts.

This is just a very BASIC formula, then gives you a rough idea.

I have a lot more to add to this (hopefully).

I also have ideas to use this with ObjectDTM to map out the area, but I don't know how accurate in pixels it will be yet.

Kyle Undefined

2012-01-22 00:48:57

Ohhh this looks sexy! :D Great work!

ReadySteadyGo

2012-01-22 01:42:39

I did something like this a while ago but using a perspective transformation.


I will create my own thread with the source as I don't want to hijack yours Narcle.

mormonman

2012-01-22 02:05:51

I use a much simpler version of this to pick up ground items in my roach killer.

P1nky

2012-01-22 02:09:57

Lovely. Code is Smexy.

Narcle

2012-01-22 02:20:30

From: ReadySteadyGo
I did something like this a while ago but using a perspective transformation.


I will create my own thread with the source as I don't want to hijack yours Narcle.


Ya w/e, i just want to see code. XD

Also I'm going to make a grid setup where each tile is a 4x4 (about the size in pixels of a tile on minimap). Then draw a polygon for the general area inside it.

ReadySteadyGo

2012-01-22 02:29:20

From: Narcle
Ya w/e, i just want to see code. XD

Also I'm going to make a grid setup where each tile is a 4x4 (about the size in pixels of a tile on minimap). Then draw a polygon for the general area inside it.


Sweet, we should try and combine our work. I'm going to try and make it a bit more robust. Atm, it takes a lot of fiddling for my one to look right. I want to be able to just plug in the values that you get when you type getcamerapos into the developer console. :P

mormonman

2012-01-22 02:59:45

My ghetto implementation of this..picks up all items.
function MMMS(MM: TPoint): TPoint;//credit Home
Var
X, Y :Extended;
begin
X := (((MM.X - 626.5) * 9.81119354838709677419354838709677) + 258.531);
Y := (((MM.Y - 84.5) * 8.84193548387096774193548387096777) + 175.341);
Result := Point(Round(X), Round(Y));
end;

function GetSBox(P: TPoint): TBox;
begin
if not LoggedIn then Exit;
Result := PointToBox(MMMS(Point(P.x - 2, P.y - 3)),
MMMS(Point(P.x + 3, P.y + 2)));
end;

procedure RemoveColorTPA(SB: TBox; var TPA: TPointArray; Col, Tol: Integer;
H, S: Extended);
var
RTPA: TPointArray;
HM, SM: Extended;
CTS: Integer;
begin
GetColorspeed2Modifiers(HM, SM);
CTS := GetColorToleranceSpeed;

SetColorspeed2Modifiers(H, S);
ColorToleranceSpeed(2);
if FindColorsTolerance(RTPA, Col, SB.X1, SB.Y1, SB.X2, SB.Y2, Tol) then
TPA := ClearTPAFromTPA(TPA, RTPA);

SetColorspeed2Modifiers(HM, SM);
ColorToleranceSpeed(CTS);
end;

procedure RemoveBadColors(SB: TBox; var TPA: TPointArray);
var
CT1, CT2, CT3, CT4, CT5, CT6, CT7, CT8: array[0..1] of Integer;
HS1, HS2, HS3, HS4, HS5, HS6, HS7, HS8: array[0..1] of Extended;
begin
CT1[0] := 3427197; CT1[1] := 18;//body
HS1[0] := 0.25; HS1[1] := 0.75;//body
CT2[0] := 2637130; CT2[1] := 8;//legs
HS2[0] := 0.27; HS2[1] := 1.37;//legs
CT3[0] := 2313556; CT3[1] := 13;//feet
HS3[0] := 0.19; HS3[1] := 1.08;//feet
CT4[0] := 3233380; CT4[1] := 14;//wall
HS4[0] := 0.04; HS4[1] := 0.50;//wall
CT5[0] := 3377517; CT5[1] := 13;//greenwall
HS5[0] := 0.03; HS5[1] := 0.68;//greenwall
CT6[0] := 2503482; CT6[1] := 15;//switch
HS6[0] := 0.21; HS6[1] := 0.20;//switch
CT7[0] := 855310; CT7[1] := 1;//switchblack
HS7[0] := 16.67; HS7[1] := 3.71;//switchblack
CT8[0] := 725785; CT8[1] := 2;//tile
HS8[0] := 0.36; HS8[1] := 1.53;//tile

RemoveColorTPA(SB, TPA, CT1[0], CT1[1], HS1[0], HS1[1]);
RemoveColorTPA(SB, TPA, CT2[0], CT2[1], HS2[0], HS2[1]);
RemoveColorTPA(SB, TPA, CT3[0], CT3[1], HS3[0], HS3[1]);
RemoveColorTPA(SB, TPA, CT4[0], CT4[1], HS4[0], HS4[1]);
RemoveColorTPA(SB, TPA, CT5[0], CT5[1], HS5[0], HS5[1]);
RemoveColorTPA(SB, TPA, CT6[0], CT6[1], HS6[0], HS6[1]);
RemoveColorTPA(SB, TPA, CT7[0], CT7[1], HS7[0], HS7[1]);
RemoveColorTPA(SB, TPA, CT8[0], CT8[1], HS8[0], HS8[1]);
end;

function FindDrop(var P: TPoint; var UT: String): Boolean;
var
SB: TBox;
PP: TPoint;
FTPA, TTPA: TPointArray;
ATPA: T2DPointArray;
HM, SM: Extended;
i, Hi, CTS: Integer;
begin
Result := False;
if not LoggedIn then Exit;
if not rs_OnMinimap(P.x, P.y) then Exit;
SB := GetSBox(P);
PP := MMMS(P);
P := Point(-1, -1);
GetColorspeed2Modifiers(HM, SM);
CTS := GetColorToleranceSpeed;

//get floor in area
SetColorspeed2Modifiers(0.05, 0.36);
ColorToleranceSpeed(2);
if not FindColorsTolerance(FTPA, 5468278, SB.X1, SB.Y1, SB.X2, SB.Y2, 14) then
begin
SetColorspeed2Modifiers(HM, SM);
ColorToleranceSpeed(CTS);
Exit;
end;

//get floor bounds and tpa
SB := GetTPABounds(FTPA);
if Debug then SMART_DrawBoxEx(True, SB, clPurple);
TTPA := TPAFromBox(SB);

//remove roach/floor colors from tpa
TTPA := ClearTPAFromTPA(TTPA, FTPA);
TTPA := ClearTPAFromTPA(TTPA, TPAFromBox(IntToBox(243, 143, 275, 182)));
if m_HPBar then
TTPA := ClearTPAFromTPA(TTPA, TPAFromBox(IntToBox(227, 121, 293, 149)));
RemoveBadColors(SB, TTPA);
SetColorspeed2Modifiers(HM, SM);
ColorToleranceSpeed(CTS);

//split tpa by 1
ATPA := SplitTPA(TTPA, 1);
Hi := High(ATPA);
if Hi < 0 then Exit;

//sort arrays
SortATPASize(ATPA, True);
for i := 0 to Hi do
begin
if Debug then
begin
SMART_DrawDotsEx(False, ATPA[i], clYellow);
end;
{if (PixelShift(GetTPABounds(ATPA[i]), 120) > 20) then
begin
m_Debug('Removing Item: PixelShift', False);
Continue;
end;}
if not InRange(Length(ATPA[i]), 10, 430) then
begin
m_Debug('Removing Item: Length', False);
Continue;
end;
P := RPDist(ATPA[i], 3);
MMouse(P.x, P.y, 0, 0);
Wait(150);
if WaitText(UT, ['alk here'], 150) then
begin
P := Point(-1, -1);
m_Debug('Removing Item: Uptext', False);
Continue;
end;

if Debug then
begin
SMART_DrawDotsEx(False, ATPA[i], clGreen);
SMART_DrawBoxEx(False, GetTPABounds(ATPA[i]), clBlue);
end;
Break;
end;

Result := PointInBox(P, MSBox);
end;

Narcle

2012-01-23 16:19:15

An update.

(stupid net was out)

Bobzilla69

2012-01-23 16:24:59

Looks extremely good, can't wait to try and use it for somthing

Olly

2012-01-23 17:15:24

This might just make chin scripts near enough flawless to detect your own trap, like if you successfully put one down in 5,5.

Narcle

2012-01-23 17:17:20

From: akonowns
This might just make chin scripts near enough flawless to detect your own trap, like if you successfully put one down in 5,5.


Its one reason I made it. ;)

honeyhoney

2012-01-25 18:04:50

From: ReadySteadyGo
I want to be able to just plug in the values that you get when you type getcamerapos into the developer console. :P


This whole thing is really impressive but I think being able to just plug in the values would make it doubly as impressive :P

This has a lot of applications and I can't wait to see a more polished version of it all.

dweg

2012-01-25 18:14:30

Guise, holy shit, reflection features without reflection?!?

euphemism

2012-01-25 18:35:09

From: dweg
Guise, holy shit, reflection features without reflection?!?


I mean, it's math. So, much cooler than Reflection.

Kyle Undefined

2012-01-25 19:02:47

From: euphemism
I mean, it's math. So, much cooler than Reflection.


Lol'd, this is really good stuff!

Yago

2012-01-25 19:03:17

I'd love if we could get this into the includes somehow.

Narcle

2012-01-25 19:14:36

From: Yago
I'd love if we could get this into the includes somehow.


I plan on adding it to math.simba. Also I'm really debating on using this for our MMtoMS instead (its way more accurate I think).

Function MMtoMS2(MM: TPoint): TPoint;
var
Yh, yMod, X, Y: Extended;
begin
X := MM.x-627.0;
Y := MM.y-85.0;
yMod := 36.0;
Yh := Abs(Y + yMod);
Result.x := Round(263.5 + (X*9.75/(12.8-(Yh/yMod*3.15))) * 9.75);
Result.y := Round(182.0 + Y * (6.3 + ((Yh/yMod)*2.4)));
if not PointInBox(Result, MSBox) then
Result := Point(-1, -1);
end;

Yago

2012-01-25 19:29:22

From: Narcle
I plan on adding it to math.simba. Also I'm really debating on using this for our MMtoMS instead (its way more accurate I think).

Function MMtoMS2(MM: TPoint): TPoint;
var
Yh, yMod, X, Y: Extended;
begin
X := MM.x-627.0;
Y := MM.y-85.0;
yMod := 36.0;
Yh := Abs(Y + yMod);
Result.x := Round(263.5 + (X*9.75/(12.8-(Yh/yMod*3.15))) * 9.75);
Result.y := Round(182.0 + Y * (6.3 + ((Yh/yMod)*2.4)));
if not PointInBox(Result, MSBox) then
Result := Point(-1, -1);
end;


Thank-you. I personally like the looks of the Grid16. But we would need someway to get the tile area.

Narcle

2012-01-25 19:35:38

From: Yago
Thank-you. I personally like the looks of the Grid16. But we would need someway to get the tile area.


Like this?


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 GetAbstractGridBoxCords(Grid: TPoint): TPointArray;//Length = 4 always
var
T: TPoint;
i: integer;
begin
T := Point(Grid.x*4, Grid.y*4);
Result := [GridCoords16(Point(T.x-2, T.y-2)), GridCoords16(Point(T.x+1, T.y-2)),
GridCoords16(Point(T.x+1, T.y+1)), GridCoords16(Point(T.x-2, T.y+1))];
for i := 0 to 3 do
if Result[i].x = -1 then
begin
Result := [Point(-1,-1), Point(-1,-1), Point(-1,-1), Point(-1,-1)];
Exit;
end;
end;


Function GetGridPos(PT: TPoint): TPoint;
var
x, y: integer;
TPA: TPointArray;
begin
Result := Point(-100, -100); //fail point
for x := -8 to 8 do
for y := -8 to 5 do
begin
TPA := GetAbstractGridBoxCords(Point(x,y));
if TPA[0].x = -1 then
Continue;
if InAbstractBox(TPA[0].x, TPA[0].y, TPA[1].x, TPA[1].y, TPA[2].x, TPA[2].y, TPA[3].x, TPA[3].y, PT.x, PT.y) then
begin
Result := Point(x, y);
Exit;
end;
end;
end;

Still working on it, like adding Height or just using X/Y mods.

Kasi

2012-01-25 19:39:49

From: Narcle
I plan on adding it to math.simba. Also I'm really debating on using this for our MMtoMS instead (its way more accurate I think).


Seems more accurate, works better on opening doors then the old one. Good Job :D

Coh3n

2012-01-26 13:16:09

Narcle, I wrote these while rewriting the randoms. Very useful for just creating a standard grid for the inventory, or bank, for example. I'll be using it to create boxes to check for items in Mordaut and Quiz, probably some others as well (and it can probably be used for inventory/bank, for later versions of SRL).

I was probably going to add them to math.simba, so if you want to add them when you add yours, feel free. :)

(*
GridBox
~~~~~~~

.. code-block:: pascal

function GridBox(slot, columns, rows, w, h, diffX, diffY: integer; startPoint: TPoint): TBox;

Returns a TBox of the slot 'slot' in a grid created by the other parameters.
Slots start with 1 being the top left of the grid, and counting accross.
* columns: number of columns in the grid
* rows: number of rows in the grid
* w: the width of each box in the grid
* h: the height of each box in the grid
* diffX: pixels from center to center (x)
* diffY: pixels from center to center (y)
* startPoint: the center point of the top left box in the grid

.. note::

Author: Coh3n
Last Modified: Jan. 25th, 2012 by Coh3n

Example:

.. code-block:: pascal

Result := GridBox(Slot, 4, 2, 95, 80, 0, 150, Point(110, 100));
*)
function GridBox(slot, columns, rows, w, h, diffX, diffY: integer; startPoint: TPoint): TBox;
begin
if (slot > (columns * rows)) then
begin
writeln('GridBox: Invalid slot: '+toStr(slot));
exit;
end;

result.x1 := (startPoint.x + (((slot - 1) mod columns) * diffX) - (w / 2));
result.y1 := (startPoint.y + (((slot - 1) div columns) * diffY) - (h / 2));
result.x2 := (result.x1 + w);
result.y2 := (result.y1 + h);
end;

(*
Grid
~~~~

.. code-block:: pascal

function Grid(columns, rows, w, h, diffX, diffY: integer; startPoint: TPoint): TBoxArray;

Returns a grid of TBoxes (see GridBox for parameters).

.. note::

Author: Coh3n
Last Modified: Jan. 25th, 2012 by Coh3n

Example:

.. code-block:: pascal

SMART_DrawBoxes(false, Grid(5, 10, 20, 20, 25, 25, point(30, 30)), clYellow);
*)
function Grid(columns, rows, w, h, diffX, diffY: integer; startPoint: TPoint): TBoxArray;
var
i: integer;
begin
setLength(result, (columns * rows));

for i := 0 to high(result) do
result[i] := GridBox(i + 1, columns, rows, w, h, diffX, diffY, startPoint);
end;
Used like:

(**
* Author: Coh3n
* Description: Returns a TBox of the small puzzle item slot 'Slot'. Top right
* is slot 1, botton right is slot 8.
*)
function MD_SmallBox(Slot: Integer): TBox;
begin
Result := GridBox(Slot, 4, 2, 95, 80, 95, 150, Point(110, 100));
end;
Doesn't really have much to do with this thread, other than they're a different kind of grid function. You can test by calling

SMART_DrawBoxesEx(false, Grid(4, 2, 95, 80, 95, 150, Point(110, 100)), clGreen);

Yago

2012-01-29 19:28:42

I was facing north at highest angle.

Now i ran the grid 16 box code to draw all the tiles, and I noticed that the lower left tiles on screen are bit(maybe more) off

Narcle

2012-01-29 19:34:22

From: Yago
I was facing north at highest angle.

Now i ran the grid 16 box code to draw all the tiles, and I noticed that the lower left tiles on screen are bit(maybe more) off


The height of the tiles will mess it up even if they're flat.

Yago

2012-01-29 20:29:26

From: Narcle
The height of the tiles will mess it up even if they're flat.


OK I get it.

Kasi

2012-01-29 20:30:36

Seeing as, would this work for random's like evil twin? considering the Camera move's out from a fixed point?

nokkasiili

2012-03-11 04:45:07

From: pur3b100d
Seeing as, would this work for random's like evil twin? considering the Camera move's out from a fixed point?


No, because minimap is blacked out ;)

Coh3n

2012-03-12 00:46:26

From: nokkasiili
No, because minimap is blacked out ;)
Shouldn't make a difference unless you're looking for a color on the minimap, then calling MMToMS.

Zota

2012-03-22 06:34:57

Is this still alive? Looked very promising!

Luke

Coh3n

2012-03-22 11:44:13

It's already been added to SRL.

Press Play

2013-02-19 06:14:54

I'm playing around with these functions at the moment, and it seems as though it only works when you are fully zoomed in (in RS visual settings). I thought that it was standard to have it zoomed all the way out? I would try and fix it, but I have no idea of the maths involved! So yeah - just wanted to give you guys the heads up on this, and if anyone knows the maths for how to make it compatible with the zoomed out.

Also, the boxes left-hand side are weird, and some boxes are incomplete :/ I've had a look at the code, and it seems all good - Narcle is pretty beast… I wanted to use those boxes to search in and stuff :(

I'm using this:
program new;
{$DEFINE SMART8}
{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/SmartGraphics.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
SRL_SixHourFix := True;
Smart_FixSpeed := True;
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);
if not PointInBox(T, MSBox) then
Continue;
SMART_DrawDotsEx(false, [T], clRed);
SMART_DrawBoxEx(False, False, IntToBox(T.x-2, T.y-2, T.x+2, T.y+2), clYellow);
SMART_DrawBoxEx(False, False, IntToBox(T.x-10, T.y-30, T.x+10, T.y+10), clBlue);
end;
end.


Olly

2013-02-19 14:07:30

@-daazndagger-

Yeah this is the main problem, MMtoMS functions were designed back when that was the zoom setting, but semi recently jagex released custom zoom-able and for obvious reasons the furthest zoom is the best/most used. Im sure its an easy fix if you created it (hey @Narcle :p) or if you understand the math, must be something like adding more tiles or something.