SRL Archive - SRL Archives

Smithing.scar


n3ss3s

2008-05-01 14:37:30

It has always contained only furnace opening functions, and Smithing is a lot larger area than just opening a furnace, so to begin, I suggest the three OpenFurnaces of Smithing.scar will be replaced with a finder function, so the scripter can use that one straight if he doesn't necassarily want to yet open the furnace or then do it with his own way. There is no need for a ready furnace opener because anyone can easily make an opener using the finder.


{*******************************************************************************
Function FindFurnace(Var X, Y: Integer): Boolean;
By: n3ss3s
Description: Finds a furnace and stores the coordinates into X and Y.
*******************************************************************************}

Function FindFurnace(Var X, Y: Integer): Boolean;

Var
TPAA: T2DPointArray;
TPA: TPointArray;
CTS, I, X, Y: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 3815998, MSX1, MSY1, MSX2, MSY2, 10);
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, 50, 50);
SortATPASize(TPAA, True);
For I := 0 To High(TPAA) Do
If GetArraylength(TPAA[i]) > 150 Then
Begin
MiddleTPAEx(TPAA[i], X, Y);
MMouse(X, Y, 3, 3);
If IsUpText('urnac') Then
Begin
Result := True;
GetMousePos(X, Y);
Break;
End;
End;
End;


Second thing, Bitmaps.scar in the misc folder gives us great possibilities for Smithing.scar improvement on the smelting behalf, since it has got all the bitmaps for the bars.

Third, about this one I am not sure does it go too far thinking from the point of view that there needs to be something done by the scripter too, but what about an "universal handler" for the smithing interface, where you could do like Smith('Iron platebody')? :)

Cazax

2008-05-01 15:10:36

Im with you :) ill start making Smithng functions for bronze things. A lil' thing:
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 3815998, MSX1, MSY1, MSX2, MSY2, 10);
to:

ColorToleranceSpeed(3);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2895152, MSX1, MSY1, MSX2, MSY2, 10);
:)

EDIT: Latest functions:
SmeltScreen: Boolean:
function SmeltScreen: Boolean;
begin
Result := (GetColor(36, 432) = 0);
end;

Smelt(Bar : String; HowMany : Integer): Boolean:
Function Smelt(Bar : String; HowMany : Integer): Boolean;
Var
BarBox : TBox;
begin
If Not (SmeltScreen) Then Exit;
If (HowMany > 28) Or (HowMany < 1) Then
Begin
srl_Warn('Smelt', 'Invalid range - ' + IntToStr(HowMany), Warn_AllVersions);
End;
Case LowerCase(Bar) Of
'bronze': BarBox := IntToBox(37, 399, 69, 418);
'blurite': BarBox := IntToBox(88, 400, 116, 421);
'iron': BarBox := IntToBox(141, 399, 171, 422);
'silver': BarBox := IntToBox(190, 401, 218, 421);
'steel': BarBox := IntToBox(243, 397, 273, 419);
'gold': BarBox := IntToBox(293, 402, 323, 419);
'mithril': BarBox := IntToBox(346, 399, 377, 423);
'addy','adamant','adamantite': BarBox := IntToBox(399, 396, 430, 420);
'rune','runite': BarBox := IntToBox(453, 400, 482, 422);
Else
Begin
srl_Warn('Smelt', 'Invalid Option - '+ Bar, Warn_AllVersions);
Result := False;
Exit;
End;
End;
MouseBox(BarBox.X1, BarBox.Y1, BarBox.X2, BarBox.Y2, 2);
Wait(150 + Random(100));
If Not (ChooseOption(IntToStr(HowMany))) Then
Begin
ChooseOption('X');
Wait(2000 + Random(1000));
TypeSend(IntToStr(HowMany));
End;
Wait(500 + Random(500));
If FindNPCChatText('Click here', ClickLeft) Then
Begin
srl_Warn('Smelt', 'No Ore(s)', Warn_AllVersions);
Result := False;
Exit;
End Else
Result := True;
End;

MORE COMING SOON

n3ss3s

2008-05-02 04:01:14

