SRL Archive - SRL Archives

Core shortenings/Procedures


Naum

2009-09-21 20:35:27

Hello there, please comment, feedback, ridicule, insult /etc.


1) A SetGraphics (Autoing Defaults) procedure which works for both, the loginscreen and in game. This means you do not need Login_SetGraphics:

Procedure FixGraphics;
Var X, Y, F : Integer; //Variables!
TPA : TPointArray;
ATPA : T2DPointArray;
TB : TBox;
Label Animations;

Begin
If FindTextTPAEx(2070783, 1, 0, 0, 758, 498, x, y, 'tanda', StatChars, Nothing) Then
Begin // ^ Checks for Orange text of 'Standard Detail'
MouseBox(x, y - 35, x + 50, y, 1); // If it finds it then it clicks on it, to activate it
Wait(1300 + Random(800)); // Waits while it sets itself.
End;

If FindTextTPAEx(2070783, 1, 0, 0, 758, 498, x, y, 'ixe', StatChars, Nothing) Then
Begin // Checks for the 'Fixed Size' text, in Orange
MouseBox(x - 14, y - 40, x + 30, y, 1);// If it finds it then it clicks on it, to activate it
Wait(500 + Random(800)); // Waits while it sets itself.
End;

If GetColor(232 + (127 * Integer(Not LoggedIn)), 215 + (103 * Integer(Not LoggedIn))) = 14474979 Then
Begin //This sets the Brightness
Mouse(232 + (127 * Integer(Not LoggedIn)), 215 + (103 * Integer(Not LoggedIn)), 5, 5, True);
Wait(900 + Random(700));
End;

If FindTextTPAEx(2070783, 1, 0, 0, 758, 498, x, y, 'x', StatChars, Nothing) Then //Finds the orange 'x'
If Not FindText(x, y, '0x6', StatChars, x - 50, y - 50, x + 50, y + 50) Then //Finds the text around it
Begin
Mouse(x, y, 30, 10, True); //Sets it at 800x600
Wait(200 + Random(200)); //Waits.
Mouse(x, y + 15, 1, 4, True);
End;

If FindText(x, y, 'Ad', UpChars, 0, 0, 758, 498) Then //Finds the Advanced Settings text
TB := IntToBox(x, y - 50, x + 520, y + 150); //Makes boundaries for FindColors, hence its global

FindColorsTolerance(TPA, 3753553, TB.x1, TB.y1, TB.x2, TB.y2, 0); //Finds Occurances of the Background 'Box color'
ATPA := TPAToATPAEx(TPA, 13, 13); //Splits then into squares of 13x13
SortATPAFromFirstPoint(ATPA, Point(197, 89)); //Sorts them
For F := 0 To High(ATPA) Do //This loop will now set it.
Begin
TB := GetTPABounds(ATPA[F]); //Gets the boundaries of the box
If FindText(x, y, 'any', StatChars, TB.x1 - 65, TB.y1 - 4, TB.x2 + 2, TB.y2 + 3) Then
GoTo Animations; //^ since animations have 3 options, if the given TPA is the option then it will skip the check.

If CountColor(2070783, TB.x1, TB.y1, TB.x2, TB.y2) >= 5 Then //To filter the text from arrows.
If CountColor(2070783, TB.x1 - 45, TB.y1, TB.x1 + 3, TB.y1 + 3) = 0 Then //To check the option isn't already set
Begin
Animations :
MouseBox(TB.x1 - 45, TB.y1, TB.x2, TB.y2, 1); //Clicks on one of the options
Wait(800 + Random(200)); //Waits.
If FindColor(x, y, 2070783, TB.x1 - 55, TB.y1 + 11, TB.x1 - 6, TB.y2 + 7) Then //Finds the orange color in the pop-up
Mouse(x, y, 20, 8, True); //Randomly clicks it
Begin
Wait(50 + Random(80)); //Waits
MMouse(x, y - 10, 6, 4); //Moves mouse off the box, so it doesn't muck up the ATPA
Wait(900 + Random(180)); //Waits while it is being set.
End;
End;
End;
End;



