SRL Archive - OSR Help

Colour speed 1 or 2?


Troll

2011-12-31 13:09:25

Ok so i have made a function which i want to use to fight lesser deamons in the resoucre dung, but it is very slow so the demons have moved by the time script find them.

Function Attack(Name:String):Boolean;
Var x,y,I :Integer;
TPA :TPointArray;
MyATPA :Array Of TPointArray;
Mon :Monster;
Begin
If Not LoggedIn Then Exit;
Mon := SetMon(Name);
SetColorToleranceSpeed(2);
SetColorspeed2Modifiers(Mon.Hue,Mon.Sat);
If FindColorsSpiralTolerance(x,y,TPA,Mon.Colour,MSX1,MSY1,MSX2,MSY2,Mon.Toll) Then
Begin
MyATPA := TPAtoATPAEx(TPA,Mon.W,Mon.H)
For I:= 0 To High(MyATPA) Do
If High(MyATPA[I]) > Mon.MinCount Then
Begin
SMART_DrawDotsEx(True,MyATPA[I],clRed);
MMouse(MiddleTPA(MyATPA[I]).x,MiddleTPA(MyATPA[I]).y,3,3);
If WaitUptext(Mon.Name,3000) Then
Begin
GetMousePos(x,y)
If Mon.MustRClick Then
Begin
If Random(100)=5 Then
Begin
Mouse(x,y,0,0,False);
If WaitOption(Mon.RClickOption,3000) Then
Begin
Write('Right clicked and attacked ' + Mon.Name + ' :)');
Result := True;
Exit;
End Else Begin
Write('Right Clicked ' + Mon.Name + ' But could not see option' + Mon.RClickOption);
Result := False;
Exit;
End;
End Else Begin
Mouse(x,y,0,0,True);
Write('Left clicked ' + Mon.Name);
Result := True;
Exit;
End;
Mouse(x,y,0,0,True);
Write('Left clicked ' + Mon.Name);
Result := True;
Exit;
End;
End;
End Else Write('MinCount was too high ');
End Else Begin
Write('No Colours Found for ' + Mon.Name);
Result := False
End;
End;

So should i use colour speed 1 or is the way ive scripted slow? Thanks for any input

Also here is the settings


'lesser':Begin
Result.Colour := 2634828;
Result.H := 30;
Result.Hue := 0.26;
Result.MinCount := 30;
Result.MustRClick := True;
Result.Name := 'Lesser Deamon';
Result.RClickOption := 'ttack';
Result.Sat := 1.26;
Result.Toll := 19;
Result.W := 20;

YoHoJo

2011-12-31 13:11:16

Color 2 is 'better' as in more picky/accurate.
Not sure if it's faster.

[Nathan]

2011-12-31 13:12:53

Its slow from your code not from from setcolorspeed as 2, and it is this line:

If WaitUptext(Mon.Name,3000) Then
This will move the mouse to a point, and wait 3 seconds for the uptext to be right, so you are waiting three seconds no matter where the mouse moves, if it hits a monster or not, try like 300 there and see what happens

Troll

2011-12-31 13:13:17

Yeah thats why i used colour speed as it finds them, however by the time its sorted its self out the deamon has moved
E: Dang [Nathan] thanks how did i miss that, thanks

[Nathan]

2011-12-31 13:14:23

From: Troll
Yeah thats why i used colour speed as it finds them, however by the time its sorted its self out the deamon has moved
E: Dang [Nathan] thanks how did i miss that, thanks

Use a timer to see how long it is taking to sort your TPA, its pretty close to instant for me…

Its always the simple things, for me its using for(int i=0 … because I'm so used to java.

Dynamite

2011-12-31 13:14:40

CTS1 is faster but less accurate.

-Boom

Troll

2011-12-31 13:15:38

Yep just tested it was not colour speed 2 it was my stupid use of a wait for, thanks for the help and quick answers, thanks everyone

Brandon

2011-12-31 13:18:25

Change to these two..
MiddleTPAEx(ATPA(I), X, Y);
MMouse(x, y, 3, 3);

Change to this

If WaitUptext(Uptext, 300) then

Remove this
Random(100)=5


That right there will make it take AGES!

Dynamite

2011-12-31 13:35:26

From: ggzz
Random(100)=5


I don't even…

Troll

2011-12-31 13:42:24

Does Random(100) really add a lot of time, ive taken it out and its kinda working but buggy but thats just because im new, if Random(100) takes a lot of time what would be a good way to pick left or right?

Brandon

2011-12-31 14:26:10

From: Troll
Does Random(100) really add a lot of time, ive taken it out and its kinda working but buggy but thats just because im new, if Random(100) takes a lot of time what would be a good way to pick left or right?


What do you mean pick left or right? Random(100)= 5 doesn't do that :S

Random(100) = 5 will work like this: It picks a random number between 0 and 100.. if that number = 5.. then it will do the procedure.. else it will not.. Now think about this.. What are the chances that this number will = 5? REALLLY LOW!

In your case.. if that random number = 5 then it will right click.. else left click all the time..

The right way to do this is to check if the uptext is there.. if it is, then click left else right click and chooseoption..

Random(7) = 5 takes more than long enough.. imagine 100 = 5..

Troll

2011-12-31 14:31:32

My question is how long does it take Random(100) to pick a number because If it =5 then it will right click else it will left click and with random 7 it would click right click once every 7 clicks on avg and i think that is too much however it does not matter, thanks for all your help :)

