PDA

View Full Version : Working on my first script,need help with finding objects.



xujnea
05-06-2015, 11:47 PM
Hello guys, I never been programming in my life,but I decided to learn. I need to find/climb ladders,but not sure how to do this. I tried using "FindColorSpiralTolerance",but it seems it doesn't work with "HumanMMouse",cause it requires Tpoint. I tried creating var x, y = Integer; But it doesnt work that way.
I also thought about using "findMSObjectSimple",but what the hell is "cols: TIntegerArray" and how can i find it? :/ Or maybe you know even better ways to find ladder? Thanks for your time ;) o/

procedure UseLadder

var
x, y : Integer;
begin
WriteLn('Looking for ladder');
if(FindColorSpiralTolerance(x, y, 2576744, 29, 33, 466, 300, 6)) then
begin
WriteLn('Ladder found');
HumanMMouse([point(x,y)], 5, 5);
fastClick(mouse_Right);
Wait(200 + random(400));
ChooseOption('imb-up');
WriteLn('Up');
Wait(100 + random(400));
end;
end;

iEatApplez
05-07-2015, 12:12 AM
HumanMMouse([x, y], 5, 5);

This should do the trick. It's been a while, so let me know if it doesn't work.
Weird though, I remember just using HumanMMouse(x, y, 3, 3);

woo hoo
05-07-2015, 12:21 AM
If it asked for a Tpointarray instead of a Tpoint, the brackets are usually for arrays.
HumanMMouse(point(x, y), 5, 5);




"cols: TIntegerArray"
An array of colors that you'd want it to look for, something like :
findMSObjectSimple([color1, color2, color3], ['uptext1', 'uptext2'])

Flight
05-07-2015, 03:50 AM
If it asked for a Tpointarray instead of a Tpoint, the brackets are usually for arrays.
HumanMMouse(point(x, y), 5, 5);




An array of colors that you'd want it to look for, something like :
findMSObjectSimple([color1, color2, color3], ['uptext1', 'uptext2'])

In addition to this information let me point out a few basics. An array of anything will be kept in brackets []. He's a few examples:

procedure funWithArrays;
var
Point_A : TPoint;
SomePoints : TPointArray;
Integer_A : Integer;
SomeInts : TIntegerArray;
begin
Point_A := Point(150, 375); // Points consist of X/Y coordinates, so this point has a X value of 150 and Y value of 375
SomePoints := [Point(300, 195), Point(23545, 52125), Point(9248, 458)]; // This 'array of points' contains 3 points

Integer_A := 9001;
SomeInts := [1301, 4, 49, 3245328]; // An 'array of integers' containing 4 integers
end;


And you see that 'HumanMMouse' requires a TPoint in the first parameter you'll need to use a single TPoint, so you had the right idea to make a TPoint out of the X/Y values from FindColorSpiralTolerance but you tried to input that as an array of TPoints. Simply take away the brackets like so:

HumanMMouse(point(x,y), 5, 5);


Using an alternative method you could try your hand at using what's called a TMSObject but you'll need to learn a little bit about how to create & utilize those. I'd recommend you take a look at this thread (https://villavu.com/forum/showthread.php?t=112826) to get a little more info on them.

xujnea
05-07-2015, 10:23 AM
Thank you,guys,for fast and very usefull replies. It worked really nice ! :)

xujnea
05-07-2015, 03:46 PM
Now I got stuck with chatting to npc. Im using simple "HumanMMouse" and i pick colours from chatbox for failsafes. But maybe there is more efficient or better way to do that? o/

Verfy
05-07-2015, 07:21 PM
Hello guys, I never been programming in my life,but I decided to learn. I need to find/climb ladders,but not sure how to do this. I tried using "FindColorSpiralTolerance",but it seems it doesn't work with "HumanMMouse",cause it requires Tpoint. I tried creating var x, y = Integer; But it doesnt work that way.
I also thought about using "findMSObjectSimple",but what the hell is "cols: TIntegerArray" and how can i find it? :/ Or maybe you know even better ways to find ladder? Thanks for your time ;) o/

procedure UseLadder

var
x, y : Integer;
begin
WriteLn('Looking for ladder');
if(FindColorSpiralTolerance(x, y, 2576744, 29, 33, 466, 300, 6)) then
begin
WriteLn('Ladder found');
HumanMMouse([point(x,y)], 5, 5);
fastClick(mouse_Right);
Wait(200 + random(400));
ChooseOption('imb-up');
WriteLn('Up');
Wait(100 + random(400));
end;
end;

