SRL Archive - OSR Help

Leaving out an area to search in // Finding different monsters


J J

2012-03-18 14:51:52

Hi.

I'm working on a combat script and I'm currently trying to figure out what would be the best way to locate a second monster. The monsters I'm fighting have a quite annoying death animation. I can save around 5 seconds by not waiting for the animation.

However, when I loop my script the first monster it will attack is the monster it's fighting that's in the death animation. So I figured I could search for a specific area but leaving out an area like this:


Leaving out the white area.

What's the best way to do this? I was thinking about these ways:

Option #1
(0, 250, 515, 337) = Bottom area
(0, 0, 515, 90) = Top area
(0, 0, 150, 337) = Left area
(380, 0, 515, 90) = Right area

This would leave the white part out but search in 4 different parts.

FindColorSpiralTolerance(X, Y, {monster color} , a, b, c, d, {tolerance});
–>
if FindColorSpiralTolerance(X, Y, {monster color} , 0, 250, 515, 337, {tolerance}) or FindColorSpiralTolerance(X, Y, {monster color} , 0, 0, 515, 90, {tolerance}) or FindColorSpiralTolerance(X, Y, {monster color} , 0, 0, 150, 337, {tolerance}) or FindColorSpiralTolerance(X, Y, {monster color}, 380, 0, 515, 90, {tolerance}) then


Option #2
Doing something with MSX1, MSY1, MSX2, MSY1 and leaving out a box with the co-ords of the white part. Not sure if this is possible




Any tips?

Er1k

2012-03-19 02:46:58

If this is melee, then an easy way is to process the distance from MSCX and MSCY. Filter if it is in melee distance.

But this is a very makeshift hack and won't work for range/mage or other strange things.

Nebula

2012-03-19 11:15:58

Use RemoveDistTPointArray.

From: Naum
RemoveDistTPointArray

[php]{*******************************************************************************
function RemoveDistTPointArray(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
Description: Removes the points that are inside or outside the distance Dist
from the point (x, y) from the TPointArray ThePoints.
*******************************************************************************}
[/php]

RemoveDistTPointArray, will make a circle of radius 'Dist' with it's center points being situated at cordinates 'x' and 'y'. The 'RemoveHigher' parameter of data type Boolean will remove points inside or outside of the circle.

RemoveHigher is True - Points removed outside the circle of radius 'Dist', points are kept within circle of radius 'Dist'

RemoveHigher is False - Points are kept outside the circle of radius 'Dist', points are removed within circle of radius 'Dist'.

Remember that this is a function so a data type of TPointArray must be assigned to it. It can be used as such:

program New;
{.Include SRL/SRL.Scar}
{.include srl/srl/misc/debug.scar}
Var x, y : Integer;
tpa : array of tpoint;
Begin
SetupSRL;
FindColorsTolerance(TPA, 7048347, msx1, msy1, msx2, msy2, 10);
MiddleTPAEx(TPA, x, y);
TPA := RemoveDistTPointArray(x, y, 20, TPA, true); // here
DebugTPA(tpa, '');
End.

What that script will do is find occurances of the color '7048347' in the mainscreen of runescape and find the middle of all those points. It then makes a circle of radius 20 (Dist) around the cordinates x and y of the TPointArray 'TPA'. The last parameter is true, so it will remove the points within the circle, and leave the ones outside of the circle untouched.

More will be explained in due time, in the next section.

Er1k

2012-03-20 03:27:43

From: Nebula
Use RemoveDistTPointArray.



He isn't really using tpa, but he should.

I think the tpa solution should filter out the area in search or the colors. Tha should be quite easy because I think wizzy plugin has a few functions for that

greent

2012-03-21 18:28:27

This should sort through a ATPA and return the closest middle point that isn't in the defined box. Its messy just made it quite quickly but the logic behind it should work.


function PointInTBox(TBox:TBox;TPoint:TPoint):Boolean;

var
x,y:Integer;
begin
x:=TPoint.x;
y:=Tpoint.y;
if((x>TBox.X1)and (x<TBox.X2) and (y>TBox.Y1) and (y>TBox.Y2)) then
Result:= True;
end;

function GetClosestPointIgnoreBox(TBox:TBox;ATPA :Array of TPointArray): TPoint;

var
I:Integer;
Dist,TDist:Extended;
Best,Temp:TPoint;

begin
for I:=0 to High(ATPA) do
begin
Temp:=MiddleTPA(ATPA[I]);
if(PointInTBox(TBox,Temp))then
Continue;
TDist := Sqr(pow(Temp.x-MSCX,2)+pow(Temp.y-MSCY,2));
if(Best.x=0) then
begin
Best:=Temp;
Dist:=TDist;
end
else if (TDist<Dist) then
begin
Best:=Temp;
Dist:=TDist;
end
end;
Result:=Best;
end;