SRL Archive - OSR Help

[Color] Help


Polack

2015-04-03 12:58:03

Hey, I'm trying to make a simple collector script, and I'm having trouble with a few parts:
    *Script needs to wait for a set time period after collecting X amount of items (i.e. after collecting 3 bones it needs to sit there and wait until a bone respawns (not keep searching for similar colors) *Is there a way to tell if the script is walking so that it doesn't try to click mid-walk (especially on a different object – so far I'm just solving by increasing the wait times between clicks) *What function do I use to switch worlds (to a world that I set?)

This is my code for just the looting part:


procedure Loot;.
var
x, y : Integer;
i : integer;
begin
for i:=1 to 3 do //my attempt at making it only collect 3 items before waiting X amount of time
begin
if not LoggedIn then LoginPlayer else
begin
if FindObjCustom(x, y, ['Take', 'ones'], [COLOR], 3) then //it doesn't seem to collect items in order of closeness to player; it might be a problem with the color tolerance (a lot of similar colors around unfortunately(the wall, the NPCS, even the damn ground lol))
begin
MMouse (x, y, 3, 3);
Wait(200 + Random(100));
Mouse (x, y, 0, 0, false); //left click would be faster/easier, but this is more stable i think
Wait(100 + Random(100));
ChooseOption('Take Bones');
Wait(4000 + Random(100)); //wait in between collecting items (to compensate for walking time)
end else; //I thought this would work for waiting X amount of time before looking for the item again after IF there were none left
begin
wait (3000 + Random(250));
end;
end;
end;
end;

