SRL Archive - OSR Help

How would I make the script Rotate the camera if it doesn't find a color?


Twinki

2013-04-30 21:51:43

This is for a RSPS, I doubt that makes a difference though. I made a script for finding an Ardy knight and Pick'ing it. Sometimes the knight will get stuck behind a tree or building and the bot won't be able to find it. How would I make it rotate the camera if it doesn't find the knight, until it finds it?

// Find and PickPocket Knight \\
procedure FindKnight;
var
X, Y:Integer;
begin
if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
begin
WriteLn('Found Knight');
MMouse(x, y, 0, 0);
ClickMouse2(False);
wait(2000);
ChooseOption('Pickpocket Knight');
wait(250);
WriteLn('Picked Knight');
inc(PickPockets);
end;
end;

tealc

2013-04-30 22:06:12

something like below 69 is code for the letter "e". Ill update when I find the arrow key codes.

else
begin
keydown(69);
wait(500);
keyup(69);
end;

Twinki

2013-04-30 22:08:50

From: tealc
something like below 69 is code for the letter "e". Ill update when I find the arrow key codes.

else
begin
keydown(69);
wait(500);
keyup(69);
end;


Ahhhh, didn't realize the Else statements works the same way as Java's else..
I found the list though, http://docs.villavu.com/simba/scriptref/mouseandkeyboard.html#keyboard-virtual-keys

Thanks :)

Sjoe

2013-04-30 22:13:08

From: Twinki
Ahhhh, didn't realize the Else statements works the same way as Java's else..
I found the list though, http://docs.villavu.com/simba/scriptref/mouseandkeyboard.html#keyboard-virtual-keys

Thanks :)


MakeCompass might be easier to use.

King

2013-04-30 22:13:35

From: Twinki
Ahhhh, didn't realize the Else statements works the same way as Java's else..
I found the list though, http://docs.villavu.com/simba/scriptref/mouseandkeyboard.html#keyboard-virtual-keys

Thanks :)

procedure FindKnight;
var
X, Y:Integer;
begin
if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
begin
WriteLn('Found Knight');
MMouse(x, y, 0, 0);
ClickMouse2(False);
wait(2000);
ChooseOption('Pickpocket Knight');
wait(250);
WriteLn('Picked Knight');
inc(PickPockets);
end
else
CompassMovement( 60, 120, true);
end;

That will move the compass a minimum of 60 degrees, max of 120 and return to the original position afterwards, set it to 'false' to stay where it lands.

tealc

2013-04-30 22:20:20

He said its for a private server will those compass functions still work?

Twinki

2013-04-30 22:22:16

From: tealc
He said its for a private server will those compass functions still work?


Well the RSPS is just like EoC, well right before it was launched basically. I'll try both :)

Twinki

2013-04-30 22:52:25

From: King
procedure FindKnight;
var
X, Y:Integer;
begin
if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
begin
WriteLn('Found Knight');
MMouse(x, y, 0, 0);
ClickMouse2(False);
wait(2000);
ChooseOption('Pickpocket Knight');
wait(250);
WriteLn('Picked Knight');
inc(PickPockets);
end
else
CompassMovement( 60, 120, true);
end;

That will move the compass a minimum of 60 degrees, max of 120 and return to the original position afterwards, set it to 'false' to stay where it lands.


Neither of them aren't working actually, it doesn't even start the 'Else'
procedure FindKnight;
var
X, Y:Integer;
begin
if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
begin
WriteLn('Found Knight');
MMouse(x, y, 0, 0);
ClickMouse2(False);
wait(2000);
ChooseOption('Pickpocket Knight');
wait(250);
WriteLn('Picked Knight');
inc(PickPockets);
end
else
begin
WriteLn('Knight not found, rotating camera')
keydown(37);
wait(500);
keyup(37);
end;
end;

tealc

2013-04-30 22:57:05

so it writes 'Found Knight' and moves the mouse? Try a smaller tolerance.

Sk1nyNerd

2013-04-30 23:05:46

if it doesnt start the else then its finding your colors somewhere, your procedure looks correct. i would recommend adding a repeat until to your else otherwise it will only move the camera once for half a second, unless thats enough time to find the knight? you also dont have it going back to pickpocket the knight once it finds it

Twinki

2013-04-30 23:08:37

From: tealc
so it writes 'Found Knight' and moves the mouse? Try a smaller tolerance.


Yeah, then it moves the mouse to the bottom right, like it does when it can't find something.

My ACA will wright out that it doesn't find it, but not move the camera / write out what I coded.

tealc

2013-04-30 23:17:14

which cts are you using

example of cts 2

procedure
//vars
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(hue mod, sat mod);//these are found on ACA and these two are only for cts 2
begin
if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
begin
WriteLn('Found Knight');
MMouse(x, y, 0, 0);
ClickMouse2(False);
wait(2000);
ChooseOption('Pickpocket Knight');
wait(250);
WriteLn('Picked Knight');
inc(PickPockets);
end
else
begin
WriteLn('Knight not found, rotating camera')
keydown(37);
wait(500);
keyup(37);
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;

Twinki

2013-04-30 23:22:47

From: tealc
which cts are you using

example of cts 2