Great, I'm going to our summer cottage soon today so I'll start working too when I get home…

MylesMadness

2008-05-03 09:28:36

Hey n3s, can I use your FindFurnace function in my script. Credits and rep if you let me.

ShowerThoughts

2008-05-03 09:46:30

From: n3ss3s
It has always contained only furnace opening functions, and Smithing is a lot larger area than just opening a furnace, so to begin, I suggest the three OpenFurnaces of Smithing.scar will be replaced with a finder function, so the scripter can use that one straight if he doesn't necassarily want to yet open the furnace or then do it with his own way. There is no need for a ready furnace opener because anyone can easily make an opener using the finder.


{*******************************************************************************
Function FindFurnace(Var X, Y: Integer): Boolean;
By: n3ss3s
Description: Finds a furnace and stores the coordinates into X and Y.
*******************************************************************************}

Function FindFurnace(Var X, Y: Integer): Boolean;

Var
TPAA: T2DPointArray;
TPA: TPointArray;
CTS, I, X, Y: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 3815998, MSX1, MSY1, MSX2, MSY2, 10);
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, 50, 50);
SortATPASize(TPAA, True);
For I := 0 To High(TPAA) Do
If GetArraylength(TPAA[i]) > 150 Then
Begin
MiddleTPAEx(TPAA[i], X, Y);
MMouse(X, Y, 3, 3);
If IsUpText('urnac') Then
Begin
Result := True;
GetMousePos(X, Y);
Break;
End;
End;
End;


Second thing, Bitmaps.scar in the misc folder gives us great possibilities for Smithing.scar improvement on the smelting behalf, since it has got all the bitmaps for the bars.

Third, about this one I am not sure does it go too far thinking from the point of view that there needs to be something done by the scripter too, but what about an "universal handler" for the smithing interface, where you could do like Smith('Iron platebody')? :)


Yours look similar to mine, but first of all.
For I := 0 To High(TPAA) Do
H:=High(TPAA);
For I := 0 To H Do
:D
and I will post mine:
Function HFind(var TempX, TempY:Integer; What:String):Boolean;
Var
TempTpa: TpointArray;
Temp: T2DPointArray;
H, CTS, I, MSpeed, BigX, BIgY, Hcolor:Integer;
Uptext:String;
Begin
MSpeed:=MouseSpeed;
MouseSpeed:=30;
if Not LoggedIn Then Exit;
CTS := GetColorToleranceSpeed;
If Not CTS = 2 Then ColorToleranceSpeed(2);
Case LowerCase(What) Of
'ellis':Begin
Case Random(2) of
0:Begin
HColor:=3234951;
BigX:=20;
BigY:=20;
UpText:='anner';
End;
1:Begin
HColor:=4878794;
BigX:=15;
BigY:=15;
UpText:='anner';
End;
End;
End;
'range':Begin
Case Random(2) of
0:Begin
HColor:=2829359;
BigX:=20;
BigY:=20;
UpText:='ange';
End;
1:Begin
HColor:=6974066;
BigX:=15;
BigY:=15;
UpText:='ange';
End;
End;
End;
'furnace':Begin
Case Random(2) of
0:Begin
HColor:=1781406;
BigX:=40;
BigY:=40;
UpText:='urnace';
End;
1:Begin
HColor:=3552826;
BigX:=15;
BigY:=15;
UpText:='urnace';
End;
End;
End;
End;
FindColorsSpiralTolerance(TempX, TempY, TempTPA, HColor, MSX1+50, MSY1+50, MSX2-50, MSY2-50, 10);//Change the Color, Tol, Where to search.
Temp:= TPAtoATPAEx(TempTPA, BigX, BigY);//Change the Bigness.
SortATPASize(Temp, True);
H:=High(Temp);
For I := 0 To H Do
Begin
MiddleTPAEx(Temp[i], TempX, TempY);
MMouse(TempX, TempY, 3, 3);
Result:=HUpText([UpText]);//Change this
If Result Then Break;
End;
ColorToleranceSpeed(CTS);
MouseSpeed:=MSpeed;
End;
You Cheated me :p j/k mine is also for a range and the tanner ellis has to do something with an al-kharid 3 in one.