2) OrderWorlds in WorldSwitcher.scar does NOT work. I made a fix for it, plus I made it much shorter:

Procedure OrderWorlds(By : String; Descending : Boolean);
Var TPA : TPointArray;
ATPA : T2DPointArray;
I : Byte;
Arr : T2DStringArray;
TB : TBox;
Begin
Arr := [TStringArray(['world', 'w', 'worlds']), TStringArray(['players', 'pl', 'player']), TStringArray(['activity', 'location', 'loc', 'act']),
TStringArray(['ls', 'lootshare']), TStringArray(['type', 't']), TStringArray(['ping', 'pi'])];
For I := 0 To High(Arr) Do
If InStrArr(Lowercase(By), Arr[i], False) Then
Break;
FindColorsTolerance(TPA, 1074576, 0, 0, 716, 141, 1);
ATPA := SplitTPA(TPA, 2);
SortATPAFromFirstPoint(ATPA, Point(91, 124));
TB := GetTPABounds(ATPA[(I * 2)+Integer(Descending)]);
MouseBox(TB.x1, TB.y1, TB.x2, TB.y2, 1);
End;



3) The SetAngle shorten, using Integer();


procedure SetAngle(Highest : Boolean);
begin
if (not LoggedIn) then exit;
KeyDown((Integer(Not Highest)*2)+38);
Sleep(1000 + Random(300));
KeyUp((Integer(Not Highest)*2)+38);
Wait(500 + Random(100));
end;
This should also be done to 'RandomAngle'.



4) A DragMouse(); procedure:


Procedure DragMouse(StartX, StartY, SRandX, SRandY, EndX, EndY, ERandX, ERandY : Integer);
Begin
MMouse(StartX, StartY, SRandX, SRandY);
Wait(150 + Random(20));
GetMousePos(x, y);
HoldMouse(x, y, True);
Wait(50 + Random(20));
MMouse(EndX, EndY, ERandX, ERandY);
Wait(150 + Random(20));
ReleaseMouse(x, y, True);
End;

Would help cut down on the code for few things, for example DragItem, Bee_DragMouse and a few others.

Usage: If I wanted to click on 500, 500 with 6 randomness on the x and 7 on the y co-ord, I would do:

DragMouse(500, 500, 6, 7 ....);

If I wanted to drag it to 800, 800 and release it with 3 randomness and 6 for x and y respectively, I would then add:

DragMouse(500, 500, 6, 7, 800, 800, 3, 3);

:)



5) In Text.Scar, TypeSend:

C:= GetKeyCode(StrGet(Text, I));

could be:

C:= GetKeyCode(Text[I]);

Cuts out the un-needed 'StrGet'..



6) In Agility.Scar, a typo

 'agiliy dungeon ledge': CourseXP := 22.5;

To:

 'agility dungeon ledge': CourseXP := 22.5;



7) ClickNorth shorten:

procedure ClickNorth(AngleHigh: boolean);
begin
if Random(4) = 1 then
begin
Mouse(542, 24, 15, 15, False);
WaitOptionMulti(['ace', 'orth'], 1200);
end else
Mouse(542, 24, 15, 15, True);
if AngleHigh then
begin
Wait(RandomRange(500, 1250));
SetAngle(True);
end;
end;

To :

procedure ClickNorth(AngleHigh: boolean);
begin
if Random(4) = 1 then
begin
Mouse(542, 24, 15, 15, False);
WaitOptionMulti(['ace', 'orth'], 1200);
end else
Mouse(542, 24, 15, 15, True);
Wait(RandomRange(500, 1000));
SetAngle(AngleHigh);
end;

The compass in RuneScape, when clicked on will NOT set it to the lowest angle, it seems to set it somewhere in-between.


8) A new procedure called MouseCircle()

