SRL Archive - OSR Help

Need help with debugging a function.


Gala

2012-02-24 14:12:59

Hey all.
I just made my own function that counts the players on the minimap. I know there is already one that comes with SRL, but this one works badly for me especially if there is a symbol next to some players.
It works for me, but it seems to click on the compass symbol, so the angle is on 'north'. I tried everything, but I think there is someone who can tell me very quickly what's wrong with the function:

function GetTotalPlayers: Integer;
var
MiddlePosSPS, MiddlePos: TPoint;
PlayersTPA: TPointArray;
PlayerATPA: Array of TPointArray;
begin
if not LoggedIn then Exit;
MiddlePosSPS := Point(4183, 2748);
MiddlePos := SPS_PosToMM(MiddlePosSPS);
if not AtYewsVar then
begin
Result := -1;
end else
begin
CTS := GetColorToleranceSpeed;
if not CTS = 2 then ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.14, 3.32);
if not FindColorsSpiralTolerance(MMCX, MMCY, PlayersTPA, 14927604, MMX1, MMY1, MMX2, MMY2, 20) then
begin
SetColorSpeed2Modifiers(0.01, 2.17);
if not FindColorsSpiralTolerance(MMCX, MMCY, PlayersTPA, 13033957, MMX1, MMY1, MMX2, MMY2, 20) then
begin
SetColorSpeed2Modifiers(0.34, 1.05);
if not FindColorsSpiralTolerance(MMCX, MMCY, PlayersTPA, 14801359, MMX1, MMY1, MMX2, MMY2, 20) then
begin
end;
end;
end;
ColorToleranceSpeed(CTS);
if SPS_PosOnMM(MiddlePosSPS) then
begin
PlayersTPA := RemoveDistTPointArray(MiddlePos.x, MiddlePos.y, 35, PlayersTPA, True);
end;
PlayerATPA := TPAToATPAEx(PlayersTPA, 3, 3);
Result := Length(PlayerATPA);
end;
end;

The number of players (Result := Length(PlayerATPA)) is correct, but it seems to click on the compass and I can't figure out why.
Could someone help me please? :)

Brandon

2012-02-24 14:53:13


if not FindColorsSpiralTolerance(MMCX, MMCY, PlayersTPA, 14927604, MMX1, MMY1, MMX2, MMY2, 20) then //Pink Coloured
begin
SetColorSpeed2Modifiers(0.01, 2.17);
if not FindColorsSpiralTolerance(MMCX, MMCY, PlayersTPA, 13033957, MMX1, MMY1, MMX2, MMY2, 20) then //Cream Coloured
begin
SetColorSpeed2Modifiers(0.34, 1.05);
if not FindColorsSpiralTolerance(MMCX, MMCY, PlayersTPA, 14801359, MMX1, MMY1, MMX2, MMY2, 20) then //Fishing Spot Bubbled Coloured
begin
//What in the world? Why is this even here?
end;
end;
end;

In the above function, are u trying to find the Cream Inside the Pink? Because that's not what your function is doing.. Your searching for pink, but never using it.. then searching for Cream and never using it :S

I guess your just using those to Add to the PlayersTPA.. but I'm not sure that it adds.. I think it actually replaces that whole TPA with the colours found??

Next is that When you use MMX1, MMY1, MMX2, MMY2.. it refers to a box.. Not the minimap itself. It actually encapsulates from the Top Left of compass (included) all the way down to the Bottom Right of the Summoning Symbol (Included)

What your need to do is use:

FilterPointsPie(TPA, 0.0, 360.0, 0.0, 76.0, MMCX, MMCY);

which will give you just the minimap alone.

Gala

2012-02-24 15:28:01

lol cream indside the pink :P
The script just tries all the 3 colors. I am happy if at least one color is found. Then it writes the TPAs into PlayerTPA. I don't care if the next one overwrites them, because those will be the same. (As far as i tested)

I could also do this:
FindColorsSpiralTolerance(MMCX, MMCY, PlayersTPA, 14927604, MMX1, MMY1, MMX2, MMY2, 20);
FindColorsSpiralTolerance(MMCX, MMCY, PlayersTPA, 13033957, MMX1, MMY1, MMX2, MMY2, 20);
FindColorsSpiralTolerance(MMCX, MMCY, PlayersTPA, 14801359, MMX1, MMY1, MMX2, MMY2, 20);

This would be the same or not? Except my version can be faster. (At least a bit)
However, the function gives the correct number of players on the minimap within a given circle.

And isn't
FilterPointsPie(TPA, 0.0, 360.0, 0.0, 76.0, MMCX, MMCY);
similar to
RemoveDistTPointArray(MMCX, MMCY, 76, TPA, True);
?

I just wonder where in this function is something that occurs a click :/

Kyle Undefined

2012-02-24 15:32:05

In your script, look for ClickNorth, that's probably the culprit.

Brandon

2012-02-24 15:32:42

LOL what a dirty mind :/

Uhhh The RemoveDistTpointArray seems to be similar yeah but I haven't used it before. Umm The above function doesn't click anything at all so it's somewhere else in your script. That's for sure.

euphemism

2012-02-24 15:44:23

I am pretty sure SPS sets the compass to north before performing any positioning or walking.

E: SPS_PosToMM wouldn't do that, so never mind. My bad.

Gala

2012-02-24 15:47:30

@Kyle Undefined
nope, this procedure isn't in my script. I didn't even choose even numbers for the compass degrees..

@ggzz
That's not my fault, that is because of the perverted tv shows nowadays :P

Strange, if I remove this function my script works without any problems. :/
Thx for the help, I will try to fix it later.

Edit:
@euphemism
Yea I thought the same as this is the only procedure that could occur a click.

Gala

2012-02-24 17:26:17

//FIXED//

Pheew, I cut the whole script into pieces for nothing :/
I just found the problem:

I use SPS_PoToMM which calls SPS_GetMyPos.
And that includes this:
  // we should just rotate the minimap according to the minimap angle.
ang := round(rs_GetCompassAngleDegrees());
SPS_DebugStr('[SPS] Compass Angle: '+toStr(ang));

if (inRange(ang, 10, 350)) then
{$IFDEF SRL5}
ClickNorth(SRL_ANGLE_HIGH);
{$ELSE}
ClickNorth(True);
{$ENDIF}


So.. ClickNorth, here u are -.-

Thanks @all for help, in the end Kyle was right :D

Hobbit

2012-02-25 20:18:27

Moved to Scripting Help

:)