EvilChicken!

2008-05-03 10:42:12

From: Hermpie
For I := 0 To High(TPAA) Do
H:=High(TPAA);
For I := 0 To H Do


Actually,

H := GetArrayLength(TPAA) - 1;
For I := 0 To H Do

if you're going to count milliseconds.

Wizzup?

2008-05-03 11:54:49

From: EvilChicken!
Actually,

H := GetArrayLength(TPAA) - 1;
For I := 0 To H Do

if you're going to count milliseconds.


Make that microseconds.




program New;

var
t,i, g:integer;
a:tintegerarray;
begin
a:=[7,3,6,8];
t:=getsystemtime;
for i := 0 to 1000000 do
getarraylength(a);
writeln(floattostr((getsystemtime - t) /999999.0));
t:=getsystemtime;
for i := 0 to 1000000 do
high(a);
writeln(floattostr((getsystemtime - t) /999999.0));
end.
Successfully compiled (63 ms)
0.00265600265600266 // getarraylength
0.00298400298400298 // high
Successfully executed


Diff = 0.3 * 10^-3 milliseconds = 0.3 microseconds…
0.3 microseconds = 0.3 * 10^-9 seconds…

program New;

var
t,i, g:integer;
a:tintegerarray;
begin
a:=[7,3,6,8];
t:=getsystemtime;
for i := 0 to 1000000 do
g:=getarraylength(a)-1;
writeln(floattostr((getsystemtime - t) /999999.0));
t:=getsystemtime;
for i := 0 to 1000000 do
g:=high(a);
writeln(floattostr((getsystemtime - t) /999999.0));
end.

Successfully compiled (63 ms)
0.00357900357900358 //getarraylength-1
0.00353100353100353 // high
Successfully executed


Oops! Seems like High is faster than GetArrayLength-1 after all!

Well, GetArrayLength should truly speed up your script! Not. :p

ShowerThoughts

2008-05-03 12:10:39

From: Wizzup?
Make that microseconds.



Diff = 0.3 * 10^-3 milliseconds = 0.3 microseconds…
0.3 microseconds = 0.3 * 10^-9 seconds…



Oops! Seems like High is faster than GetArrayLength-1 after all!

Well, GetArrayLength should truly speed up your script! Not. :p


See I Knew it! :p

But you guys like my thingy or not? use n3ss3s for in srl but pls give some comment about it. :D

Gu3st...

2008-05-03 12:28:34

From: Cazax
…
Smelt(Bar : String; HowMany : Integer): Boolean:
Function Smelt(Bar : String; HowMany : Integer): Boolean;
Var
BarBox : TBox;
begin
If Not (SmeltScreen) Then Exit;
If (HowMany > 28) Or (HowMany < 1) Then
Begin
srl_Warn('Smelt', 'Invalid range - ' + IntToStr(HowMany), Warn_AllVersions);
Result := False;
Exit;
End;
...


i often do '55' as a 'HowMany' value, cus its faster to type.

EDIT: Actually, 33 is faster if using numpad :)

n3ss3s

2008-05-03 15:31:09

Myles, go ahead.

Hermpie, let's look at some facts, mmkay? It's a damn 50 * 50 pixel box split the TPAToATPAEx does there, count how many 50*50 boxes fit in to the whole mainscreen, the time of one High() and the amount of High()s you would do for all the 50*50 boxes isn't enough reason to declare the variable for the high. Second, you won't find that many 50 * 50 boxes of the furnace color that it would matter. kthxbai.

Cazax, make the function only warn, not exit or result false, if the range isn't between 1 and 28, because if you "type to make" more than you can make, it's easy to detect when you are done since it'll say so in the chatbox ;)

Cazax

2008-05-03 18:45:38

From: n3ss3s

Cazax, make the function only warn, not exit or result false, if the range isn't between 1 and 28, because if you "type to make" more than you can make, it's easy to detect when you are done since it'll say so in the chatbox ;)

Uhm yes fixed. I also fixed a bug in SmeltScreen :p