Home

2011-12-31 14:39:13

From: Troll
My question is how long does it take Random(100) to pick a number because If it =5 then it will right click else it will left click and with random 7 it would click right click once every 7 clicks on avg and i think that is too much however it does not matter, thanks for all your help :)


Just do this.

If Random(100) = 5 then Mouse(X, Y, 0, 0, True)
else
Mouse(X, Y, 0, 0, False);


Random(100) = 5 takes like 0.001 MS to compile :P

~Home

Claymore

2011-12-31 14:39:21

Its just about as instant as blinking your eyes?



case Random(10) of
0..5: Mouse(x, y, 0, 0, True);
6..10: Mouse(x, y, 0, 0, False);
end;

logical

2011-12-31 14:41:23

From: ggzz
What do you mean pick left or right? Random(100)= 5 doesn't do that :S


It does for him :P


If Random(100)=5 Then
Begin
Mouse(x,y,0,0,False);
blah;
End Else Begin
Mouse(x,y,0,0,True);
blah2;
End;

And Random(100) won't take any noticeable amount of time…

Edit: ninja'd by two people >.<

Brandon

2011-12-31 14:49:23

I don't know if I'm misunderstanding or if you guys are? I don't think he's asking how long it takes to compile but rather how long it will take before random(100) = 5 returns true.. and that is actually quite long…

program new;
{$I SRL/SRL.Scar}

var
Num, T: Integer;

begin
MarkTime(T);
while (Num <> 5) do
begin
Num:= Random(100);
writeln(Num);
end;
writeln('Time: ' + ToStr(TimeFromMark(T)));
end.



Compiled successfully in 1092 ms.
39
22
82
31
32
45
75
90
30
80
27
31
39
93
87
84
58
2
68
45
50
77
0
30
90
6
84
77
13
64
34
79
24
6
47
74
84
32
77
71
11
69
54
43
94
13
73
25
85
16
42
13
73
18
17
23
0
82
85
53
6
55
13
22
76
77
74
47
94
72
97
72
62
24
93
74
72
2
85
7
26
41
13
1
85
18
40
86
12
65
8
99
85
89
91
11
10
8
83
75
10
99
88
51
36
61
4
15
34
11
44
91
83
1
31
0
70
13
70
22
53
24
87
29
36
20
93
26
89
82
1
93
74
63
70
65
87
50
72
79
94
19
79
75
2
46
91
18
74
45
24
65
15
80
1
31
75
93
36
38
73
16
33
42
83
81
93
82
47
97
14
13
35
40
81
83
20
13
39
85
31
80
26
13
99
28
95
65
90
55
40
11
64
97
23
48
71
37
26
83
65
42
96
91
40
13
12
2
17
97
20
10
84
93
57
45
16
49
40
77
20
80
9
23
74
64
8
88
4
81
0
9
33
69
77
54
87
76
40
80
40
89
61
95
14
64
31
72
62
60
64
53
16
9
60
6
44
77
30
59
62
12
42
82
43
18
49
18
48
53
95
85
50
28
93
60
56
9
28
22
75
96
41
97
62
30
60
0
49
48
70
4
85
59
73
50
73
86
60
5
Time: 2075
Successfully executed.
That answers the question I believe.. but the thing is.. That code only wrote out the random numbers.. His code actually has to go through all those procedures to decide if to R-Click or not.. And that is where the problem is.. It will take him quite some time before Random(100) = 5 Returns true..

logical

2011-12-31 14:56:58

@ggzz
But if it returns false it will left click and continue
if random(100) = 5 is so there is a 1% chance of right clicking
It won't repeat the function if it returns false…i think

Brandon

2011-12-31 15:05:04

From: logical
@ggzz
But if it returns false it will left click and continue
if random(100) = 5 is so there is a 1% chance of right clicking
It won't repeat the function if it returns false…i think


But that's the problem.. See this:

If Mon.MustRClick Then
Begin
If Random(100)=5 Then
Begin
Mouse(x,y,0,0,False);
If WaitOption(Mon.RClickOption,3000) Then
Begin
Write('Right clicked and attacked ' + Mon.Name + ' :)');
Result := True;
Exit;
End Else Begin
Write('Right Clicked ' + Mon.Name + ' But could not see option' + Mon.RClickOption);
Result := False;
Exit;
End;

If Mon.MustRClick then it will never click unless Random(100) = 5.. Only time it will left click is if Mon.MustRClick = False..

logical

2011-12-31 15:07:34

mb :P
I see ^.^
didn't look through it properly

Troll

2012-01-02 06:59:07

From: ggzz
But that's the problem.. See this:

If Mon.MustRClick Then
Begin
If Random(100)=5 Then
Begin
Mouse(x,y,0,0,False);
If WaitOption(Mon.RClickOption,3000) Then
Begin
Write('Right clicked and attacked ' + Mon.Name + ' :)');
Result := True;
Exit;
End Else Begin
Write('Right Clicked ' + Mon.Name + ' But could not see option' + Mon.RClickOption);
Result := False;
Exit;
End;

If Mon.MustRClick then it will never click unless Random(100) = 5.. Only time it will left click is if Mon.MustRClick = False..


Ahh i saw that just after my first post and changed it here for me, but not here so thats why :P Yeah the real problem was the WaitUptext being 3 secounds, so after i took them out and pretty much rewrote the code it works a treat now :) But thanks for the help