SRL Archive - OSR Help

All round struggle, need help :)


stuartroad

2012-06-04 02:03:42

Hey guys, this is my first script and I am really struggling with a few certain things. Here is my list:

  • Cuts a new tree before finished cutting last one,
  • Sometimes randomly stops cutting, hovers over the tree and is waiting for it to be felled but never happens cause it doesn't right click, has something to do with the above error.
  • Makes a fire fine.
  • Doesn't wait till the fire is made before starting to add to bonfire.
  • After removing the bonfire bit, It just ends the script once it has made 1 fire.
I know there are a lot of un used variables, they are for future things.

Please fire your constructive criticism cannon at me :)

program BarbarianChopNBonfire;
{$DEFINE SMART}
{$i srl\srl.simba}


const
SRLStats_User = ''; // Your SRL Stats Username
SRLStats_Password = ''; // Your SRL Stats Password
SERVER = 0; // Enter "0" to pick a random server.
MEMBERS = True;
Version ='1.0';
Leftclick = 'True'; // Left click add to Bonfire
Log = 'NormalLog'; // NormalLog, Oak, Willow, Maple, Yew, Magic ;

var
Start, Ending, LevelsGained, FireSpirts, LogsCutAndBurnt, TotalXP, x, y, NormalLog, Oak, Willow, Maple, Yew,
Found: Extended;

Procedure DeclarePlayers;

begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='@hotmail.com';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Pin := ''; //don't need
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'ssence'];
Players[0].Member := True;
Players[0].Active:=True;
end;

procedure StartingXp;
begin
Start := GetXPBarTotal
Writeln ('Getting Starting Xp');
end;

procedure EndingXp;
begin
Ending := GetXPBarTotal
Writeln ('Getting Ending Xp');
end;

Procedure LevelUps;
begin
if (LevelUp) then
Inc (LevelsGained);
Writeln('Gained a Level!');
end;
function AddLogsToFire: Boolean;
begin
if FindBlackChatMessage ('add') then
begin
Result := True;
end else Result := False;
Writeln ('Adding the logs to bonfire');
end;

procedure LogsCutBurnt;
begin
if FindBlackChatMessage('You add a log to the fire') then
Inc(LogsCutAndBurnt)
end;

procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
case Random(8000) of
0:
begin
HoverSkill('Woodcutting', false);
wait(2453+Random(432));
end;
1: PickUpMouse;
2:
begin
MakeCompass('N');
wait(100+random(133));
MakeCompass('S');
wait(50+random(133));
MakeCompass('N');
FindNormalRandoms;
end;
3:
begin
HoverSkill('Firemaking', false);
wait(2453+Random(432));
end;
end;
end;

procedure Chop;

var x, y: integer;

begin

begin
repeat
FindNormalRandoms
if FindObj(x,y,'ver', 1453860, 35) then
Writeln ('Found Tree');
begin
Mouse(x, y, 0, 0, false);
ChooseOption('hop');
Writeln ('Chopping Tree');
end;
repeat
Wait(300+ random(300));
until not IsUpText('ree') or (InvFull);
until (InvFull);
Writeln ('Invent Full, Burning');
end;
end;

