SRL Archive - Help and Support

MS to MM?


Special Ed

2007-04-07 12:07:37

Ok what I am trying to accomplish is to be able to use the minimap to find things on the mainscreen, i.e. finds the little tree thing on the minimap and can find it on the mainscreen if you are close enough to it.

I've gotten it to work once really good but then after that It doesn't always work, sometimes on and off it does but not a lot.

What I need help with is for you guys to help me find the ratios from the minimap to the mainscreen so like the top left corner of the mainscreen is where compared to the…. wait I think I may have just figured it out.

EDIT: ZOMG I did it!! the measurements of the view of the mainscreen to the MM are off a little bit but i got the ratios right. Oh this is sweet…

Anyways, if someone wants to try and find a "flat" piece of ground in rs and try to find out where the top of the mainscreen is on the minimap and the bottom ect. that would be cool.

Oh and here's my coding if anyone wants to critique it or maybe give me some input, its not perfect but i still got it to work.

P.S. If somone could try and help me make a DTM or Bitmap that works for all trees on the minimap that would be awsome. *mine kinda work*

program New;
{.include SRL/SRL.scar}
var DTMPlayer,DTMItem,DTMCreature,SearchMod,Ptx,Pty:integer;
DTMTree,DTMTree2,XX,YY,MX,MY,MSTX,MSTY,MSMX1,MSMY1,MSMX2,MSMY2:integer;
begin
SetupSRL;
Wait(500);
MakeCompass('N');
DTMTree := DTMFromString('78DA637463606070614001E11A0C0C42409A1' +
'188FF0301A33BA61A3F135E066EA81A100000F79F0641');
DTMTree2 := DTMFromString('78DA638C63606030664001EAEE9C609A11CA6' +
'78C0512A6A86AFC051818B890D5C461AA7193E140510300BD1D03' +
'11');
MSMX1:= 614;
MSMY1:= 57;
MSMX2:= 682;
MSMY2:= 103;
begin
SearchMod:= 15;
if(not(FindDTM(DTMTree,x,y, MSMX1, MSMY1, MSMX2, MSMY2))and(not(FindDTM(DTMTree2,x,y, MSMX1, MSMY1, MSMX2, MSMY2))))then
begin
if(not(FindDTM(DTMTree,x,y, MMCX - SearchMod, MMCY - SearchMod, MMCX + SearchMod, MMCY + SearchMod))and(not(FindDTM(DTMTree2,x,y, MMCX - SearchMod, MMCY - SearchMod, MMCX + SearchMod, MMCY + SearchMod))))then
begin
repeat
Writeln('Tree Not Found');
SearchMod:= (SearchMod + 1);
until(FindDTM(DTMTree,x,y, MMCX - SearchMod, MMCY - SearchMod, MMCX + SearchMod, MMCY + SearchMod) or (FindDTM(DTMTree2,x,y, MMCX - SearchMod, MMCY - SearchMod, MMCX + SearchMod, MMCY + SearchMod)) or (SearchMod >= 72));
end;
if(FindDTM(DTMTree,MX,MY, MMCX - SearchMod, MMCY - SearchMod, MMCX + SearchMod, MMCY + SearchMod) or (FindDTM(DTMTree2,MX,MY, MMCX - SearchMod, MMCY - SearchMod, MMCX + SearchMod, MMCY + SearchMod)))then
begin
Mouse(MX,MY,2,2,true);
Wait(500);
Writeln('Found Tree In Minimap');
Flag;
Wait(500);
end;
end;
if(FindDTM(DTMTree,MSTX,MSTY, MSMX1, MSMY1, MSMX2, MSMY2) or (FindDTM(DTMTree2,MSTX,MSTY, MSMX1, MSMY1, MSMX2, MSMY2)))then
begin
Writeln('Found Tree In MainScreen');
XX:= Trunc(MSTX - MSMX1);
Writeln('MSTX: ' + inttostr(MSTX));
YY:= Trunc(MSTY - MSMY1);
Writeln('MSTY: ' + inttostr(MSTY));
Ptx:= Trunc(XX * 7.5);
Writeln('Ptx: ' + inttostr(Ptx));
Pty:= Trunc(YY * 7.25);
Writeln('Pty: ' + inttostr(Pty));
MMouse(MSX1 + Ptx,MSY1 + Pty,2,2);
Wait(1000);
end;
Wait(100);
end;
end.

Junior

2007-04-07 12:38:22

Wow, I was trying to do this same thing the other day. I havent gotten far with it. What I have done was find what the corners of the main screen are on the mini map, and then split the square that was on the mini map into 4 quadrants. After I did this, I was trying to find a formula to use for each quadrant, but im not really good with math so I stopped it there. Ill post up what I have done soon, im on my laptop now. This would be a really cool function if completed.

Special Ed

2007-04-07 12:41:27

Well if you wanted to do it like radialwalking with quadrants I have something here for you.

This was part of my script to make a radialwalk.

You could make it so that the center of the minimap is like the center of the mainscreen and have it do something similar to radialwalking but on the mainscreen instead of the minimap.

EDIT: Also if you want to work together on this I think we can make it work really well.

