SRL Archive - OSR Help

Hovers trees but does nothing


Syntax

2013-03-09 09:59:12

I have been working on this script for 2 in a half hours and I cannot get it work work. I now have changed so much on it I'm getting really confused.
If someone could run it, and see the error I'm having with the loop of hovering trees and then running to the trees location on the minimap…
I'd REALLY appreciate it. Here is the code:
program WillowTreeBanker;
{$DEFINE SMART}
{$I SRL/SRL.Simba}
{$I P07Include.Simba}

var
CurTime, ProgTime, ProgBank, InitWait, InitChopWait, AxeFailSafe1, AxeFailSafe2,
AxeFailSafeToggle,AxeFailSafeTime, LocFailSafe, AxeFailSafe, AnimationCheck,
Skiller, RunFromCombat, Lagg, ChopWaitTime,TreeColor, BankDTM, BankColor1: integer;
Location: string;

procedure DTM;
begin
begin
skiller := 1;
end;
begin
RunFromCombat := 1;
end
Lagg := strtoint('500') ; //lag time in ms
ChopWaitTime := strtoint('20') ; //time in seconds to check if chopping
AnimationCheck := strtoint ('90') ; //for pixelshift, chopping

case random(0) of
0: Location := 'Willow';
end;
begin
TreeColor := 12892;
BankColor1 := 8229016;
BankDTM := DTMFromString('mQwAAAHicY2ZgYOBnYWAQBmJpIH7IgMB//jDBMSuQD8OMSBgIAFujCPA=');
end;

end;

Procedure P07_DeclarePlayer;
Begin
P07_PlayerName:='username' ;
P07_PlayerPass:='pass' ;
end;

//DONT EDIT BELOW

procedure WaitHumanClick;
begin
case random(606) of
1..442: Wait(RandomRange(0, 125));
443..575: Wait(RandomRange(0, 201));
573..590: Wait(RandomRange(0, 605));
591..606: Wait(RandomRange(412, 1009));
end;
end;

procedure FreeDTMss;
begin
FreeDTM(BankDTM);
MarkTime(CurTime);
writeln('Banked ' + inttostr(ProgBank) + ' invs in ' + inttostr(((TimeFromMark(ProgTime) / 1000) / 60)) + ' mins.');
end;

procedure GoToBank;
var x, y: integer;
begin
P07_MakeCompassNorth;
if(not(P07_BankScreen)) then
begin
WaitHumanClick;
if(findDTM(BankDTM, x, y, 565, 7, 717, 157)) then
begin
case Location of
'Willow': Mouse(RandomRange(X + 15, x + 20), RandomRange(Y - 8, Y - 13), random(3), random(3), true);
'Maple': Mouse(RandomRange(X - 5, x + 5), RandomRange(Y + 10, Y + 15), random(3), random(3), true);
end;
end;
P07_FFlag;
wait (lagg);
end;
end;

procedure BankLogs;
begin
wait(lagg);
if(P07_BankScreen) then
begin
if(skiller = 1) then
begin
P07_Deposit(2, 28, True);
wait (lagg);
end
else
begin
P07_Deposit(1, 28, True);
wait (lagg);
end;
end;
//if(((P07_InvCount < 2) and (skiller = 1)) or ((P07_InvCount < 1) and (skiller = 0))) then
//begin
ProgBank := ProgBank + 1;
//end;
end;

procedure OpenBank1;
var x, y: integer;
begin
Repeat
If P07_FindObj(x, y, 'ank booth', BankColor1, 10) Then
begin
LocFailSafe := 0;
WaitHumanClick;
Mouse(RandomRange(X - 5, x + 5), RandomRange(Y - 5, Y + 5), random(3), random(3), false);
WaitHumanClick;
P07_ChooseOptionMulti(['se-q']);
end
else
begin
P07_MakeCameraAngleHigh;
P07_MakeCompassDegree(randomrange(25, 35));
LocFailSafe := LocFailSafe + 1;
GoToBank;
end;
P07_FFlag;
wait (lagg);
until(P07_BankScreen)
end;

procedure GoToTrees;
var x, y: integer;
begin
P07_MakeCompassNorth;
WaitHumanClick;
if(findDTM(BankDTM, x, y, 565, 7, 717, 157)) then
begin
case Location of
'Willow': Mouse(RandomRange(X - 7, x - 17), RandomRange(Y + 17, Y + 27), random(4), random(3), true);
'Maple': Mouse(RandomRange(X, x + 10), RandomRange(Y - 10, Y - 15), random(3), random(3), true);
end;
end;
P07_FFlag;
wait (lagg);
end;