Hey there! I had some problems finding objects too but today I figured I could do something. I guess you're using lape reflection for 07 rs and this is how i did it in a script I am making:



procedure FindLectern;
begin
if lectern.Find(objGame, 'Lectern', 20) then
begin
if not lectern.IsOnMS then Reflect.Tiles.RotateCameraToTile(lectern.GetTile);
lectMSPt := Reflect.Tiles.TileToMS(lectern.GetTile);
x1 := lectMSPt.X - 15; //Made some kind of box which centre point is lectern tile ms point
y1 := lectMSPt.Y - 15;
x2 := lectMSPt.X + 10;
y2 := lectMSPt.Y + 10;
if x1 <= 0 then x1 := 2; //if box parameters passes 0 it gives error so when it's 0 or below it goes back to 2 (needs to be fixed a bit)
if y1 <= 0 then y1 := 2;
if FindColorSpiralTolerance(x, y, 3294041, x1, y1, x2, y2, 15) then //searched for specific color of an object in that box i made earlier
begin
truePt.X := x; //truePt - point where color was found (which should be on object you want to find)
truePt.Y := y;
Reflect.Mouse.Move(truePt, 0, 0);
if Reflect.Text.IsUpText('Study Lectern') then //checks if there is right uptext and clicks if it's true
begin
Reflect.Mouse.Click(mouse_right);
Reflect.Text.ChooseOption('Study Lectern');
end;
end;
end;
end;
end;


Hope it helps you in some way, if you don't understand something you can allways pm or quote :) Have fun scripting

if you were wondering how you can assign seperate integers to TPoint you can do it like this



procedure Points;
var
x, y, : integer;
somePoint : TPoint;
begin
x := 10;
y := 20;
somePoint.x := x;
somePoint.y := y;
Writeln(somePoint);
end;


^ This will output: Point(20, 10) and values of x and y will be assigned to somePoint. There may be other ways to do that but I found that way by myself :)

xujnea
05-10-2015, 06:40 PM
Thanks for replies o/ BTW,I bumped into other problem and I noticed most of script has is too. I dont want to creat new thread,so I'll write it here. How can you make random camera moves while walking ? Cause it looks really obvious... I tried this,but didn't had much luck lol. Maybe you have better ideas?


procedure RandomCam

var
RC : timer;

begin
RC.start
begin
if(RC.timeElapsed > (1000 * (random(6)))) then
begin
WriteLn('Performing antiban');
case random(8) of
0: RandomKeys0; // Just random camera movement.
1: RandomKeys1;
2: RandomKeys2;
3: RandomKeys3;
4: hoverSkill('random', false);
5: RandomKeys4;
6: RandomKeys5;
7: RandomKeys6;
8: RandomKeys7;
end;
end;
end;
end;

woo hoo
05-10-2015, 10:20 PM
Here is the RSWalker setting that allows usage of procedures while RSWalker is on a path.

RSWalker.onMoveEvent := @insertantibanprocedure;

Be careful with it, your procedure will be looping until the path is done.

Hoodz
05-10-2015, 10:37 PM
Thanks for replies o/ BTW,I bumped into other problem and I noticed most of script has is too. I dont want to creat new thread,so I'll write it here. How can you make random camera moves while walking ? Cause it looks really obvious... I tried this,but didn't had much luck lol. Maybe you have better ideas?


procedure RandomCam

var
RC : timer;

begin
RC.start
begin
if(RC.timeElapsed > (1000 * (random(6)))) then
begin
WriteLn('Performing antiban');
case random(8) of
0: RandomKeys0; // Just random camera movement.
1: RandomKeys1;
2: RandomKeys2;
3: RandomKeys3;
4: hoverSkill('random', false);
5: RandomKeys4;
6: RandomKeys5;
7: RandomKeys6;
8: RandomKeys7;
end;
end;
end;
end;

if you are using aerolib you could just call this: compassMovement(0, 360, false);
this will move the compass to a random angle between 0 and 360

xujnea
05-11-2015, 04:55 PM
Thank you,that helped alot ! :) And I'm again with another question :S Is there a way to find and react to xp increases,like osbuddy does( Xp drops )? :/

Davi
05-12-2015, 06:05 PM
Thank you,that helped alot ! :) And I'm again with another question :S Is there a way to find and react to xp increases,like osbuddy does( Xp drops )? :/

With reflection, yes.