Procedure MouseCircle(MidX, MidY, Radius : Integer);
Var TP : TPoint;
Control : Array [0..1] Of Integer; //The random controls
Begin
Control[0] := Random(Radius) + 1; //Finds a radius between 0 and 'Radius'
Control[1] := Random(361); //Gives a Random Angle in Degrees.
TP := Point(Round(Control[0] * Sin(Control[1] * Pi / 180)) + MidX,
Round(-Control[0] * Cos(Control[1] * Pi / 180)) + MidY); //Works out the point
Mouse(TP.x, TP.y, 0, 0, True); //Clicks There
End;

I was thinking of a new mouse procedure. For example we have mousebox, this clicks anywhere in the boundaries specified. So I thought about MouseCircle, this would click randomly in the circle specified by the MidPoints - MidPointX and MidPointY, and Radius 'Radius'.

It's main uses would be for clicking on the world map for example or the compass, to face north or whatever.


Will add more If I find :).

Thanks!

NCDS

2009-09-21 20:43:27

You are ridiculous.

Nice work Naum :)

Gu3st...

2009-09-22 00:09:41

Nub.
Good job! :)

YoHoJo

2009-09-22 00:18:47

<3 Goojob. Be a Dev.

Gu3st...

2009-09-22 00:23:52

From: YoHoJo
<3 Goojob. Be a Dev.


lol I agree :P

marpis

2009-09-22 00:27:06

lol, how do you have the energy to find these little tweaks in every core file :p

Rich

2009-09-22 00:30:06

From: marpis
lol, how do you have the energy to find these little tweaks in every core file :p


He must sit there for hours on end, just searching for the tiniest things which he could change to make it better, such as the StrGet thing in the first post :p

Anyway, nice going Naum.

YoHoJo

2009-09-22 00:30:19

He actually reads though the SRL include and looks for ways to fix it.
He's also got a photographic memory (i think) and memorizes weird shit…

Sandstorm

2009-09-22 01:16:09

YoHoJo, you're thinking of a photographic memory.

One word: Damn.

~Sandstorm

YoHoJo

2009-09-22 02:08:48

@ Sandstorm ROFL!

Sabzi

2009-09-22 17:25:48

You are all wrong. He is a machine and he got a USB cable or whatever it's called. He just plug it in his computer and scans the include. He got everything fixed but he don't want to post it in one thread so he always releases a few fix/tweak every once in a while.

On a serious note: Why aren't you a dev? You should be in my eyes :p.
Great job!

Naum

2009-09-22 23:44:48

Thanks for all the comments :)

I was thinking of a new mouse procedure. For example we have mousebox, this clicks anywhere in the boundaries specified. So I thought about MouseCircle, this would click randomly in the circle specified by the MidPoints - MidPointX and MidPointY, and Radius 'Radius'.

It's main uses would be for clicking on the world map for example or the compass, to face north or whatever:

Procedure MouseCircle(MidPointX, MidPointY, Radius : Integer);
Var TP : TPoint;
R, II : Integer;
Rand : Array [0..1] Of Integer;
Begin
Rand[0] := 1 + Random(358);
Rand[1] := Random(Radius)-1;
For II := 0 To Radius Do
For R := 1 To 360 Do
Begin
TP := Point(Round(II * Sin(R * Pi / 180)) + MidPointX,
Round(-II * Cos(R * Pi / 180)) + MidPointY);

If (Rand[0] = R) And (Rand[1] = II) Then
Begin
Mouse(TP.x, TP.y, 0, 0, True);
Exit;
End;
End;
End;

Would be smex-eh if you could give it a try. Tested it on paint btw :)

Rich

2009-09-23 00:55:11

From: NaumanAkhlaQ
Thanks for all the comments :)

I was thinking of a new mouse procedure. For example we have mousebox, this clicks anywhere in the boundaries specified. So I thought about MouseCircle, this would click randomly in the circle specified by the MidPoints - MidPointX and MidPointY, and Radius 'Radius'.

