SRL Archive - SRL Archives

Some New/Modified functions.


danrox2004

2007-02-01 07:05:08

ContinueFunc

Clicks Continue until the continues dissapear.. Made by Danrox2004
function ContinueFunc(): boolean;begin
if (ClickToContinue) then
begin
result:=true
repeat
wait(1000 + random(1000));
until (not ClickToContinue)
end else
Result := false;
end;

Check4Head

Checks for a color in the left of the chat box suggesting the face of an npc might be there which means you are talking to an NPC. Made by Danrox2004
function Check4Head(color: integer): boolean;
begin
Result:=FindColorTolerance(x, y, color, MCX1, MCY1, MCX2, MCY2, 15)
end;

TalkToNPC

Function used alot in my tutorial island script. Description below. Made by Danrox2004.
function TalkToNPC(Color: integer; Head: integer): boolean;
begin
Time := 0;
MarkTime(Time);
repeat
repeat
SendArrowSilentWait(1, 1000 + random(1000));
wait(500 + random(1000));
if (TimeFromMark(Time) > (60000)) then
break;
until (FindObjMultiText(x, y, 'Talk-to', 'Talk', '-to', Color, 15))
if (TimeFromMark(Time) > (60000)) then
NextChar;
mouse(x, y, 10, 10, true);
Flag;
wait(1000 + random(1000));
until (Check4Head(Head))
ContinueFunc;
Result := true;
end;

This is a function I used alot during my Tutorial Island Script.

It is very useful because it is fairly fast. It finds NPC's based on a color and clicks on it if Talk is in the top left. It then checks that it is talking to the NPC by checking for a specific color in the text window, where the NPC's face should be. It then Clicks to continue until Click to continue disappears.

If it doesn't find Talk-to in the top left or cannot find the face of the NPC in the chat box then it looks again for the NPC, for up to 60 seconds. If it cannot find it it returns false.

I have only tested this on tutorial island and it works very well.


I had some free time and decided to modify some procedures which searched for more then one thing and make them arrays so they search for as many things as they want.

None of these have been tested :( sorry

Thanks for xxKanexx for showing how to do arrays in functions.

FindBitmapsProgressiveTol

Credits go to Stupid3000 for origional function.
{*******************************************************************************
function FindBitmapsProgressiveTol(Bmp: array of Integer;tolmax, step, xs, ys, xe, ye: Integer): Boolean;
By: Stupid3000
Description: Finds any of maximum 5 bitmaps in box specified by xs,ys,xe,ye.
If you only need to find one bitmap, fill in 0 for others.
*******************************************************************************}
function FindBitmapsProgressiveTol(Bmp: array of Integer; tolmax, step, xs, ys, xe, ye: Integer): Boolean;
var //by Stupid3ooo
c, i: Integer;
begin
for i:= 0 to GetarrayLength(Bmp)-1 do
begin
while (c < tolmax) do
begin
c := c + step;
if (Bmp[i] > 0) then
begin
if (FindBitmapSpiralTolerance (Bmp[i], x, y, xs, ys, xe, ye, c)) then
begin
Result := True;
break;
end;
end;
end
end;
end;


DropMulti

{*******************************************************************************
procedure DropMulti(I: Array of Integer);
By: Danrox2004
Description: Drops all except item(s) specified by inventory number(s).
*******************************************************************************}
procedure DropMulti(a: array of Integer);
var
InvSpot, i: integer;
begin
for InvSpot := 1 to 28 do
begin
for i:= 0 to GetarrayLength(a)-1 do
begin
if(InvSpot = a[i]) then
If(ItemExists(InvSpot) then DropItem(InvSpot)
end
end
end;

Ron

2007-02-05 18:06:55

Nice work! :)

Hey by the way, you can shorten some of your functions. I'm not sure if it makes a difference in speed, but it makes a difference in lines.

Code such as this:

if(FindDan)then
begin
PokeDan;
end else
begin
KeepLooking;
end;

Can be shortened to this:

if(FindDan)then
PokeDan
else
KeepLooking;

This type of thing only works when there is only 1 statement. Notice the first statement "PokeDan" does not end in a comma. You have to do that for the first one if you're going to exclude the begin and end and only if it's 1 line being executed. You couldn't do this.

if(FindDan)then
PokeDan;
PokeAgain
else
KeepLooking;
EatASnack;

Hope that helps. :D Again, nice work. Did the devs add your function?

~Ron

danrox2004

2007-02-06 02:05:33

Ah thanks Ron, I'll keep that in mind. I dont think the devs did add this, i don't think its what the devs are looking for

Ron

2007-02-06 17:08:13

Oh that's too bad. :(

Hey danrox! You didn't listen to me. :p


function Check4Head(color: integer): boolean;
begin
if (FindColorTolerance(x, y, color, MCX1, MCY1, MCX2, MCY2, 15)) then
Result := true;
else
Result := false;
end;

should be this:

function Check4Head(color: integer): boolean;
begin
if (FindColorTolerance(x, y, color, MCX1, MCY1, MCX2, MCY2, 15)) then
Result := true
else
Result := false;
end;

lol. The statement right before the else can not have a semicolon after it, or it errors out. Just wanted to point that out if you ever put this in your future scripts. :D

bullzeye95

2007-02-06 17:42:40

Or it could just be
function Check4Head(color: integer): boolean;
begin
Result:= FindColorTolerance(x, y, color, MCX1, MCY1, MCX2, MCY2, 15);
end;
:p

danrox2004

2007-02-07 05:53:36

From: Ron
Oh that's too bad. :(

Hey danrox! You didn't listen to me. :p


function Check4Head(color: integer): boolean;
begin
if (FindColorTolerance(x, y, color, MCX1, MCY1, MCX2, MCY2, 15)) then
Result := true;
else
Result := false;
end;

should be this:

function Check4Head(color: integer): boolean;
begin
if (FindColorTolerance(x, y, color, MCX1, MCY1, MCX2, MCY2, 15)) then
Result := true
else
Result := false;
end;

lol. The statement right before the else can not have a semicolon after it, or it errors out. Just wanted to point that out if you ever put this in your future scripts. :D


Oops.. Sorry Ron. Will go with Bullzeye's tho because its shorter :P

Ron

2007-02-07 14:43:31

Ooooo nice one bullzeye, I didn't realize it returned a boolean. I was concentrating more on the ifs lol. :D

Hey whatever is better man. Don't appologize. :p