Overall this code works for looting, albeit it's kinda slow and inefficient – especially how it sometimes doesn't pick items up in order of closeness. I remember reading a part of a tutorial (forgot whose) about making TPA's of bankers and using them based on closeness – could that work for collecting (haven't done a TPA yet so I'm apprehensive xD).
Also, on a unrelated note, do I need to 'FreeDTMs' in my script if I use them (also haven't done this yet).

Home

2015-04-03 13:56:04

Heya, I quickly made this up (On phone at the moment, so I don't know what functions are in SRL-OSR Include, but you get the idea, how to speed things up).


program new;
{$i SRL-OSR/SRL.Simba}

const
COLOR = 123;
AMOUNT_TO_PICK = 3;
WAIT_TIME = 3000;

procedure Loot;
var
x, y: Integer;
i: integer;
begin
I := 0;
while (I <= AMOUNT_TO_PICK) do
begin
if FindObjCustom(x, y, ['Take', 'ones'], [COLOR], 3) then
begin
Mouse(X, Y, 0, 0, mouse_left);
if WaitOptionMulti(['ake B', 'Take Bones'], RandomRange(250, 350)) then
begin
Flag;
Inc(I);
end;
end;
end;
Wait(WAIT_TIME + Random(500));
end;

begin
SetupSRL;
end.


For finding objects with better accuracy, I suggest you to take a look in TPA's.

~Home

Polack

2015-04-03 14:11:41

From: Home
Heya, I quickly made this up (On phone at the moment, so I don't know what functions are in SRL-OSR Include, but you get the idea, how to speed things up).


program new;
{$i SRL-OSR/SRL.Simba}

const
COLOR = 123;
AMOUNT_TO_PICK = 3;
WAIT_TIME = 3000;

procedure Loot;
var
x, y: Integer;
i: integer;
begin
I := 0;
while (I <= AMOUNT_TO_PICK) do
begin
if FindObjCustom(x, y, ['Take', 'ones'], [COLOR], 3) then
begin
Mouse(X, Y, 0, 0, mouse_left);
if WaitOptionMulti(['ake B', 'Take Bones'], RandomRange(250, 350)) then
begin
Flag;
Inc(I);
end;
end;
end;
Wait(WAIT_TIME + Random(500));
end;

begin
SetupSRL;
end.


For finding objects with better accuracy, I suggest you to take a look in TPA's.

~Home


Thank you. I'll try this when I get back to my computer and tell you how it goes.

Polack

2015-04-04 00:48:00

Seems to still spam click multiple times; often clicking on the next item before it finished picking up the first (it collects them all eventually, but it just looks bot-like + messes up the order of collecting completely). I added a longer wait time in the 'RandomRange', but too long would reduce efficiency. After it loots all the items, it still seems to hover between two patches of ground that are a similar color (I'll look into making a TPA tomorrow).
Other then that, it's not too bad at looting.

Does anyone know how to implement world hopping (after it finished looting all the items on current world)?

Thanks

Zace

2015-04-05 23:40:54

Function LootBones:Boolean;
var
X, Y, PlusOne, BoneCounter, TooLong: Integer;
Begin
MarkTime(TooLong);
FindNormalRandoms;
PlusOne:= InvCount + 1;
//If if FindObjCustom(x, y, ['Take', 'ones'], [COLOR], 3) then
x:=MSCX;//searchs from the middle of game screen X-Axis(Closest to you)
y:=MSCY; // Main screen of Y axis same as above so it finds bones closest to you
If FindObjTPA(x, y, BoneColor, TOL, 1, 15, 15, 8, ['ones']) Then //Use APA for Tol 15 width and 15 height(Counting Pixels/Draws Box around Bones) 8 pixels of that color in the box
Begin
WriteLn('Found Bone');
GetMousePos(x, y);

Case Random(2) Of
0: Mouse(x, y, 5, 5, True);
1: Begin
Mouse(x, y, 5, 5, False);
WaitOption('ones', 500);
end;
end;

Flag;//waits for flag on minimap to go away before performing next action
Marktime(BoneCounter);
If (TimeFromMark(TooLong)> 30000) Then
FailSafe('Could not find Bones!');
Repeat
If (TimeFromMark(TooLong)> 30000) Then
FailSafe('Could not find Bones!');
FindNormalRandoms;
WriteLn('Waiting');
AntiBan;
Wait(500);
If InvCount=PlusOne Then
WriteLn('we got one');
Until (InvCount=PlusOne) or (TimeFromMark(TreeCounter)> 7000)
end;
end;

begin
SetUpSRL;
//ActivateClient;
DeclarePlayers;
LoginPlayer;
repeat
LootBones;
until(false);
end.

above the LootBones Function you need to use ACA AutoColorFunction to create the Function for you once you get your colors setup. Watch Let YoHoJo break it down for you at https://www.youtube.com/watch?v=98wVrr6GwyU
Hope this helps a bit. I don't know to much other than what I've seen in the guides, so my standards aren't the best either.

Polack

2015-04-06 19:23:51

Thank you Zace, that was very helpful.
I've gotten this far, but I'm having some hellish error that won't go away: [Error] (46:8): Type mismatch at line 47


procedure Loot;
var
x, y: Integer;
z: integer;
I: integer;
TooLong: integer;
PlusOne: integer;
begin
MarkTime(TooLong);
PlusOne :=InvCount + 1
x :=MSCX;
y :=MSCY;
I :=0
repeat
repeat
if FindObjCustom(x, y, ['Take', 'ones'], [COLOR], 3) then
begin
Mouse(x, y, 0, 0, mouse_left);
while(isMoving) do wait(z); // this is much better then Flag.
if InvCount=PlusOne then
Inc(I); // I'm assuming this will increase 'I' after every loot so bot knows when to world hop
end;
until I =4 or (TimeFromMark(TooLong>4000)) //TimeFromMark is just in case there aren't 4 items on the ground (someone else looting) and it doesn't stay in same world
WorldHop;
until(InvFull)
end; <------------- Line 47

Procedure WorldHop;
begin
Logout;
SelectWorld(10); <- any way to make it alternate between set worlds (cases)?
LogInPlayer;
end;


Have solved (with everyone's help):Choosing closet object (combination of x :=MSCX ; y :=MSCY), waiting before clicking next object (isMoving function)


Need help with: Looking over my code to see if what I have will work, fixing this compiling error, world switching input


Will work on myself: Better item recognition (TPA's) as well as banking.



I appreciate all the input so far!!

Zace

2015-04-06 23:04:04

First off you have few mistakes not using semicolons were needed, all Inc does is call InChat(Text:String) so to me its just looking for chat true or false do to it being a function so i would say its useless in the way you have it. Plus i'am not familiar with it as i'am new to scripting.
To be honest i would make a function called findbones, then make a procedure called loot, and all you have to do is call the function into the procedure. The procedure should be as simple as just creating mouse movements once the function is done properly. But make sure you look back at homes example and get the picking bones section down before moving on to word hopping.

Below is what i came up with hope this helps, although it still has issues.

procedure loot;
var
x, y: Integer;
z: integer;
I: integer;
TooLong: integer;
PlusOne: integer;
begin
MarkTime(TooLong);
PlusOne :=InvCount + 1; // needed a ;
x :=MSCX;
y :=MSCY;
I :=0; // needed a ;
repeat
//repeat Duplicate repeats
if FindObjCustom(x, y, ['Take', 'ones'], [123], 3) then
begin
Mouse(x, y, 0, 0, mouse_left);
while(isMoving) do
wait(z); // this is much better then Flag.
if InvCount=PlusOne then
writeLn('found a bone');
Inc(I);
begin // Talked about it below
if not (InvCount = PlusOne) or (TimeFromMark(TooLong)>4000) then //So TimeFromMark just counts 4 secs from when you last called MarkTime hope that kind of makes sense. You also needed to put Then at the end of this if calling more commands in the script if not just take it out and call end;
writeLn('is this where i hop?'); //WorldHop;//not sure about this...
//until(InvFull)
end;
end;
end;

Polack

2015-04-07 22:32:23

This is what I have so far; it works pretty well (world hopper is pretty ghetto, but it's not half bad (I'll have to add more cases probably so it doesn't log in same world too often)). I need to work on item recognition still (TPA's), as finding the object sometimes seems to take it a while, but it's passable for now. Next step is depositing items in chest, and withdrawing necessary teleport jewelry when out of charges. End is in sight at least though for my first real script.

program Collector;
{$DEFINE SMART}
{$i srl-osr/srl.simba}
{$I SRL-OSR\SRL\misc\SmartGraphics.simba}

const
COLOR = X;
AMOUNT_TO_PICK = 3;
WAIT_TIME = 3000;

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].WorldInfo := []; // ***Desired World, leave blank if random***
Players[0].Name :='Name';
Players[0].Pass :='Password';
Players[0].Nick :='Unecessary';
Players[0].Active:=True;
end;
procedure LootAll;
var
x, y: Integer;
z: integer;
PlusOne: integer;

begin
PlusOne :=InvCount + 1;
x :=MSCX;
y :=MSCY;
if FindObjCustom(x, y, ['Take', 'X'], [COLOR], 3) then
begin
Mouse(x, y, 0, 0, mouse_left);
while(isMoving) do wait(z);
if InvCount=PlusOne then
writeln('Found the item!');
end else
begin
Logout;
begin
case (Random(7)) of
0: SelectWorld(X1);
1: SelectWorld(X2);
2: SelectWorld(X3);
3: SelectWorld(X4);
4: SelectWorld(X5);
5: SelectWorld(X6);
6: SelectWorld(X7);
end;
LogInPlayer;
end;
end;
end;


Procedure TeleportToBank;
begin
if(InvFull) then
begin
GameTab(Tab_Equip); //go to equipment tab
if WearingItem(3) then //https://villavu.com/forum/archive/index.php/t-84362.html
begin
MouseEquippedItem('necklace',mouse_right); //mouse right = false
Wait(100 + Random(200));
WaitOption('Clan', 2000); //https://villavu.com/forum/showthread.php?t=77161&p=970654#post970654
end;
end;
end;
Procedure FindDoor;
var
x, y: Integer;
begin
Wait(3000);
If findObjCustom(x, y, ['pen'], [DOOR COLOR], 5) then
begin
Wait(randomRange(1000, 1500));
Mouse(x, y, 0, 0, mouse_right);
Wait(200 + Random(150));
ChooseOption('Open door');
writeln('We opened the door!');
end else
begin
If findObjCustom(x, y, ['lose'], [DOOR COLOR], 5) then
begin
Writeln('Door was already open, continuing to bank');
end;
end;
end;

procedure mainLoop;
begin
LootAll;
TeleportToBank;
FindDoor;
end;


begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('n');
repeat
mainLoop;
until(false);
end.

Thanks for all the help, and if you any suggestions please tell me!