It's main uses would be for clicking on the world map for example or the compass, to face north or whatever:

Procedure MouseCircle(MidPointX, MidPointY, Radius : Integer);
Var TP : TPoint;
R, II : Integer;
Rand : Array [0..1] Of Integer;
Begin
Rand[0] := 1 + Random(358);
Rand[1] := Random(Radius)-1;
For II := 0 To Radius Do
For R := 1 To 360 Do
Begin
TP := Point(Round(II * Sin(R * Pi / 180)) + MidPointX,
Round(-II * Cos(R * Pi / 180)) + MidPointY);

If (Rand[0] = R) And (Rand[1] = II) Then
Begin
Mouse(TP.x, TP.y, 0, 0, True);
Exit;
End;
End;
End;

Would be smex-eh if you could give it a try. Tested it on paint btw :)


Very nice. I thought using an equal amount of randomness with Mouse would give a circle, so I gave it a shot on paint as well. The Mouse with randomness came out a perfect square (unexpectedly) and your function and nice neat circle. Nice going Naum!

Naum

2009-09-23 19:56:11

Thanks for testing,

Upped in first post :D

Rich

2009-09-23 20:06:20

No problem. I'm glad I could help.

EvilChicken!

2009-09-28 12:18:09

Comitted 2, 3 and 6.
Plus, removed the stupid C: Byte var in TypeSendEx.

Thanks a lot, Naum.
(Btw, sorry that I sometimes don't reply on MSN when I'm on my xBox. <_<)

Naum

2009-09-28 23:06:53

From: EvilChicken!
Comitted 2, 3 and 6.
Plus, removed the stupid C: Byte var in TypeSendEx.

Thanks a lot, Naum.
(Btw, sorry that I sometimes don't reply on MSN when I'm on my xBox. <_<)


Hey, Thanks man :).

(Please get some new games, I'm sick of see-ing the same 3 - 4 games in your name :p)

Rich

2009-09-28 23:16:31

I definitely think that MouseCircle should be added. EC, if you test it, you will see how useful it is. It could be used for many things, such as clicking the compass.

Naum

2009-09-29 19:45:37

From: R1ch
I definitely think that MouseCircle should be added. EC, if you test it, you will see how useful it is. It could be used for many things, such as clicking the compass.


I had a look at it, and found that it could be made much, much shorter:

Procedure MouseCircle(MidPointX, MidPointY, Radius : Integer);
Var TP : TPoint;
Begin
TP := Point(Round(Random(Radius+ 1) * Sin(Random(361) * Pi / 180)) + MidPointX,
Round(-Random(Radius+ 1) * Cos(Random(361) * Pi / 180)) + MidPointY);
Mouse(TP.x, TP.y, 0, 0, True);
End;

Got rid of loads, I made it draw stuff with points:


This is the test script I used:

Var X : Integer;

Procedure MouseCircle(MidPointX, MidPointY, Radius : Integer);
Var TP : TPoint;
Begin
TP := Point(Round(Random(Radius+ 1) * Sin(Random(361) * Pi / 180)) + MidPointX,
Round(-Random(Radius+ 1) * Cos(Random(361) * Pi / 180)) + MidPointY);
ClickMouse(TP.x, TP.y, True);
End;

Begin
For x := 0 To 60000 Do
MouseCircle(300, 100, 40);
End.

:)

EvilChicken!

2009-09-29 21:44:51

R1ch, I know how useful it is – I just used my future-predicting-skillz to predict that Naum would leeten up that procedure. Which is why I waited with committing it until today. (You believe me, right?)

Naum; reccomend me a new game, then!

But, as I said, I committed your new proc, good job.

Sabzi

2009-09-29 22:49:26

It gives me this:
?
With this:
program New;