//Modded from SRL/SRL/core/math.scar "ArcTan2"
function SpecialArcTan(y,x:Extended):Extended;
begin
if(y = MMCY) and (x < MMCX) then Result := Radians(180.0);
if(y = MMCY) and (x > MMCX) then Result := Radians(0.0);
if(x = MMCX) and (y < MMCY) then Result := Radians(270.0);
if(x = MMCX) and (y > MMCY) then Result := Radians(90.0);
if(Result = 0.0) and (x <> MMCX) then
if(x = 0) then
begin
x:= 1;
end;
if(Abs(y) / Abs(x) = 1.0) then
begin
if(y > MMCY) and (x > MMCX) then Result := Radians(45.0);
if(y > MMCY) and (x < MMCX) then Result := Radians(135.0);
if(y < MMCY) and (x < MMCX) then Result := Radians(225.0);
if(y < MMCY) and (x > MMCX) then Result := Radians(315.0);
end;
if Result = 0 then
begin
Result := ArcTan(Abs(-y) div Abs(x));
if(y > MMCY) and (x < MMCX) then Result := Result + Radians(90.0);
if(y < MMCY) and (x < MMCX) then Result := Result + Radians(180.0);
if(y < MMCY) and (x > MMCX) then Result := Result + Radians(270.0);
end;
end;

function FlagIn_Quadrant:integer;
var MPX,MPY:integer;
begin
FindColor(MPX,MPY,255,MMX1,MMY1,MMX2,MMY2);
begin
if(((648 < MPX)and(MPX < 735))and((5 < MPY) and(MPY < 86))) then Result:= 1; // 1 - 89 Degrees
if(((570 < MPX)and(MPX < 648))and((5 < MPY) and(MPY < 86))) then Result:= 2; // 91 - 179 Degrees
if(((570 < MPX)and(MPX < 648))and((86 < MPY)and(MPY < 166))) then Result:= 3; // 181 - 269 Degrees
if(((648 < MPX)and(MPX < 735))and((86 < MPY)and(MPY < 166))) then Result:= 4; // 271 - 359 Degrees
if((MPX = 648)and(5 < MPY) and(MPY < 86)) then Result:= 5; // 0 & 360 Degrees
if((MPY = 86) and(570 < MPX)and(MPX < 648)) then Result:= 6; // 270 Degrees
if((MPY = 86) and(648 < MPX)and(MPX < 735)) then Result:= 7; // 90 Degrees
if((MPX = 648)and(86 < MPY) and(MPY < 166)) then Result:= 8; // 180 Degrees
end;
end;

function StartRadialDegrees:extended;
var RadX,RadY,AngleInRadians,AngleInDegrees:Extended;
MPX,MPY:integer;
begin
if(not(FlagPresent))then Exit;
if(FlagPresent)then
begin
GetMousePos(MPX,MPY);
RadX:= (MMCX - MPX);
RadY:= (MMCY - MPY);
AngleInRadians:= (Abs((SpecialArcTan(MMCY + 72,MMCX) - SpecialArcTan(RadY,RadX))));
AngleInDegrees:= ((AngleInRadians * 180) / Pi);
if(FlagIn_Quadrant = 1)then result:= (180 - AngleInDegrees);
if(FlagIn_Quadrant = 2)then result:= (180 + AngleInDegrees);
if(FlagIn_Quadrant = 3)then result:= ((180 - AngleInDegrees) + 180);
if(FlagIn_Quadrant = 4)then result:= (AngleInDegrees);
if(FlagIn_Quadrant = 5)then result:= 0;
if(FlagIn_Quadrant = 6)then result:= 270;
if(FlagIn_Quadrant = 7)then result:= 90;
if(FlagIn_Quadrant = 8)then result:= 180;
end;
end;

function EndRadialDegrees:extended;
var RadX,RadY,AngleInRadians,AngleInDegrees:Extended;
MPX,MPY,FIQ:integer;
begin
if(not(FlagPresent))then Exit;
begin
repeat
if(FlagIn_Quadrant = 1)then FIQ:= 1;
if(FlagIn_Quadrant = 2)then FIQ:= 2;
if(FlagIn_Quadrant = 3)then FIQ:= 3;
if(FlagIn_Quadrant = 4)then FIQ:= 4;
if(FlagIn_Quadrant = 5)then FIQ:= 5;
if(FlagIn_Quadrant = 6)then FIQ:= 6;
if(FlagIn_Quadrant = 7)then FIQ:= 7;
if(FlagIn_Quadrant = 8)then FIQ:= 8;
Wait(100);
until(not(FlagPresent));
end;
RadX:= (MMCX - MPX);
RadY:= (MMCY - MPY);
AngleInRadians:= (Abs((SpecialArcTan(MMCY + 72,MMCX) - SpecialArcTan(RadY,RadX))));
AngleInDegrees:= ((AngleInRadians * 180) / Pi);
if(FIQ = 1)then result:= (180 - AngleInDegrees);
if(FIQ = 2)then result:= (180 + AngleInDegrees);
if(FIQ = 3)then result:= ((180 - AngleInDegrees) + 180);
if(FIQ = 4)then result:= (AngleInDegrees);
if(FIQ = 5)then result:= 0;
if(FIQ = 6)then result:= 270;
if(FIQ = 7)then result:= 90;
if(FIQ = 8)then result:= 180;
end;

procedure Make_RadialWalk;
var CX,CY,Color,MouseRand,Dist,SR,ER:integer;
begin
if((not(FlagPresent)))then Exit;
if(FlagPresent)then
begin
FindColor(CX,CY,255,MMX1,MMY1,MMX2,MMY2);
Color:= GetColor(CX + 2,CY);
SR:= Trunc(StartRadialDegrees);
ER:= Trunc(EndRadialDegrees);
Dist:= Distance(MMCX,MMCY,CX,CY);
MouseRand:= (Random(3) + 1);
Writeln('RadialWalk(' + inttostr(Color) + ',' + inttostr(SR) + ',' + inttostr(ER) + ',' + inttostr(Dist) + ',' + inttostr(MouseRand) + ',' + inttostr(MouseRand) + ');');
end;
end;