procedure
//vars
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(hue mod, sat mod);//these are found on ACA and these two are only for cts 2
begin
if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
begin
WriteLn('Found Knight');
MMouse(x, y, 0, 0);
ClickMouse2(False);
wait(2000);
ChooseOption('Pickpocket Knight');
wait(250);
WriteLn('Picked Knight');
inc(PickPockets);
end
else
begin
WriteLn('Knight not found, rotating camera')
keydown(37);
wait(500);
keyup(37);
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;


Full ACA:

// ACA for Knight \\
function KnightColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.19, 0.78);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 11542895, MSX1, MSY1, MSX2, MSY2, 21);
if (Length(arP) = 0) then
begin
Writeln('Failed to find Knight, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
//Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 2.75) and (X <= 26.73) and (Y >= 1.72) and (Y <= 15.51) and (Z >= 7.95) and (Z <= 84.02) then
begin
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('Failed to find the Knight');
end;

CTS 2 (I think…)
  tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.19, 0.78);

King

2013-04-30 23:26:05


function FindKnight: Boolean; // Returns true if found, use like this If FindNight then blah blah blah
var
X, Y, Failcount: Integer;
begin
result := false; //sets to false so all other but success automagically = false
repeat
if FindColorTolerance(X, Y, KnightColor, MSX1 MSY1, MSX2, MSY2, 10) then //Try using a lesser tolerance / TPA, find color isnt the most useful
begin
WriteLn('Found Knight'); //Debug
MMouse(x, y, 2, 2); // Always add randomness
ClickMouse2(False);
WaitOption('Pickpocket ', 350); // Same effect, waits for the option of PickPocket
wait(randomrange(250, 350)); //Once again randomness
WriteLn('Picked Knight');
inc(PickPockets); // proggy
result := true; // Results true for the function
end
else
begin
writeln('Did not find the knight, moving compass'); //Lets us know where we are at
CompassMovement(60, 120, false); // Moves the compass between 60-120 degrees
inc(FailCount); // Increases the failcount for our loop
end;
until (result or (FailCount >= 10)); // Stops when the result is true (result = default true) or we fail 10 times
end;

^ should work, commented code, learn TPAs/ATPA's here, they make life much easier!(:

Twinki

2013-04-30 23:29:14

From: King

function FindKnight: Boolean; // Returns true if found, use like this If FindNight then blah blah blah
var
X, Y, Failcount: Integer;
begin
result := false; //sets to false so all other but success automagically = false
repeat
if FindColorTolerance(X, Y, KnightColor, MSX1 MSY1, MSX2, MSY2, 10) then //Try using a lesser tolerance / TPA, find color isnt the most useful
begin
WriteLn('Found Knight'); //Debug
MMouse(x, y, 2, 2); // Always add randomness
ClickMouse2(False);
WaitOption('Pickpocket ', 350); // Same effect, waits for the option of PickPocket
wait(randomrange(250, 350)); //Once again randomness
WriteLn('Picked Knight');
inc(PickPockets); // proggy
result := true; // Results true for the function
end
else
begin
writeln('Did not find the knight, moving compass'); //Lets us know where we are at
CompassMovement(60, 120, false); // Moves the compass between 60-120 degrees
inc(FailCount); // Increases the failcount for our loop
end;
until (result or (FailCount >= 10)); // Stops when the result is true (result = default true) or we fail 10 times
end;

^ should work, commented code, learn TPAs/ATPA's here, they make life much easier!(:


I didn't add randomness because this is an RSPS.. and I've had permission from the owner to script bots. But thanks i'll try it out :)

EDIT: Also this doesn't move the compass either when it can't find it, and I know this wasn't a fix for it was just saying :P

King

2013-04-30 23:40:31

From: Twinki
I didn't add randomness because this is an RSPS.. and I've had permission from the owner to script bots. But thanks i'll try it out :)

EDIT: Also this doesn't move the compass either when it can't find it.


Then I really dont know what to say, tested this with my own colors, worked finee

Twinki

2013-04-30 23:44:15

From: King
Then I really dont know what to say, tested this with my own colors, worked finee


Well I noticed that even if the knight isn't visible, it still acts as if it does. If that makes sense :P

If I just run the script and make the window the simba window, it'll still say it found the Knight and say it pickpocketed it. It'll even right click…

King

2013-05-01 00:02:26

From: Twinki
Well I noticed that even if the knight isn't visible, it still acts as if it does. If that makes sense :P

If I just run the script and make the window the simba window, it'll still say it found the Knight and say it pickpocketed it. It'll even right click…


Then you need to redo the colors matey :P I would just use a color from ACA not the entire function, more than likely because you are using a tolerance on an already colored function. So just use findcolorspiral, without tolerance

Twinki

2013-05-01 00:14:54

From: King
Then you need to redo the colors matey :P I would just use a color from ACA not the entire function, more than likely because you are using a tolerance on an already colored function. So just use findcolorspiral, without tolerance


Yeah it has something to do with the ACA Function, but there isn't a good color that shows up on both the back and front of the knight..

King

2013-05-01 00:16:15

From: Twinki
Yeah it has something to do with the ACA Function, but there isn't a good color that shows up on both the back and front of the knight..


Pm me a screenshot, Ill find a Good color combination today/ tomorrow. I may just make a TPA finding function if you like