procedure MouseCircle(MidPointX, MidPointY, Radius: Integer);
var
TP : TPoint;
begin
TP := Point(Round(Random(Radius + 1) * Sin(Random(361) * Pi / 180)) + MidPointX,
Round(-Random(Radius + 1) * Cos(Random(361) * Pi / 180)) + MidPointY);
ClickMouse(TP.x, TP.y, True);
end;

begin
repeat
MouseCircle(356, 251, 50);
Wait(5);
until False;
end.

What's happening?

Off: Naum, I found one thing that I don't like in you. Those capitalized bolds makes me crazy.

Naum

2009-09-30 19:33:03

I <3 Bold Words, Capitalized!!!

Furthermore, thanks. I kinda overlooked the fact that the controls had to be the same.

I got a fixed version, all annotated and commented:

{*******************************************************************************
procedure MouseCircle(MidX, MidY, Radius : Integer);
By: NaumanAkhlaQ
Description: Clicks a random point in the circle of midpoint 'MidX', 'MidY'
and with a radius of 'Radius'.
*******************************************************************************}

Procedure MouseCircle(MidX, MidY, Radius : Integer);
Var TP : TPoint;
Control : Array [0..1] Of Integer; //The random controls
Begin
Control[0] := Random(Radius) + 1; //Finds a radius between 0 and 'Radius'
Control[1] := Random(361); //Gives a Random Angle in Degrees.
TP := Point(Round(Control[0] * Sin(Control[1] * Pi / 180)) + MidX,
Round(-Control[0] * Cos(Control[1] * Pi / 180)) + MidY); //Works out the point
Mouse(TP.x, TP.y, 0, 0, True); //Clicks There
End;

EDIT: Thanks :D

Sabzi

2009-09-30 19:40:15

From: NaumanAkhlaQ
I <3 Bold Words, Capitalized!!!

Furthermore, thanks. I kinda overlooked the fact that the controls had to be the same.

I got a fixed version, all annotated and commented:

{*******************************************************************************
procedure MouseCircle(MidX, MidY, Radius : Integer);
By: NaumanAkhlaQ
Description: Clicks a random point in the circle of midpoint 'MidX', 'MidY'
and with a radius of 'Radius'.
*******************************************************************************}

Procedure MouseCircle(MidX, MidY, Radius : Integer);
Var TP : TPoint;
Control : Array [0..1] Of Integer; //The random controls
Begin
Control[0] := Random(Radius) + 1; //Finds a radius between 0 and 'Radius'
Control[1] := Random(361); //Gives a Random Angle in Degrees.
TP := Point(Round(Control[0] * Sin(Control[1] * Pi / 180)) + MidX,
Round(-Control[0] * Cos(Control[1] * Pi / 180)) + MidY); //Works out the point
Mouse(TP.x, TP.y, 0, 0, True); //Clicks There
End;

Capitalized bold words are evil.
It works excellent now. I am sure I will use this. Oh and if you commented that for me thanks but the question "What happening here?" meant: Am I causing the problem and then what I did wrong or you left a bug in there by accident?

Seriously, I should learn how to say what I want more clearly :D.

EvilChicken!

2009-09-30 20:01:10

Sabzi; don't worry, I fix his capitalization before committing. :garfield:


BAH; my future-predicting-skillz failed me. D:
Committed the new version.

Naum

2009-09-30 20:06:36

From: EvilChicken!
Sabzi; don't worry, I fix his capitalization before committing. :garfield:


BAH; my future-predicting-skillz failed me. D:
Committed the new version.


Heh, my fault, must test before posting :(.

Thanks for the commit :).

Sabzi

2009-09-30 20:13:38

From: NaumanAkhlaQ
Heh, my fault, must test before posting :D.

Thanks for the commit :).

EDIT: YOU SHALL NEVER CRUSH CAPITALISM!!1oNEsHIFT!!!11


I always wanted you as a developer and never knew why aren't you one already. But that post shows me that you would capitalize everything in the includes, lol.
We don't want it.



Joke of course, I still want you as a dev.(without capitalizing)