SRL Archive - SRL Archives

MiniMap To MainScreen


jimmy_mac

2009-12-13 08:41:11

What do you think of this. Converts an x,y location on the minimap to a TPoint x,y location on the main screen.


Function MiniMap2MainScreen(x, y : Integer) : TPoint;
begin
if inRange(x, 602, 652) and inRange(y, 68, 99) then
begin
result.x := round((x - 601) * 10.66666);
result.y := round((y - 67) * 10.77419);
end;
end;

Heres an example:

var
Example:TPoint;
x, y: Integer;
begin
if FindColorTolerence(x, y, 66281, 602, 68, 652, 99, 0) then
Begin
Example := MiniMap2MainScreen(x, y);
SetAngle(True);
Mouse(Example.x, Example.y, 0, 0, true);
Writeln('Found and Clicked.');
end else Writeln('Didnt find the color you were looking for.');
end;
Anyway, let me know what you think. If theres already a function like this, dont flame ;)

noidea

2009-12-13 10:23:03

This is already in srl, but awesome nevertheless.
here
Function MiniMap2MainScreen(x, y : Integer) : TPoint; 
begin
if inRange(x, 602, 652) and inRange(y, 68, 99) then
result := point(round((x - 601) * 10.66666), round((y - 67) * 10.77419));
end;

This is three lines shorter :p

Sir R. M8gic1an

2009-12-13 10:36:13

From: noidea
This is already in srl, but awesome nevertheless.
here
Function MiniMap2MainScreen(x, y : Integer) : TPoint; 
begin
if inRange(x, 602, 652) and inRange(y, 68, 99) then
result := point(round((x - 601) * 10.66666), round((y - 67) * 10.77419));
end;

This is three lines shorter :p


and much more of a pain in the ass to read…
I wonder what is this obsession with short code…

~RM

mixster

2009-12-13 13:02:02

People confuse short with fast of course.

Anyway, on topic, using SRL constants would be nicer rather than hard coded numbers, ie InRange(x, MMX1, MMX2) or, if it's not the whole minimap, InRange(x, MMX1 + 15, MMX2 - 15). Of course, if the first bit is just a check to see it's on the minimap, you could use the rs_OnMinimap(x, y) function.

YoHoJo

2009-12-13 13:19:43

How did he get the EXACT same cords and numbers for his function?….
Also, why not use in CIRCLE?! :D
function InCircle(x, y, mx, my, r: Integer): Boolean;
Returns true if x and y are in or on a circle specified by the midpoints mx, my and the radius r.

jimmy_mac

2009-12-13 18:26:01

From: YoHoJo
How did he get the EXACT same cords and numbers for his function?….
Also, why not use in CIRCLE?! :D


Because I enlarged the minimap in Photoshop, and lined up the minimap with the main screen, because its a rectangle, searching the minimap within a circle wouldn't work.

Example:
I've updated it a bit since the first one up the top, changed the numbers a tiny bit. but its still got the general gist of things.

Anyway whats the function built-in to srl? The only one I could find was a reflection based one, which is MMToMS.

noidea

2009-12-13 18:47:12

From: Rasta Magician
and much more of a pain in the ass to read…
I wonder what is this obsession with short code…

~RM


I personally find it easier to read.

And I don't see how making that code shorter projected that I was attempting to make it faster.. The only speed difference would be point(); as you are referring to another procedure to make the tpoint, instead of directly referring to the var. The speed difference would be nano seconds.

MylesMadness

2009-12-13 18:53:12

From: jimmy_mac
Because I enlarged the minimap in Photoshop, and lined up the minimap with the main screen, because its a rectangle, searching the minimap within a circle wouldn't work.

Example:
*snip*
I've updated it a bit since the first one up the top, changed the numbers a tiny bit. but its still got the general gist of things.

Anyway whats the function built-in to srl? The only one I could find was a reflection based one, which is MMToMS.
Wow, thats a good idea. Can't believe others haven't though about it.

mrpickle

2009-12-13 18:56:48

I do think this function can be added. Like the old one, but different method in getting at the same answer. Sometimes that is all the difference :).

Awkwardsaw

2009-12-13 18:57:35

From: jimmy_mac


Anyway whats the function built-in to srl? The only one I could find was a reflection based one, which is MMToMS.


object.scar, :) i think

Sex

2009-12-13 19:07:33

Wouldn't the coordinates be different if the pitch and yaw and stuff is different of the camera?

jimmy_mac

2009-12-13 19:17:34

From: Sex
Wouldn't the coordinates be different if the pitch and yaw and stuff is different of the camera?


whats pitch and yaw?

could just add: SetAngle(True); to the function.

Baked0420

2009-12-13 19:54:54

From: Rasta Magician
and much more of a pain in the ass to read…
I wonder what is this obsession with short code…

~RM


just take out the begin/end and put the x and y coords in on line, result:= point(x, y); (but with the actual function x and y)

seems the same to me when reading, other then the begin/end the only thing that is different is result:= point();

looks nicer to me the way it is in SRL, no offense to jimmy_mac, your coding is very clear and readable, looks nice, I like both but I just prefer the one in the include already, both seem just as readable.

jimmy_mac

2009-12-13 19:59:45

From: Baked0420
just take out the begin/end and put the x and y coords in on line, result:= point(x, y); (but with the actual function x and y)

seems the same to me when reading, other then the begin/end the only thing that is different is result:= point();

looks nicer to me the way it is in SRL, no offense to jimmy_mac, your coding is very clear and readable, looks nice, I like both but I just prefer the one in the include already, both seem just as readable.


which is the one in the include?
Is this it?..

Function FindObjThroughMM(var x, y: Integer; Kind: String; Colors, Tol: TIntegerArray; UpText: TStringArray; Width, Height: Integer): boolean; // * By N1ke!

It seems quite a lot more complex than the one im suggesting. though I havn't used that function before.

Baked0420

2009-12-13 21:23:02

noidea posted it, it's called Function MiniMap2MainScreen(x, y : Integer) : TPoint;

awkwardsaw said he thinks it's in object.scar.

lol do you even read your own thread? hahaa :p

noidea

2009-12-13 21:29:42

From: Baked0420
noidea posted it, it's called Function MiniMap2MainScreen(x, y : Integer) : TPoint;

awkwardsaw said he thinks it's in object.scar.

lol do you even read your own thread? hahaa :p


No, that was his function. I just made it "unread-ably" short

marpis

2009-12-14 09:09:00

It's in /core/math.scar}

{*******************************************************************************
Function MMToMS(MM: TPoint): TPoint;
By: N1ke!
Description: Turns a Minimap point into a close MS point.
*******************************************************************************}
Function MMToMS(MM: TPoint): TPoint;
It's not reflection based.

Boreas

2009-12-14 14:57:36

One in reflection include takes height of object from the ground, and camera angle into account.