procedure ChopTree;
var
x, y,tmpCTS:integer;
TreeTPA:TPointArray;
begin
tmpCTS := GetColorToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.03, 1.64); //Ive plugged in my hue and sat mods. Plug in your own here.
if FindColorsTolerance(TreeTPA, 2649183, MSX1, MSY1, MSX2, MSY2, 6) then
begin
MMouse(RandomRange(X - 7, X + 7), RandomRange(y - 8, y + 6), 0, 0);
GetMousePos(x,y);
SetColorToleranceSpeed(tmpCTS); //RIGHT AFTER we find our colors, we
SetToleranceSpeed2Modifiers(0.02, 0.02); //Change the CTS back.
if (P07_ContainsText(GetTextAtExWrap(35, 8, 170, 21, 0, 5, 1, 13423640, 65, 'P07UpChars'), [Location])) then
begin
GetMousePos(x, y);
LocFailSafe := 0;
if(random(2) = 1) then
begin
Mouse(x,y,0,0,true);
end
else
begin
Mouse(x,y,0,0,false); //clicks it
P07_ChooseOptionMulti(['hop']);
end;
end
else
begin
GoToTrees;
end;
P07_FFlag;
wait (Lagg * 2 + 250);
MMouse(x, y, 0, 0);
if (P07_FindObj(x, y, Location, TreeColor, 5) and P07_ContainsText(GetTextAtExWrap(35, 8, 170, 21, 0, 5, 1, 13423640, 65, 'P07UpChars'), [Location])) then
begin
if(AxeFailSafe > ChopWaitTime) then
begin
MarkTime(InitChopWait);
InitWait := 1;
end;
//Mouse(RandomRange(X - 5, x + 5), RandomRange(y - 5, y + 5), random(5), random(5), True);
end
else
begin
Mouse(242, 195, random(3), random(3), true);
end;
end
else
begin
wait(2000); //goes to trees if cant find trees
if((LocFailSafe = 0) or (LocFailSafe = 5) or (LocFailSafe = 10) or (LocFailSafe = 15) or (LocFailSafe = 20)) then
begin
P07_MakeCompassDegree(randomrange(25, 35));
GoToTrees;
end;
LocFailSafe := LocFailSafe + 1;
end;
end;

procedure TurnOnRun;
var x, y: integer;
begin
Mouse(671, 482, random(5), random(5), true);
WaitHumanClick;
if(FindColorTolerance(x, y, 4803917, 651, 422, 659, 430, 10)) then
begin
Mouse(640, 426, random(5), random(5), true);
end;
Mouse(644, 184, random(5), random(5), true);
end;

Function isMoving1: Boolean;
var
PBox: TBox;
begin
PBox := IntToBox(220, 140, 300, 200);
Result := (AveragePixelShift(PBox, 250, 500) > AnimationCheck);
//Writeln(IntToStr(AveragePixelShift(PBox, 250, 500)));
end;

Function AntiBan: Boolean;
var x,y:integer;
begin
case random(400) of
0: P07_HoverSkill('woodcutting', random(5000));
1: TurnOnRun;
2: P07_MakeCameraAngleHigh;
3: P07_MakeCompassSouth;
4: P07_MakeCompassEast;
5: P07_MakeCompassWest;
6: P07_MakeCompassNorth;
7: MMouse(RandomRange(X - 9, X + 9), RandomRange(y - 9, y + 9), 0, 0);
8: MMouse(RandomRange(X - 12, X + 12), RandomRange(y - 12, y + 12), 0, 0);
end;
end;


begin
SetupSRL();
P07_DeclarePlayer;
SetupP07Include;
ActivateClient;
Wait(2000);

If (Not P07_LoggedIn) Then
begin
P07_LogInPlayer;
end;

P07_MakeCameraAngleHigh;
P07_MakeCompassNorth;
InitChopWait := 0;
InitWait := 0;
ProgBank := 0;
MarkTime(ProgTime);
DTM;
AddOnTerminate('FreeDTMss')
TurnOnRun;
LocFailSafe := 0;
AxeFailSafe := 80;
AxeFailSafeToggle := 0;
AxeFailSafe1 := 0;
AxeFailSafe2 := 0;
MarkTime(AxeFailSafeTime);

repeat
AntiBan;

if(TimeFromMark(InitChopWait) > (ChopWaitTime * 500)) then
begin
InitWait := 0;
end;

if(timefromMark(AxeFailSafeTime) > 500) then
begin
if(AxeFailSafeToggle = 0) then
begin
AxeFailSafe1 := p07_invCount;
AxeFailSafeToggle := 1;
end
else
begin
AxeFailSafe2 := p07_invcount;
AxeFailSafeToggle := 0;
if (AxeFailSafe2 = AxeFailSafe1) then
begin
AxeFailSafe := AxeFailSafe + 1;
end
else
begin
AxeFailSafe := 0;
end;
end;
MarkTime(AxeFailSafeTime);
end;

if(((CountColorTolerance(255, 220, 140, 300, 200, 2) + CountColorTolerance(65280, 230, 130, 280, 180, 2)) > 100) and (RunFromCombat = 1)) then
begin
Mouse(305, 174, random(10), random(10), true);
P07_FFlag;
wait (lagg);
if((CountColorTolerance(255, 220, 140, 300, 200, 2) + CountColorTolerance(65280, 230, 130, 280, 180, 2)) > 100) then
begin
GoToBank;
if(((P07_InvCount > 1) and (Skiller = 0)) or ((P07_InvCount > 2) and (Skiller = 1))) then
begin
OpenBank1;
BankLogs;
end;
GoToTrees;
end;
end;