procedure MakeFire;
var
x, y, NormalLog: Integer;
begin
if not LoggedIn then Exit;
if not (getCurrentTab = tab_Inv) then
FTab (tab_Inv);
begin
NormalLog := DTMFromString('mLgAAAHicY2JgYNBiYmAwAWJ9RgYGHSAOtldlcDCQYWAFyoEwIxQzMAAAOcMCEQ==');
if FindDTM(NormalLog, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
MMouse(x, y, 2, 2);
if IsUpText('og') then
Writeln('Found Log');
begin
ClickMouse2(mouse_right);
WaitOption('ight', 300);
Writeln('Burning Log');
end;
end;
end;
end;

procedure BonFire;

var x, y, NormalLog: Integer;

begin
if not LoggedIn then Exit;
if not (getCurrentTab = tab_Inv) then
FTab (tab_Inv);
if InvEmpty then
Chop;
begin
NormalLog := DTMFromString('mLgAAAHicY2JgYNBiYmAwAWJ9RgYGHSAOtldlcDCQYWAFyoEwIxQzMAAAOcMCEQ==');
if FindDTM(NormalLog, x, y, MIX1, MIY1, MIX2, MIY2) then
Writeln('Found Log');
ClickMouse2(mouse_left);
begin
Wait(250+random(150));
WaitOption('Add to bonfire', 200);
MouseBox(305, 420, 315, 435, mouse_Left);
Writeln('Making Bonfire');
while ExistsItem(27) do wait(100); //wait until last slot empty
end;
end;
end;

begin
Smart_Signed := TRUE;
Smart_Members := MEMBERS;
Smart_SuperDetail := FALSE;
Smart_Server := 35;
ActivateClient;
SetupSRL;
DeclarePlayers;
if not (LoggedIn) Then
begin
LoginPlayer;
end;
ClickNorth (SRL_ANGLE_HIGH);
wait(40+random(20));
repeat
Chop;
MakeFire;
BonFire;
Antiban;
until(false)
end.


I have tried to use FindBlackChatMessage to wait till a fire is made before starting the bonfire bit but I cannot seem to make this work, is there something else I could use, I know I need to put in a bit that searches for a fire also.

J J

2012-06-04 02:35:02

In your bonfire procedure the statements aren't working properly. Let's start up by fixing the standards (a bit) :P
procedure BonFire;
var
x, y, NormalLog: Integer;

begin
// Checking if we are logged in and/or need to change tabs
if not(LoggedIn) then Exit;
if not(getCurrentTab = tab_Inv) then
FTab (tab_Inv);
// Checking if our inventory is full
if not(InvEmpty) then
begin
// Our inventory is full so time to make a bonfire
NormalLog := DTMFromString('mLgAAAHicY2JgYNBiYmAwAWJ9RgYGHSAOtldlcDCQYWAFyoEwIxQzMAAAOcMCEQ==');
if FindDTM(NormalLog, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Found Log');
ClickMouse2(2);
if WaitOptionMulti(['onfi', 'Add', 'bon'], 500) then
begin
MouseBox(305, 420, 315, 435, 1);
Writeln('Making Bonfire');
while ExistsItem(28) do Wait(100); //wait until last slot empty
end;
end;
end else
begin
WriteLn('Inventory isn`t full yet, chopping!');
Chop;
end;
end;

I'm not sure what this "MouseBox(305, 420, 315, 435, 1);" is supposed to do but I don't think you can simply right click a log and click add to bonfire to add your whole inventory to a bonfire. It might be possible though, but I would double check it.

Try to run each procedure individually, chop a full inventory and try to run this procedure. Once that works you can make the Chop procedure better, etc.

stuartroad

2012-06-04 02:41:16

"MouseBox(305, 420, 315, 435, 1);" is supposed to go to the location of where the add to bonfire picture thing is, Just realized I forgot to add that it's meant to click once it goes to that location.
is that what thats meant to do?

while ExistsItem(28) do Wait(100); //wait until last slot empty —– this bit is meant to only do till 27 because axe not equipped, when i implement spirit finding i will need to find a different way to do this.

Gotta help the kids with homework and cook dinner, Please continue your help, I am very thankful :)

Hazzah

2012-06-04 02:42:38

procedure MakeFire;
var
x, y, NormalLog: Integer;
begin
if not LoggedIn then Exit;
if not (getCurrentTab = tab_Inv) then
FTab (tab_Inv);
begin
NormalLog := DTMFromString('mLgAAAHicY2JgYNBiYmAwAWJ9RgYGHSAOtldlcDCQYWAFyoEwIxQzMAAAOcMCEQ==');
if FindDTM(NormalLog, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
MMouse(x, y, 2, 2);
if IsUpText('og') then
Writeln('Found Log');
begin
ClickMouse2(mouse_right);
WaitOption('ight', 300);
//Add a Wait option here, like, Wait(RandomRange(1200,1500));
Writeln('Burning Log');
end;
end;
end;
end;

procedure Chop;

var x, y: integer;

begin

begin
repeat
FindNormalRandoms
if FindObj(x,y,'ver', 1453860, 35) then
Writeln ('Found Tree');
begin
Mouse(x, y, 0, 0, false);
ChooseOption('hop');
//Marktime;
Writeln ('Chopping Tree');
end;
repeat
Wait(300+ random(300));
until not IsUpText('ree') or (InvFull) {or TimeFromMark>15000};
until (InvFull);
Writeln ('Invent Full, Burning');
end;
end;

I have yet to finish writing my first script, but I think these would be the best way to handle your mentioned issues.

stuartroad

2012-06-04 05:34:51

Thanks guys, I will fix it up tomorrow.

stuartroad

2012-06-05 03:51:12

Hey guys, Few more problems if you don't mind helping me again…

  • I still have a problem with chopping the tree, if the character moves, the mouse is no longer hovering the tree so it thinks the tree has been felled, and begins finding another tree, eventually it stop running between tree's and chops one.
  • Now the script doesn't even start making a bonfire, skips right over it and says "Inventory is not full, Chopping!" This shows me that it does go through the bonfire procedure, just doesn't do it for some reason?

program BarbarianChopNBonfire;
{$DEFINE SMART}
{$i srl\srl.simba}


const
SRLStats_User = ''; // Your SRL Stats Username
SRLStats_Password = ''; // Your SRL Stats Password
SERVER = 0; // Enter "0" to pick a random server.
MEMBERS = True;
Version ='1.0';
Leftclick = 'True'; // Left click add to Bonfire
Log = 'NormalLog'; // NormalLog, Oak, Willow, Maple, Yew, Magic ;

var
Start, Ending, LevelsGained, FireSpirts, LogsCutAndBurnt, TotalXP, x, y, NormalLog, Oak, Willow, Maple, Yew,
Found: Extended;

Procedure DeclarePlayers;

begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='@hotmail.com';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Pin := ''; //don't need
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'ssence'];
Players[0].Member := True;
Players[0].Active:=True;
end;

procedure StartingXp;
begin
Start := GetXPBarTotal
Writeln ('Getting Starting Xp');
end;

procedure EndingXp;
begin
Ending := GetXPBarTotal
Writeln ('Getting Ending Xp');
end;

Procedure LevelUps;
begin
if (LevelUp) then
Inc (LevelsGained);
Writeln('Gained a Level!');
end;
function AddLogsToFire: Boolean;
begin
if FindBlackChatMessage ('add') then
begin
Result := True;
end else Result := False;
Writeln ('Adding the logs to bonfire');
end;

procedure LogsCutBurnt;
begin
if FindBlackChatMessage('You add a log to the fire') then
Inc(LogsCutAndBurnt)
end;

procedure MarkTimer(var TimeMarker: Integer);
begin
TimeMarker := GetSystemTime;
end;

procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
case Random(8000) of
0:
begin
HoverSkill('Woodcutting', false);
wait(2453+Random(432));
end;
1: PickUpMouse;
2:
begin
MakeCompass('N');
wait(100+random(133));
MakeCompass('S');
wait(50+random(133));
MakeCompass('N');
FindNormalRandoms;
end;
3:
begin
HoverSkill('Firemaking', false);
wait(2453+Random(432));
end;
end;
end;

procedure Chop;

var x, y: integer; t:Integer;

begin

begin
repeat
FindNormalRandoms
if FindObj(x,y,'ver', 1453860, 35) then
Writeln ('Found Tree');
begin
Mouse(x, y, 0, 0, false);
ChooseOption('hop');
MarkTime(t)
Writeln ('Chopping Tree');
end;
repeat
Wait(300+ random(300));
until not IsUpText('ree') or (InvFull) or (TimeFromMark(t) > 15000)
until (InvFull);
Writeln ('Invent Full, Burning');
end;
end;

procedure MakeFire;
var
x, y, NormalLog: Integer;
begin
if not LoggedIn then Exit;
if not (getCurrentTab = tab_Inv) then
FTab (tab_Inv);
begin
NormalLog := DTMFromString('mLgAAAHicY2JgYNBiYmAwAWJ9RgYGHSAOtldlcDCQYWAFyoEwIxQzMAAAOcMCEQ==');
if FindDTM(NormalLog, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
MMouse(x, y, 2, 2);
if IsUpText('og') then
Writeln('Found Log');
begin
ClickMouse2(mouse_right);
WaitOption('ight', 300);
Wait(RandomRange(1200,1500));
Writeln('Burning Log');
end;
end;
end;
end;

procedure BonFire;

var x, y, NormalLog: Integer;

begin
begin
NormalLog := DTMFromString('mLgAAAHicY2JgYNBiYmAwAWJ9RgYGHSAOtldlcDCQYWAFyoEwIxQzMAAAOcMCEQ==');
if FindDTM(NormalLog, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Found Log');
ClickMouse2(2);
if WaitOptionMulti(['onfi', 'Add', 'bon'], 500) then
begin
MouseBox(305, 420, 315, 435, mouse_Left);
Writeln('Making Bonfire');
while ExistsItem(27) do wait(100); //wait until last slot empty
end;
end;
end
begin
Writeln('Inventory is not full, Chopping!');
Chop;
end;
end;

begin
Smart_Signed := TRUE;
Smart_Members := MEMBERS;
Smart_SuperDetail := FALSE;
Smart_Server := 35;
ActivateClient;
SetupSRL;
DeclarePlayers;
if not (LoggedIn) Then
begin
LoginPlayer;
end;
ClickNorth (SRL_ANGLE_HIGH);
wait(40+random(20));
repeat
Chop;
MakeFire;
BonFire;
Antiban;
until(false)
end.


J J

2012-06-05 04:53:03

For the tree chopping I would rely on either Pixelshift or both pixelshift and uptext.
WriteLn('Pixelshift: '+PixelShift(IntToBox(X1, Y1, X2, Y2), Time)+'');  
Fill in the coordinates of your character, those should be static. Then keep running it until you know what pixelshift there averagely is when chopping a tree OR when you aren't chopping a tree. Then make something like repeat wait until(pixelshift > 500) etc. Oh yeah you also have to fill in the time you want to count the pixelshift in, it's in milliseconds.

For the log burning:
MMouse(x, y, 2, 2);
if IsUpText('og') then
Writeln('Found Log');
You find a DTM in the inventory so it must be a log, DTM's are really accurate. If you move your mouse there the uptext won't be 'og' instantly, there is a delay so you need to use WaitUptext or WaitUptextMulti. But you can also simply Rightclick instantly because you find it by using a DTM.

if FindDTM then
begin
MMouse(X, Y, RandomRange(-2, 2), RandomRange(-2, 2));
ClickMouse2(0);
WaitOption('ight', 500);
Something with Pixelshift here
Add to bonfire procedure here
Then use pixelshift again to know when the log has been lit, you could use chatboxtext aswell. Then use a mousebox or findcolor to get the fire position and add to bonfire.