SRL Archive - Test corner

My 'Trig' Functions


Hobbit

2007-10-20 02:12:37

I call it trig cause it's triangles even though it doesn't actually use trig. But anyway I made these awhile ago and they've just kinda sat on my computer since. One I get some more actul time I'll be adding in some failsafes and stuff. But this is it for now..

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » Trig Walking --//
//-----------------------------------------------------------------//
program Trigwalk;
{.include SRL/SRL.scar}
{*******************************************************************************
Procedure TWalk(symbol1, symbol2, symbol3:integer; Debug:Boolean);
by: Hobbit
Decription: Uses Triangles made with mm symbols to walk
*******************************************************************************}
procedure TWalk(symbol1, symbol2, symbol3:integer; Debug:Boolean);
var
xa,xb,xc,ya,yb,yc : integer;
ra,rb : extended;
begin
FindBitmap(symbol1,xa,ya);
if(Debug=True)then
begin
Writeln('Found reference 1');
end;
FindBitmap(symbol2,xb,yb);
if(Debug=True)then
begin
Writeln('Found reference 2');
end;
FindBitmap(symbol3,xc,yc);
if(Debug=True)then
begin
Writeln('Found reference 3');
end;
ra:=(xa+xb+xc)/3;
rb:=(ya+yb+yc)/3;
x:=Round(ra);
y:=Round(rb);
Mouse(x,y,0,0,True);
if(Debug=True)then
begin
Writeln('Clicked Minimap');
end;
end;

{*******************************************************************************
Procedure TRef(symbol1, symbol2, symbol3:integer; NextPlayer:Boolean);
by: Hobbit
Decription: Uses Triangles made with mm symbols to check positions
Boolean: True - If reference symbols not found it switches to the next
player.
False - If reference symbols not found it leave current player
logged in.
*******************************************************************************}
procedure TRef(symbol1, symbol2, symbol3:integer; NextPlayer:Boolean);
var
xa,xb,xc,ya,yb,yc,c : integer;
ra,rb : extended;
begin
FindBitmap(symbol1,xa,ya);
FindBitmap(symbol2,xb,yb);
FindBitmap(symbol3,xc,yc);
if(not(FindBitmap(symbol1,xa,ya)))then
begin
if(NextPlayer=True)then
begin
NextPlayer(False);
end;
if(NextPlayer=False)then
Exit;
end;
if(not(FindBitmap(symbol2,xb,yb)))then
begin
if(NextPlayer=True)then
begin
NextPlayer(False);
end;
if(NextPlayer=False)then
Exit;
end;
if(not(FindBitmap(symbol3,xc,yc)))
begin
if(NextPlayer=True)then
begin
NextPlayer(False);
end;
if(NextPlayer=False)then
Exit;
end;
ra:=(xa+xb+xc)/3;
rb:=(ya+yb+yc)/3;
x:=Round(ra);
y:=Round(rb);
c:=GetColor(x,y);
if(c=16777215)then
begin
Writeln('We are where we should be! =)');
Exit;
end;
if(not(c=16777215))then
begin
Mouse(x,y,0,0,True);
Writeln('Moving to where we should be!');
end;
end;

n3ss3s

2007-10-20 03:58:58

Nice, btw you know you can do If(Alive)Then Slap with booleans?

shaunthasheep

2007-10-20 08:30:19

They don't compile, need to add x and y to the first procedure, and change the boolean NextPlayer to a different name, due to NextPlayer(active : boolean) won't work. (Type Mismatch);


//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » Trig Walking --//
//-----------------------------------------------------------------//
program Trigwalk;
{.include SRL/SRL.scar}
{*******************************************************************************
Procedure TWalk(symbol1, symbol2, symbol3 : integer);
by: Hobbit
Decription: Uses Triangles made with mm symbols to walk
*******************************************************************************}
function TWalk(Symbol1, Symbol2, Symbol3 : integer) : boolean;
var
BmpPos : Array[1..3] of TPoint;
Middle : TPoint;
begin
if not FindBitmap(Symbol1, BmpPos[1].x, BmpPos[1].y) then Exit;
if not FindBitmap(Symbol2, BmpPos[2].x, BmpPos[2].y) then Exit;
if not FindBitmap(Symbol3, BmpPos[3].x, BmpPos[3].y) then Exit;
Middle := MiddleTPA(BmpPos);
Mouse(Middle.x, Middle.y, 0, 0, True);
Result := True;
end;

{*******************************************************************************
Procedure TRef(symbol1, symbol2, symbol3:integer; DoNextPlayer:Boolean);
by: Hobbit
Decription: Uses Triangles made with mm symbols to check positions
Boolean: True - If reference symbols not found it switches to the next
player.
False - If reference symbols not found it leave current player
logged in.
*******************************************************************************}
function TRef(Symbol1, Symbol2, Symbol3: integer; DoNextPlayer : boolean) : boolean;
var
i : integer;
BmpPos : Array[1..3] of TPoint;
Middle : TPoint;
Found : boolean;
begin
for i := 1 to 3 do
begin
case i of
1 : Found := FindBitmap(Symbol1, BmpPos[1].x, BmpPos[1].y);
2 : Found := FindBitmap(Symbol2, BmpPos[2].x, BmpPos[2].y);
3 : Found := FindBitmap(Symbol3, BmpPos[3].x, BmpPos[3].y);
end;
if not Found then if DoNextPlayer then NextPlayer(False) else Exit;
end;
Middle := MiddleTPA(BmpPos);
if GetColor(Middle.x, Middle.y) = 16777215 then
Writeln('We are where we should be! =)')
else begin
Mouse(Middle.x, Middle.y, 0, 0, True);
Writeln('Moving to where we should be!');
end;
Result := True;
end;

Meh :p, Monkey Style ^.^

Hobbit

2007-10-20 21:12:49

Lol like I said I made them a long time ago, I hadn't changed for the x and y being removed from SRL.

But what do you think of them..?