if not P07_TabInventoryTab(4) then
begin
P07_TabInventoryTab(4)
end;

if(P07_InvFull) then
begin
GoToBank;
OpenBank1;
BankLogs;
GoToTrees;
end
else
begin
if(not isMoving1) then
begin
ChopTree;
end
else
begin
if((AxeFailSafe > ChopWaitTime) and (InitWait = 0)) then
begin
ChopTree;
end
else
begin
if(random(10) = 1) then
begin
MMouse(RandomRange(-100, 900), RandomRange(-100, 600), random(10), random(10));
end;
end;
end;
end;
until (Not P07_LoggedIn or (LocFailSafe > 25) or (AxeFailSafe > 100))
writeln(P07_LoggedIn);
writeln('LocFailSafe: ' + inttostr(LocFailSafe));
writeln('AxeFailSafe: ' + inttostr(AxeFailSafe));
TerminateScript;
end.

Thank you and mad respect to who gets the script working properly +1

Runehack123

2013-03-09 10:08:32

From: Blakebn2011
I have been working on this script for 2 in a half hours and I cannot get it work work. I now have changed so much on it I'm getting really confused.
If someone could run it, and see the error I'm having with the loop of hovering trees and then running to the trees location on the minimap…

I can help if you actually tell me the 'error' you're having.
Also, so many global variables…only go with global var if you can really see no other way around it is my first advice to you.

xtrapsp

2013-03-09 10:16:51

From: Runehack123
I can help if you actually tell me the 'error' you're having.
Also, so many global variables…only go with global var if you can really see no other way around it is my first advice to you.


What? That's not what global variables are for…

What you mean to say is, if you are changing the value of a variable in the WHOLE script then make a global. Otherwise put them locally in each function or procedure…

Don't just make a global var because it seems easier…

Runehack123

2013-03-09 10:21:23

From: xtrapsp
What? That's not what global variables are for…

What you mean to say is, if you are changing the value of a variable in the WHOLE script then make a global. Otherwise put them locally in each function or procedure…

You mean me? Or him?

xtrapsp

2013-03-09 10:22:28

From: Runehack123
You mean me? Or him?


From: Runehack123
Also, so many global variables...only go with global var if you can really see no other way around it is my first advice to you.


You.

Sjoe

2013-03-09 10:25:35

From: Runehack123
You mean me? Or him?


Brad meant that u didn't explain it well ;)

Runehack123

2013-03-09 10:30:31

From: Sjoekeloe
Brad meant that u didn't explain it well ;)

From: xtrapsp
What? That's not what global variables are for…

What you mean to say is, if you are changing the value of a variable in the WHOLE script then make a global. Otherwise put them locally in each function or procedure…

Don't just make a global var because it seems easier…

I wasn't explaining or trying to explain at all. All I said was avoid global variables.

Sjoe

2013-03-09 10:39:56

From: runehack123
i wasn't explaining or trying to explain at all. All i said was avoid global variables.


WELL, DO lT BETTER NEXT TIME

Brid Mayhem

2013-03-09 15:13:05

Go to where you extracted 07Chars and then make the chars be straight in the folder instead of a folder within a folder.

Syntax

2013-03-09 18:40:13

The global vars are not the issue, i know that much. The script started to have issues when I introduced TPointArrays into the finding methods for the Willow trees. Now it will only hover the tree, tried grabbing the mouse pos and MMouse(x,y,0,0, true);
No good, I was hoping someone who plays 07 and knows how to script would try this script out ;)
Thank you guys.

zackthewack

2013-03-12 23:52:35

Alright man. I just ran it. The script compiles and runs and everything, it just doesn't work haha.

I am standing in the bank and it keep trying to click a tile in the bank. Not on the minimap, just keeps clicking a tile in the bank.

If I knew how to find colors and all of that, I would help you find the tile it was clicking. I have been searching everywhere on how to find colors for my own script haha.

However, it clicks, moves the mouse to the top left, and then clicks in the same spot again.

I would recommend maybe making an if statement with a null connected to the color ID for the bank. If the null comes back as false or 0, whichever you have it has, then have it so that it turns the camera to the north, south, east,or west, and then click the bank. And maybe mae it so that it clicks the bank when the camera is to the North, south, east, or west. Instead of making an if statement, you can just make it so that it automatically checks the camera, moves to the direction you need it to, AND THEN bank. That will make the camera angle correct always.

I don't know much about scripting yet, but I am learning haha.


EDIT: and i will try to help you out as much as possible with this by running it, etc.

Also, could you point me in the right direction to finding these color IDs? I looked through the includes, etc. but I did not find anything. I found some scripts on how to find colors, but nothing for finding tree colors. and the one for finding all colors did not seem to run…